diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake --- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake @@ -118,9 +118,7 @@ find_package(CUDA QUIET) # Try to get the highest Nvidia GPU architecture the system supports -set(LIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY TRUE CACHE BOOL - "Auto detect CUDA Compute Capability if CUDA is detected.") -if (CUDA_FOUND AND LIBOMPTARGET_NVPTX_AUTODETECT_COMPUTE_CAPABILITY) +if (CUDA_FOUND) cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS) string(REGEX MATCH "sm_([0-9]+)" CUDA_ARCH_MATCH_OUTPUT ${CUDA_ARCH_FLAGS}) if (NOT DEFINED CUDA_ARCH_MATCH_OUTPUT OR "${CMAKE_MATCH_1}" LESS 35) diff --git a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt --- a/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt +++ b/openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt @@ -10,12 +10,12 @@ # ##===----------------------------------------------------------------------===## -# By default we will not build NVPTX deviceRTL on a non-CUDA +# By default we will not build NVPTX deviceRTL on a CUDA free system set(LIBOMPTARGET_BUILD_NVPTX_BCLIB FALSE CACHE BOOL - "Whether build NVPTX deviceRTL on non-CUDA system.") + "Whether build NVPTX deviceRTL on CUDA free system.") if (NOT (LIBOMPTARGET_DEP_CUDA_FOUND OR LIBOMPTARGET_BUILD_NVPTX_BCLIB)) - libomptarget_say("Not building NVPTX deviceRTL by default on non-CUDA system.") + libomptarget_say("Not building NVPTX deviceRTL by default on CUDA free system.") return() endif() @@ -73,16 +73,22 @@ set(devicertl_nvptx_directory ${devicertl_base_directory}/nvptx) -if (DEFINED LIBOMPTARGET_DEP_CUDA_ARCH) - set(default_capabilities ${LIBOMPTARGET_DEP_CUDA_ARCH}) -else() - set(default_capabilities 35 37 50 52 53 60 61 62 70 72 75 80) -endif() +set(all_capabilities 35 37 50 52 53 60 61 62 70 72 75 80) -set(LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES ${default_capabilities} CACHE STRING +set(LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES ${all_capabilities} CACHE STRING "List of CUDA Compute Capabilities to be used to compile the NVPTX device RTL.") +string(TOLOWER ${LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES} LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES) -set(nvptx_sm_list ${LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES}) +if (LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES STREQUAL "all") + set(nvptx_sm_list ${all_capabilities}) +elseif(LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES STREQUAL "auto") + if (NOT LIBOMPTARGET_DEP_CUDA_FOUND) + message(FATAL_ERROR "LIBOMPTARGET: [NVPTX] Cannot auto detect compute capability as CUDA not found.") + endif() + set(nvptx_sm_list ${LIBOMPTARGET_DEP_CUDA_ARCH}) +else() + string(REPLACE "," ";" nvptx_sm_list "${LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES}") +endif() # If user set LIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES to empty, we disable the # build. @@ -93,8 +99,8 @@ # Check all SM values foreach(sm ${nvptx_sm_list}) - if (NOT ${sm} IN_LIST default_capabilities) - message(FATAL_ERROR "LIBOMPTARGET-NVPTX: compute capability ${sm} is not supported. Supported values: ${default_capabilities}") + if (NOT ${sm} IN_LIST all_capabilities) + message(FATAL_ERROR "LIBOMPTARGET: [NVPTX] compute capability ${sm} is not supported. Supported values: ${all_capabilities}") endif() endforeach()