|
@@ -17,35 +17,55 @@
|
|
|
# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA
|
|
# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA
|
|
|
#
|
|
#
|
|
|
|
|
|
|
|
|
|
+if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language
|
|
|
|
|
+ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
|
|
|
|
+ set(CUDA_VERSION "${CMAKE_CUDA_COMPILER_VERSION}")
|
|
|
|
|
+ endif()
|
|
|
|
|
+endif()
|
|
|
|
|
+
|
|
|
|
|
+# See: https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-feature-list
|
|
|
|
|
+
|
|
|
# This list will be used for CUDA_ARCH_NAME = All option
|
|
# This list will be used for CUDA_ARCH_NAME = All option
|
|
|
set(CUDA_KNOWN_GPU_ARCHITECTURES "Fermi" "Kepler" "Maxwell")
|
|
set(CUDA_KNOWN_GPU_ARCHITECTURES "Fermi" "Kepler" "Maxwell")
|
|
|
|
|
|
|
|
# This list will be used for CUDA_ARCH_NAME = Common option (enabled by default)
|
|
# This list will be used for CUDA_ARCH_NAME = Common option (enabled by default)
|
|
|
set(CUDA_COMMON_GPU_ARCHITECTURES "3.0" "3.5" "5.0")
|
|
set(CUDA_COMMON_GPU_ARCHITECTURES "3.0" "3.5" "5.0")
|
|
|
|
|
|
|
|
-if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language
|
|
|
|
|
- if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
|
|
|
|
|
- set(CUDA_VERSION "${CMAKE_CUDA_COMPILER_VERSION}")
|
|
|
|
|
- endif()
|
|
|
|
|
|
|
+if(CUDA_VERSION VERSION_LESS "7.0")
|
|
|
|
|
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "5.2")
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
-if (CUDA_VERSION VERSION_GREATER "6.5")
|
|
|
|
|
|
|
+# This list is used to filter CUDA archs when autodetecting
|
|
|
|
|
+set(CUDA_ALL_GPU_ARCHITECTURES "3.0" "3.2" "3.5" "5.0")
|
|
|
|
|
+
|
|
|
|
|
+if(CUDA_VERSION VERSION_GREATER_EQUAL "7.0")
|
|
|
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Kepler+Tegra" "Kepler+Tesla" "Maxwell+Tegra")
|
|
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Kepler+Tegra" "Kepler+Tesla" "Maxwell+Tegra")
|
|
|
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2")
|
|
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2")
|
|
|
-endif ()
|
|
|
|
|
|
|
|
|
|
-if (CUDA_VERSION VERSION_GREATER "7.5")
|
|
|
|
|
|
|
+ if(CUDA_VERSION VERSION_LESS "8.0")
|
|
|
|
|
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2+PTX")
|
|
|
|
|
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "6.0")
|
|
|
|
|
+ endif()
|
|
|
|
|
+endif()
|
|
|
|
|
+
|
|
|
|
|
+if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0")
|
|
|
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Pascal")
|
|
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Pascal")
|
|
|
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.0" "6.1")
|
|
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.0" "6.1")
|
|
|
-else()
|
|
|
|
|
- list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2+PTX")
|
|
|
|
|
|
|
+ list(APPEND CUDA_ALL_GPU_ARCHITECTURES "6.0" "6.1" "6.2")
|
|
|
|
|
+
|
|
|
|
|
+ if(CUDA_VERSION VERSION_LESS "9.0")
|
|
|
|
|
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.1+PTX")
|
|
|
|
|
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "7.0")
|
|
|
|
|
+ endif()
|
|
|
endif ()
|
|
endif ()
|
|
|
|
|
|
|
|
-if (CUDA_VERSION VERSION_GREATER "8.5")
|
|
|
|
|
|
|
+if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0")
|
|
|
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Volta")
|
|
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Volta")
|
|
|
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.0" "7.0+PTX")
|
|
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.0" "7.0+PTX")
|
|
|
-else()
|
|
|
|
|
- list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.1+PTX")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(CUDA_VERSION VERSION_LESS "10.0")
|
|
|
|
|
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "8.0")
|
|
|
|
|
+ endif()
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
################################################################################################
|
|
################################################################################################
|
|
@@ -99,7 +119,19 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE)
|
|
|
message(STATUS "Automatic GPU detection failed. Building for common architectures.")
|
|
message(STATUS "Automatic GPU detection failed. Building for common architectures.")
|
|
|
set(${OUT_VARIABLE} ${CUDA_COMMON_GPU_ARCHITECTURES} PARENT_SCOPE)
|
|
set(${OUT_VARIABLE} ${CUDA_COMMON_GPU_ARCHITECTURES} PARENT_SCOPE)
|
|
|
else()
|
|
else()
|
|
|
- set(${OUT_VARIABLE} ${CUDA_GPU_DETECT_OUTPUT} PARENT_SCOPE)
|
|
|
|
|
|
|
+ # Filter based on CUDA version supported archs
|
|
|
|
|
+ set(CUDA_GPU_DETECT_OUTPUT_FILTERED "")
|
|
|
|
|
+ separate_arguments(CUDA_GPU_DETECT_OUTPUT)
|
|
|
|
|
+ foreach(ITEM IN ITEMS ${CUDA_GPU_DETECT_OUTPUT})
|
|
|
|
|
+ if(CUDA_LIMIT_GPU_ARCHITECTURE AND ITEM VERSION_GREATER_EQUAL CUDA_LIMIT_GPU_ARCHITECTURE)
|
|
|
|
|
+ list(GET CUDA_COMMON_GPU_ARCHITECTURES -1 NEWITEM)
|
|
|
|
|
+ string(APPEND CUDA_GPU_DETECT_OUTPUT_FILTERED " ${NEWITEM}")
|
|
|
|
|
+ else()
|
|
|
|
|
+ string(APPEND CUDA_GPU_DETECT_OUTPUT_FILTERED " ${ITEM}")
|
|
|
|
|
+ endif()
|
|
|
|
|
+ endforeach()
|
|
|
|
|
+
|
|
|
|
|
+ set(${OUT_VARIABLE} ${CUDA_GPU_DETECT_OUTPUT_FILTERED} PARENT_SCOPE)
|
|
|
endif()
|
|
endif()
|
|
|
endfunction()
|
|
endfunction()
|
|
|
|
|
|