Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion source/lmp/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,44 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION)
find_package(Kokkos CONFIG REQUIRED)
target_compile_definitions(${libname} PRIVATE LMP_KOKKOS)
target_include_directories(${libname} PRIVATE ${LAMMPS_HEADER_DIR}/KOKKOS)
target_link_libraries(${libname} PUBLIC Kokkos::kokkos)

# A runtime LAMMPS plugin must use the Kokkos runtime already linked into
# liblammps. Linking the static Kokkos libraries here creates a second CUDA
# runtime instance and corrupts its shutdown state when the plugin is
# unloaded. Import only the compile/link flags needed for Kokkos device
# code; unresolved Kokkos symbols are resolved by liblammps at load time.
# Kokkos::kokkos is an umbrella target whose usage requirements may live
# only on its component targets, notably in LAMMPS build-tree packages. Copy
# those non-link properties without importing the static runtimes.
set(_kokkos_interface_targets
Kokkos::kokkos Kokkos::kokkoscore Kokkos::kokkoscontainers
Kokkos::kokkosalgorithms Kokkos::kokkossimd)
foreach(_kokkos_target IN LISTS _kokkos_interface_targets)
if(TARGET ${_kokkos_target})
foreach(_kokkos_property IN
ITEMS INCLUDE_DIRECTORIES COMPILE_DEFINITIONS COMPILE_OPTIONS
LINK_OPTIONS COMPILE_FEATURES)
get_target_property(_kokkos_value ${_kokkos_target}
INTERFACE_${_kokkos_property})
if(_kokkos_value)
list(APPEND _kokkos_${_kokkos_property} ${_kokkos_value})
endif()
endforeach()
endif()
endforeach()
target_include_directories(${libname} SYSTEM
PRIVATE ${_kokkos_INCLUDE_DIRECTORIES})
target_compile_definitions(${libname}
PRIVATE ${_kokkos_COMPILE_DEFINITIONS})
target_compile_options(${libname} PRIVATE ${_kokkos_COMPILE_OPTIONS})
target_link_options(${libname} PRIVATE ${_kokkos_LINK_OPTIONS})
target_compile_features(${libname} PRIVATE ${_kokkos_COMPILE_FEATURES})
if(TARGET Kokkos::CUDA)
target_link_libraries(${libname} PRIVATE Kokkos::CUDA)
endif()
if(TARGET Kokkos::LIBDL)
target_link_libraries(${libname} PRIVATE Kokkos::LIBDL)
endif()
endif()

# link: libdeepmd
Expand Down
Loading