Skip to content

Commit

Permalink
Make NVHPC support CMAKE_CUDA_ARCHITECTURES as a list.
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo committed Sep 30, 2021
1 parent be7893e commit a9e69a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions CMake/ClangCompilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ if(QMC_OMP)

if(NOT DEFINED OFFLOAD_ARCH AND OFFLOAD_TARGET MATCHES "nvptx64" AND DEFINED CMAKE_CUDA_ARCHITECTURES)
list(LENGTH CMAKE_CUDA_ARCHITECTURES NUMBER_CUDA_ARCHITECTURES)
if(NOT NUMBER_CUDA_ARCHITECTURES EQUAL "1")
message(FATAL_ERROR "LLVM does not support offload to multiple architectures!")
if(NUMBER_CUDA_ARCHITECTURES EQUAL "1")
set(OFFLOAD_ARCH sm_${CMAKE_CUDA_ARCHITECTURES})
else()
message(FATAL_ERROR "LLVM does not yet support offload to multiple architectures! "
"Deriving OFFLOAD_ARCH from CMAKE_CUDA_ARCHITECTURES failed. "
"Please keep only one entry in CMAKE_CUDA_ARCHITECTURES or set OFFLOAD_ARCH")
endif()
set(OFFLOAD_ARCH sm_${CMAKE_CUDA_ARCHITECTURES})
endif()

if(DEFINED OFFLOAD_ARCH)
Expand Down
8 changes: 7 additions & 1 deletion CMake/NVHPCCompilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ if(QMC_OMP)
message(WARNING "QMCPACK OpenMP offload is not ready for NVIDIA HPC compiler.")
if(NOT DEFINED OFFLOAD_ARCH)
if(DEFINED CMAKE_CUDA_ARCHITECTURES)
set(OFFLOAD_ARCH cc${CMAKE_CUDA_ARCHITECTURES})
list(LENGTH CMAKE_CUDA_ARCHITECTURES NUMBER_CUDA_ARCHITECTURES)
if(NUMBER_CUDA_ARCHITECTURES EQUAL "1")
set(OFFLOAD_ARCH cc${CMAKE_CUDA_ARCHITECTURES})
else()
string(REPLACE ";" ",cc" OFFLOAD_ARCH "${CMAKE_CUDA_ARCHITECTURES}")
set(OFFLOAD_ARCH "cc${OFFLOAD_ARCH}")
endif()
else()
message(FATAL_ERROR "NVIDIA HPC compiler requires -gpu=ccXX option set based on the target GPU architecture! "
"Please add -DOFFLOAD_ARCH=ccXX to cmake. For example, cc70 is for Volta.")
Expand Down

0 comments on commit a9e69a1

Please sign in to comment.