Skip to content

Commit a9db0b1

Browse files
authored
Merge branch 'develop' into 20260203
2 parents ba64c35 + 06fb968 commit a9db0b1

144 files changed

Lines changed: 11903 additions & 4306 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/devcontainer.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
matrix:
1818
dockerfile: ["gnu","intel","cuda"]
1919
steps:
20+
- name: Force Clean Workspace
21+
run: |
22+
sudo chattr -i -R ${{ github.workspace }} 2>/dev/null || true
23+
sudo chown -R $USER:$USER ${{ github.workspace }}
24+
sudo find ${{ github.workspace }} -mindepth 1 -delete
25+
2026
- name: Checkout
2127
uses: actions/checkout@v6
2228

CMakeLists.txt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ option(ENABLE_RAPIDJSON "Enable rapid-json usage" OFF)
5252
option(ENABLE_CNPY "Enable cnpy usage" OFF)
5353
option(ENABLE_CUSOLVERMP "Enable cusolvermp" OFF)
5454

55+
if(NOT DEFINED NVHPC_ROOT_DIR AND DEFINED ENV{NVHPC_ROOT})
56+
set(NVHPC_ROOT_DIR
57+
"$ENV{NVHPC_ROOT}"
58+
CACHE PATH "Path to NVIDIA HPC SDK root directory.")
59+
endif()
60+
5561
# enable json support
5662
if(ENABLE_RAPIDJSON)
5763
find_package(RapidJSON)
@@ -397,21 +403,9 @@ if(USE_CUDA)
397403
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}" CACHE STRING "CUDA flags" FORCE)
398404
endif()
399405
if (ENABLE_CUSOLVERMP)
400-
add_compile_definitions(__CUSOLVERMP)
401-
find_library(CAL_LIBRARY
402-
NAMES cal
403-
PATHS ${CAL_CUSOLVERMP_PATH}
404-
NO_DEFAULT_PATH
405-
)
406-
find_library(CUSOLVERMP_LIBRARY
407-
NAMES cusolverMp
408-
PATHS ${CAL_CUSOLVERMP_PATH}
409-
NO_DEFAULT_PATH
410-
)
411-
target_link_libraries(${ABACUS_BIN_NAME}
412-
${CAL_LIBRARY}
413-
${CUSOLVERMP_LIBRARY}
414-
)
406+
# Keep cuSolverMp discovery/linking logic in a dedicated module.
407+
include(cmake/SetupCuSolverMp.cmake)
408+
abacus_setup_cusolvermp(${ABACUS_BIN_NAME})
415409
endif()
416410
endif()
417411
endif()

