From 319f8019cf0d72441db9bde8645515e8d8bc4ff5 Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" <48687836+njzjz-bot@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:03:22 +0800 Subject: [PATCH 1/3] fix(lammps): share Kokkos runtime with LAMMPS Backport conda-forge/deepmd-kit-feedstock patch 0005 at d02138263b0b30629fe28c68c8bcecc2b8644513. Agent: ChatGPT Model: GPT-5.6 Sol --- source/lmp/plugin/CMakeLists.txt | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index 8dcbe6dd59..3c2c0b5c30 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -122,7 +122,35 @@ 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. + get_target_property(_kokkos_include_dirs Kokkos::kokkos + INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_kokkos_compile_definitions Kokkos::kokkoscore + INTERFACE_COMPILE_DEFINITIONS) + get_target_property(_kokkos_compile_options Kokkos::kokkoscore + INTERFACE_COMPILE_OPTIONS) + get_target_property(_kokkos_link_options Kokkos::kokkoscore + INTERFACE_LINK_OPTIONS) + get_target_property(_kokkos_compile_features Kokkos::kokkoscore + INTERFACE_COMPILE_FEATURES) + target_include_directories(${libname} SYSTEM PRIVATE + ${_kokkos_include_dirs}) + 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 From 6d458691921d01c650b110581fb79cc64aaa353e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Aug 2026 18:07:40 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/lmp/plugin/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index 3c2c0b5c30..6fce9b9f20 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -124,8 +124,8 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) target_include_directories(${libname} PRIVATE ${LAMMPS_HEADER_DIR}/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 + # 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. get_target_property(_kokkos_include_dirs Kokkos::kokkos @@ -138,10 +138,10 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) INTERFACE_LINK_OPTIONS) get_target_property(_kokkos_compile_features Kokkos::kokkoscore INTERFACE_COMPILE_FEATURES) - target_include_directories(${libname} SYSTEM PRIVATE - ${_kokkos_include_dirs}) - target_compile_definitions(${libname} PRIVATE - ${_kokkos_compile_definitions}) + target_include_directories(${libname} SYSTEM + PRIVATE ${_kokkos_include_dirs}) + 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}) From c121e013ade3590f3dd5877ba477fb5c1ca39193 Mon Sep 17 00:00:00 2001 From: njzjz-bot Date: Sun, 23 Aug 2026 21:25:29 +0800 Subject: [PATCH 3/3] fix(lammps): import Kokkos component usage Collect non-link interface properties from the Kokkos umbrella and component targets so LAMMPS build-tree packages do not inject NOTFOUND include paths. Coding-Agent: Codex Codex-Version: codex-cli 0.149.0 Model: gpt-5.6-sol Reasoning-Effort: xhigh --- source/lmp/plugin/CMakeLists.txt | 39 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index 6fce9b9f20..b87464a03d 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -128,23 +128,32 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) # 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. - get_target_property(_kokkos_include_dirs Kokkos::kokkos - INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(_kokkos_compile_definitions Kokkos::kokkoscore - INTERFACE_COMPILE_DEFINITIONS) - get_target_property(_kokkos_compile_options Kokkos::kokkoscore - INTERFACE_COMPILE_OPTIONS) - get_target_property(_kokkos_link_options Kokkos::kokkoscore - INTERFACE_LINK_OPTIONS) - get_target_property(_kokkos_compile_features Kokkos::kokkoscore - INTERFACE_COMPILE_FEATURES) + # 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_dirs}) + 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}) + 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()