From 8222a375ad084e504427fc4c09cc14b7d1332bc9 Mon Sep 17 00:00:00 2001 From: Joshua Kammeraad Date: Thu, 9 Jul 2026 01:05:48 -0700 Subject: [PATCH 1/2] Supply CUDA math libs via CUDAToolkit imported targets pixi-build-cmake >=0.3.12 (via rattler-build 0.62's strict env isolation) no longer forwards CPATH from the developer's shell into the build, so nvc++ lost the NVHPC module's math_libs include path and every GPU translation unit failed on #include (#98). Make the build self-sufficient instead of relying on ambient CPATH: - find_package(CUDAToolkit) when USE_ACC, and link CUDA::cublas / CUDA::cusolver PUBLIC on SlaterGPU so io, sgpu.exe, and downstream consumers inherit both headers and libraries transitively - Replace the removed FindCUDA module and hand-rolled NVHPC math_libs library paths in examples/ with CUDA::cudart - Replace deprecated find_package(CUDA) in SlaterGPUConfig.cmake.in with find_dependency(CUDAToolkit) gated on the USE_ACC build setting (#93) Verified with a cold pixi build pinned to backend 0.3.14 (sanitized env): CUDAToolkit 12.9.41 is discovered from the NVHPC layout via PATH alone and all previously failing cuBLAS/cuSolver TUs compile. Co-Authored-By: Claude Fable 5 --- CMakeLists.txt | 4 ++++ SlaterGPUConfig.cmake.in | 8 ++++---- examples/CMakeLists.txt | 20 ++++++-------------- src/integrals/CMakeLists.txt | 3 +++ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64aa9dc..e790a5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,10 @@ if (USE_OMP) endif() if (USE_ACC) find_package(OpenACC REQUIRED) + # Provides CUDA::cublas / CUDA::cusolver imported targets (headers + libs), + # so the GPU build does not depend on CPATH from the developer's shell + # reaching the compiler (see issue #98) + find_package(CUDAToolkit REQUIRED) endif() set(CMAKE_CXX_STANDARD 14) diff --git a/SlaterGPUConfig.cmake.in b/SlaterGPUConfig.cmake.in index 9ed9cc8..991b47f 100644 --- a/SlaterGPUConfig.cmake.in +++ b/SlaterGPUConfig.cmake.in @@ -8,10 +8,10 @@ find_dependency(MPI REQUIRED) find_dependency(BLAS REQUIRED) find_dependency(LAPACK REQUIRED) -# Find CUDA if available -find_package(CUDA QUIET) -if(CUDA_FOUND) - enable_language(CUDA) +# The GPU build links CUDA::cublas / CUDA::cusolver, which consumers need +# to resolve from the exported SlaterGPU target +if(@USE_ACC@) + find_dependency(CUDAToolkit REQUIRED) endif() # Include the targets file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 82b0f85..807b72d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,24 +12,16 @@ set(TEST_COMP_FLAGS ${CMAKE_CXX_FLAGS}) # CUDA/GPU dependencies - only when USE_ACC is enabled if(USE_ACC) - enable_language(CUDA) - find_package(CUDA REQUIRED) - find_library(CUDART_LIBRARY cudart ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) - - target_link_options(sgpu.exe PRIVATE + target_link_options(sgpu.exe PRIVATE -acc=gpu ) - set(TEST_COMP_FLAGS ${TEST_COMP_FLAGS} + set(TEST_COMP_FLAGS ${TEST_COMP_FLAGS} -DUSE_ACC=1 -acc=gpu ) - - # GPU-specific link libraries - set(GPU_LIBRARIES - "${CUDART_LIBRARY}" - "${CUDA_LIBRARIES}" - "${CUDA_TOOLKIT_ROOT_DIR}/../../math_libs/lib64/libcublas.so" - "${CUDA_TOOLKIT_ROOT_DIR}/../../math_libs/lib64/libcusolver.so" - ) + + # GPU-specific link libraries; cuBLAS/cuSolver come transitively from + # the SlaterGPU target (CUDA::cublas / CUDA::cusolver) + set(GPU_LIBRARIES CUDA::cudart) else() # CPU-only mode set(GPU_LIBRARIES "") diff --git a/src/integrals/CMakeLists.txt b/src/integrals/CMakeLists.txt index 7569011..ee1bd3d 100644 --- a/src/integrals/CMakeLists.txt +++ b/src/integrals/CMakeLists.txt @@ -60,6 +60,9 @@ if(USE_ACC) target_compile_options(SlaterGPU PRIVATE ${SLATER_COMP_FLAGS} -DUSE_ACC=1 -acc=gpu ) + # PUBLIC: cuda_util.h includes cublas_v2.h/cusolverDn.h when USE_ACC, + # so dependents (io, sgpu.exe, consumers) need the headers and libraries too + target_link_libraries(SlaterGPU PUBLIC CUDA::cublas CUDA::cusolver) else() target_compile_options(SlaterGPU PRIVATE ${SLATER_COMP_FLAGS} -DUSE_ACC=0 From 76082e66d27aa33aa20d89778e4f8fb303d4e649 Mon Sep 17 00:00:00 2001 From: Joshua Kammeraad Date: Fri, 14 Aug 2026 16:32:46 -0400 Subject: [PATCH 2/2] Update version constraint for pixi-build-cmake Pixi 0.76.2 refused to build with the previous backend pin. Vaibhav just tested a build with 0.4.5 and it works on athena --- pixi.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pixi.toml b/pixi.toml index a954a6f..ba755f9 100644 --- a/pixi.toml +++ b/pixi.toml @@ -10,7 +10,7 @@ version = "0.1.14" [package.build.backend] name = "pixi-build-cmake" -version = ">=0.3.6,<=0.4.2" +version = ">=0.3.6,<=0.4.5" [package.build.config] compilers = []