cmake/SetupCuSolverMp.cmake

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# =============================================================================
2+
# Configure cuSolverMp dependencies and linking for ABACUS
3+
# =============================================================================
4+
5+
include_guard(GLOBAL)
6+
7+
function(abacus_setup_cusolvermp target_name)
8+
add_compile_definitions(__CUSOLVERMP)
9+
10+
# Find cuSolverMp first, then decide communicator backend.
11+
find_library(CUSOLVERMP_LIBRARY NAMES cusolverMp
12+
HINTS ${CAL_CUSOLVERMP_PATH} ${NVHPC_ROOT_DIR}
13+
PATH_SUFFIXES lib lib64 math_libs/lib math_libs/lib64)
14+
15+
find_path(CUSOLVERMP_INCLUDE_DIR NAMES cusolverMp.h
16+
HINTS ${CAL_CUSOLVERMP_PATH} ${NVHPC_ROOT_DIR}
17+
PATH_SUFFIXES include math_libs/include)
18+
19+
if(NOT CUSOLVERMP_LIBRARY OR NOT CUSOLVERMP_INCLUDE_DIR)
20+
message(FATAL_ERROR
21+
"cusolverMp not found. Set CUSOLVERMP_PATH or NVHPC_ROOT_DIR."
22+
)
23+
endif()
24+
25+
message(STATUS "Found cusolverMp: ${CUSOLVERMP_LIBRARY}")
26+
27+
set(CUSOLVERMP_VERSION_STR "")
28+
set(CUSOLVERMP_VERSION_HEADER "${CUSOLVERMP_INCLUDE_DIR}/cusolverMp.h")
29+
if(EXISTS "${CUSOLVERMP_VERSION_HEADER}")
30+
file(STRINGS "${CUSOLVERMP_VERSION_HEADER}" CUSOLVERMP_MAJOR_LINE
31+
REGEX "^#define[ \t]+CUSOLVERMP_VER_MAJOR[ \t]+[0-9]+")
32+
file(STRINGS "${CUSOLVERMP_VERSION_HEADER}" CUSOLVERMP_MINOR_LINE
33+
REGEX "^#define[ \t]+CUSOLVERMP_VER_MINOR[ \t]+[0-9]+")
34+
file(STRINGS "${CUSOLVERMP_VERSION_HEADER}" CUSOLVERMP_PATCH_LINE
35+
REGEX "^#define[ \t]+CUSOLVERMP_VER_PATCH[ \t]+[0-9]+")
36+
string(REGEX MATCH "([0-9]+)" CUSOLVERMP_VER_MAJOR "${CUSOLVERMP_MAJOR_LINE}")
37+
string(REGEX MATCH "([0-9]+)" CUSOLVERMP_VER_MINOR "${CUSOLVERMP_MINOR_LINE}")
38+
string(REGEX MATCH "([0-9]+)" CUSOLVERMP_VER_PATCH "${CUSOLVERMP_PATCH_LINE}")
39+
if(NOT CUSOLVERMP_VER_MAJOR STREQUAL ""
40+
AND NOT CUSOLVERMP_VER_MINOR STREQUAL ""
41+
AND NOT CUSOLVERMP_VER_PATCH STREQUAL "")
42+
set(CUSOLVERMP_VERSION_STR
43+
"${CUSOLVERMP_VER_MAJOR}.${CUSOLVERMP_VER_MINOR}.${CUSOLVERMP_VER_PATCH}")
44+
endif()
45+
endif()
46+
47+
# Auto-select communicator backend by cuSolverMp version.
48+
# cuSolverMp < 0.7.0 -> CAL, otherwise -> NCCL.
49+
set(_use_cal OFF)
50+
if(CUSOLVERMP_VERSION_STR AND CUSOLVERMP_VERSION_STR VERSION_LESS "0.7.0")
51+
set(_use_cal ON)
52+
message(STATUS
53+
"Detected cuSolverMp ${CUSOLVERMP_VERSION_STR} (< 0.7.0). Using CAL backend.")
54+
elseif(CUSOLVERMP_VERSION_STR)
55+
message(STATUS
56+
"Detected cuSolverMp ${CUSOLVERMP_VERSION_STR} (>= 0.7.0). Using NCCL backend.")
57+
elseif(NOT CUSOLVERMP_VERSION_STR)
58+
message(WARNING
59+
"Unable to detect cuSolverMp version from header. Using NCCL backend by default.")
60+
endif()
61+
62+
# Backend selection:
63+
# - _use_cal=ON -> cal communicator backend
64+
# - _use_cal=OFF -> NCCL communicator backend
65+
if(_use_cal)
66+
add_compile_definitions(__USE_CAL)
67+
68+
find_library(CAL_LIBRARY NAMES cal
69+
HINTS ${CAL_CUSOLVERMP_PATH} ${NVHPC_ROOT_DIR}
70+
PATH_SUFFIXES lib lib64 math_libs/lib64)
71+
find_path(CAL_INCLUDE_DIR NAMES cal.h
72+
HINTS ${CAL_CUSOLVERMP_PATH} ${NVHPC_ROOT_DIR}
73+
PATH_SUFFIXES include math_libs/include)
74+
75+
if(NOT CAL_LIBRARY OR NOT CAL_INCLUDE_DIR)
76+
message(FATAL_ERROR "CAL not found. Set CAL_PATH or NVHPC_ROOT_DIR.")
77+
endif()
78+
79+
message(STATUS "Found CAL: ${CAL_LIBRARY}")
80+
if(NOT TARGET CAL::CAL)
81+
add_library(CAL::CAL IMPORTED INTERFACE)
82+
set_target_properties(CAL::CAL PROPERTIES
83+
INTERFACE_LINK_LIBRARIES "${CAL_LIBRARY}"
84+
INTERFACE_INCLUDE_DIRECTORIES "${CAL_INCLUDE_DIR}")
85+
endif()
86+
else()
87+
88+
find_library(NCCL_LIBRARY NAMES nccl
89+
HINTS ${NCCL_PATH} ${NVHPC_ROOT_DIR}
90+
PATH_SUFFIXES lib lib64 comm_libs/nccl/lib)
91+
find_path(NCCL_INCLUDE_DIR NAMES nccl.h
92+
HINTS ${NCCL_PATH} ${NVHPC_ROOT_DIR}
93+
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
94+
PATH_SUFFIXES include comm_libs/nccl/include)
95+
96+
if(NOT NCCL_LIBRARY OR NOT NCCL_INCLUDE_DIR)
97+
message(FATAL_ERROR "NCCL not found. Set NCCL_PATH or NVHPC_ROOT_DIR.")
98+
endif()
99+
100+
message(STATUS "Found NCCL: ${NCCL_LIBRARY}")
101+
if(NOT TARGET NCCL::NCCL)
102+
add_library(NCCL::NCCL IMPORTED INTERFACE)
103+
set_target_properties(NCCL::NCCL PROPERTIES
104+
INTERFACE_LINK_LIBRARIES "${NCCL_LIBRARY}"
105+
INTERFACE_INCLUDE_DIRECTORIES "${NCCL_INCLUDE_DIR}")
106+
endif()
107+
endif()
108+
109+
# Create cusolverMp::cusolverMp imported target
110+
if(NOT TARGET cusolverMp::cusolverMp)
111+
add_library(cusolverMp::cusolverMp IMPORTED INTERFACE)
112+
set_target_properties(cusolverMp::cusolverMp PROPERTIES
113+
INTERFACE_LINK_LIBRARIES "${CUSOLVERMP_LIBRARY}"
114+
INTERFACE_INCLUDE_DIRECTORIES "${CUSOLVERMP_INCLUDE_DIR}")
115+
endif()
116+
117+
# === Link libraries ===
118+
if(_use_cal)
119+
target_link_libraries(${target_name}
120+
CAL::CAL
121+
cusolverMp::cusolverMp)
122+
else()
123+
target_link_libraries(${target_name}
124+
NCCL::NCCL
125+
cusolverMp::cusolverMp)
126+
endif()
127+
endfunction()

docs/advanced/interface/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Interfaces to Other Softwares
66
:maxdepth: 1
77
:caption: Examples
88

9+
pyabacus
910
deepks
1011
dpgen
1112
deeph

0 commit comments

Comments
 (0)