Skip to content

Commit 80e6f59

Browse files
committed
parse CMake's CMAKE_CUDA_ARCHITECTURES into NVHPC's -gpu= format
1 parent d481234 commit 80e6f59

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

.github/workflows/ci.gpu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
include:
2323
- { name: "clang 19", cuda: "12.0", cxx: "clang++", build: "Release", tag: "llvm19-cuda12.0", gpu: "v100", sm: "70", driver: "latest", arch: "amd64" }
2424
- { name: "clang 19", cuda: "12.9", cxx: "clang++", build: "Release", tag: "llvm19-cuda12.9", gpu: "v100", sm: "70", driver: "latest", arch: "amd64" }
25-
- { name: "nvc++ 24.9", cuda: "12.9", cxx: "mpic++", build: "Release", tag: "nvhpc25.5", gpu: "v100", sm: "70", driver: "latest", arch: "amd64" }
26-
- { name: "nvc++ 24.9", cuda: "12.9", cxx: "mpic++", build: "Debug", tag: "nvhpc25.5", gpu: "v100", sm: "70", driver: "latest", arch: "amd64" }
25+
- { name: "nvc++ 25.5", cuda: "12.9", cxx: "mpic++", build: "Release", tag: "nvhpc25.5", gpu: "v100", sm: "70", driver: "latest", arch: "amd64" }
26+
- { name: "nvc++ 25.5", cuda: "12.9", cxx: "mpic++", build: "Debug", tag: "nvhpc25.5", gpu: "v100", sm: "70", driver: "latest", arch: "amd64" }
2727
runs-on: linux-${{ matrix.arch }}-gpu-${{ matrix.gpu }}-${{ matrix.driver }}-1
2828
container:
2929
options: -u root

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,25 @@ if(STDEXEC_ENABLE_CUDA)
312312
target_compile_features(nvexec INTERFACE cuda_std_20)
313313
target_link_libraries(nvexec INTERFACE STDEXEC::stdexec)
314314

315+
set(_gpus)
316+
foreach(_arch IN LISTS CMAKE_CUDA_ARCHITECTURES)
317+
if(_arch MATCHES "-real")
318+
string(REPLACE "-real" "" _arch "${_arch}")
319+
string(PREPEND _arch "cc")
320+
elseif(_arch MATCHES "-virtual")
321+
string(REPLACE "-virtual" "" _arch "${_arch}")
322+
string(PREPEND _arch "cc")
323+
elseif(_arch MATCHES "^[0-9]+$")
324+
string(PREPEND _arch "cc")
325+
endif()
326+
list(APPEND _gpus "${_arch}")
327+
endforeach()
328+
list(JOIN _gpus "," _gpus)
329+
315330
target_compile_options(nvexec INTERFACE
316-
$<$<AND:$<CXX_COMPILER_ID:NVHPC>,$<COMPILE_LANGUAGE:CXX>>:-stdpar -gpu=cc${CMAKE_CUDA_ARCHITECTURES}>)
331+
$<$<AND:$<CXX_COMPILER_ID:NVHPC>,$<COMPILE_LANGUAGE:CXX>>:-stdpar -gpu=${_gpus}>)
317332
target_link_options(nvexec INTERFACE
318-
$<$<AND:$<CXX_COMPILER_ID:NVHPC>,$<COMPILE_LANGUAGE:CXX>>:-stdpar -gpu=cc${CMAKE_CUDA_ARCHITECTURES}>)
333+
$<$<AND:$<CXX_COMPILER_ID:NVHPC>,$<COMPILE_LANGUAGE:CXX>>:-stdpar -gpu=${_gpus}>)
319334

320335
install(TARGETS nvexec
321336
EXPORT stdexec-exports

0 commit comments

Comments
 (0)