1
1
set (MSG_CUDA_MAP "\n\n "
2
2
" Valid CUDA Toolkit Map:\n "
3
- " 8.x for Fermi/Kepler /Maxwell/Pascal,\n "
4
- " 9.x for Kepler /Maxwell/Pascal/Volta,\n "
5
- " 10.x for Kepler /Maxwell/Pascal/Volta/Turing,\n "
6
- " 11.x for Kepler (in part)/Maxwell/Pascal/Volta/Turing/Ampere\n\n "
3
+ " 8.x for Fermi/Kepler /Maxwell/Pascal,\n "
4
+ " 9.0 for Kepler /Maxwell/Pascal/Volta(70),\n "
5
+ " 9.1 for Kepler /Maxwell/Pascal/Volta(72),\n "
6
+ " 10.x for Kepler /Maxwell/Pascal/Volta /Turing,\n "
7
+ " 11.x for Kepler(35/37)/Maxwell/Pascal/Volta /Turing/Ampere(80)\n "
8
+ " 11.1 for Kepler(35/37)/Maxwell/Pascal/Volta /Turing/Ampere(86)\n "
9
+ " 11.4 for Kepler(35/37)/Maxwell/Pascal/Volta /Turing/Ampere(87)\n\n "
7
10
"Reference https://developer.nvidia.com/cuda-gpus#compute for arch and family name\n\n "
8
11
)
9
12
@@ -14,96 +17,110 @@ if (XMRIG_LARGEGRID)
14
17
add_definitions ("-DXMRIG_LARGEGRID=${XMRIG_LARGEGRID} " )
15
18
endif ()
16
19
17
- set (DEFAULT_CUDA_ARCH "50" )
18
-
19
- # Fermi GPUs are only supported with CUDA < 9.0
20
- if (CUDA_VERSION VERSION_LESS 9.0 )
21
- list (APPEND DEFAULT_CUDA_ARCH "20;21" )
22
- endif ()
23
-
24
- # Kepler GPUs are only supported with CUDA < 11.0
25
- if (CUDA_VERSION VERSION_LESS 11.0 )
26
- list (APPEND DEFAULT_CUDA_ARCH "30" )
27
- else ()
28
- list (APPEND DEFAULT_CUDA_ARCH "35" )
29
- endif ()
30
-
31
- # add Pascal support for CUDA >= 8.0
32
- if (NOT CUDA_VERSION VERSION_LESS 8.0 )
33
- list (APPEND DEFAULT_CUDA_ARCH "60" )
34
- endif ()
35
-
36
- # add Volta support for CUDA >= 9.0
37
- if (NOT CUDA_VERSION VERSION_LESS 9.0 )
38
- list (APPEND DEFAULT_CUDA_ARCH "70" )
39
- endif ()
40
-
41
- # add Turing support for CUDA >= 10.0
42
- if (NOT CUDA_VERSION VERSION_LESS 10.0 )
43
- list (APPEND DEFAULT_CUDA_ARCH "75" )
44
- endif ()
45
-
46
- # add Ampere support for CUDA >= 11.0
47
- if (NOT CUDA_VERSION VERSION_LESS 11.0 )
48
- list (APPEND DEFAULT_CUDA_ARCH "80" )
49
- endif ()
50
- list (SORT DEFAULT_CUDA_ARCH )
20
+ # Obtain actual list of supported arch from nvcc
21
+ execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} --help OUTPUT_VARIABLE NVCC_HELP OUTPUT_STRIP_TRAILING_WHITESPACE )
22
+ string (REPLACE "\n " ";" NVCC_HELP "${NVCC_HELP} " )
23
+ foreach (LINE ${NVCC_HELP} )
24
+ string (STRIP "${LINE} " LINE )
25
+ if (FOUND_VALUES )
26
+ string (FIND "${LINE} " "--" POS )
27
+ if (POS EQUAL 0 )
28
+ break ()
29
+ endif ()
30
+ string (APPEND SUPPORT_CUDA_ARCH "${LINE} " )
31
+ continue ()
32
+ endif ()
33
+ if (FOUND_OPT )
34
+ string (FIND "${LINE} " "Allowed values for this option:" POS )
35
+ if (POS EQUAL -1 )
36
+ continue ()
37
+ endif ()
38
+ math (EXPR chop "${POS} + 31" )
39
+ string (SUBSTRING "${LINE} " ${chop} -1 LINE )
40
+ string (STRIP "${LINE} " SUPPORT_CUDA_ARCH )
41
+ set (FOUND_VALUES TRUE )
42
+ continue ()
43
+ endif ()
44
+ string (FIND "${LINE} " "--gpu-architecture" POS )
45
+ if (POS EQUAL 0 )
46
+ set (FOUND_OPT TRUE )
47
+ endif ()
48
+ endforeach ()
49
+ unset (NVCC_HELP )
50
+ unset (FOUND_VALUES )
51
+ unset (FOUND_OPT )
52
+ unset (LINE )
53
+ string (REPLACE "compute_" "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
54
+ string (REPLACE "sm_" "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
55
+ string (REPLACE "lto_" "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
56
+ string (REPLACE "all-major" "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
57
+ string (REPLACE "all" "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
58
+ string (REPLACE "." "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
59
+ string (REPLACE "'" "" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
60
+ string (REPLACE "," ";" SUPPORT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
61
+ list (SORT SUPPORT_CUDA_ARCH )
62
+ list (REMOVE_DUPLICATES SUPPORT_CUDA_ARCH )
63
+ list (REMOVE_ITEM SUPPORT_CUDA_ARCH "" )
64
+ message (STATUS "CUDA Architectures supported by [${CUDA_NVCC_EXECUTABLE} ]: ${SUPPORT_CUDA_ARCH} " )
65
+ set (DEFAULT_CUDA_ARCH "${SUPPORT_CUDA_ARCH} " )
51
66
52
67
set (CUDA_ARCH "${DEFAULT_CUDA_ARCH} " CACHE STRING "Set GPU architecture (semicolon separated list, e.g. '-DCUDA_ARCH=20;35;60')" )
53
68
54
69
# validate architectures (only numbers are allowed)
55
70
foreach (CUDA_ARCH_ELEM ${CUDA_ARCH} )
56
- string (REGEX MATCH "^[0-9]+$" IS_NUMBER ${CUDA_ARCH } )
71
+ string (REGEX MATCH "^[0-9]+$" IS_NUMBER ${CUDA_ARCH_ELEM } )
57
72
if (NOT IS_NUMBER )
58
73
message (FATAL_ERROR "Defined compute architecture '${CUDA_ARCH_ELEM} ' in "
59
74
"'${CUDA_ARCH} ' is not an integral number, use e.g. '30' (for compute architecture 3.0)." )
60
75
endif ()
61
76
unset (IS_NUMBER )
62
77
63
- if (${CUDA_ARCH_ELEM} LESS 20 )
78
+ list (FIND SUPPORT_CUDA_ARCH "${CUDA_ARCH_ELEM} " POS )
79
+ if (POS EQUAL -1 )
64
80
message ("${MSG_CUDA_MAP} " )
65
- message (FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM} ' specified." )
66
- endif ()
67
-
68
- if (NOT CUDA_VERSION VERSION_LESS 11.0 )
69
- if (${CUDA_ARCH_ELEM} LESS 35 )
70
- message ("${MSG_CUDA_MAP} " )
71
- message (FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM} ' specified. "
72
- "Use CUDA v10.x maximum, Kepler (30) was dropped at v11." )
81
+ set (CUDA_UNSUP "Currently selected nvcc does not support CUDA architecture '${CUDA_ARCH_ELEM} '. Use CUDA Toolkit" )
82
+ if ("${CUDA_ARCH_ELEM} " LESS 30 )
83
+ message (FATAL_ERROR "${CUDA_UNSUP} v8.x maximum, Fermi (20/21) was dropped at v9.0" )
73
84
endif ()
74
- else ()
75
- if (NOT ${CUDA_ARCH_ELEM} LESS 80 )
76
- message ("${MSG_CUDA_MAP} " )
77
- message (FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM} ' specified. "
78
- "Use CUDA v11.x minimum, Ampere (80) was added at v11." )
85
+ if ("${CUDA_ARCH_ELEM} " GREATER_EQUAL 30 AND "${CUDA_ARCH_ELEM} " LESS 40 )
86
+ if ("${CUDA_ARCH_ELEM} " LESS_EQUAL 32 )
87
+ message (FATAL_ERROR "${CUDA_UNSUP} v10.x maximum, Kepler (30/32) was dropped at v11.0" )
88
+ else ()
89
+ message (FATAL_ERROR "${CUDA_UNSUP} v11.x maximum, Kepler (35/37) was dropped at v12.0" )
90
+ endif ()
79
91
endif ()
80
- endif ()
81
-
82
- if (CUDA_VERSION VERSION_LESS 10.0 )
83
- if (NOT ${CUDA_ARCH_ELEM} LESS 75 )
84
- message ("${MSG_CUDA_MAP} " )
85
- message (FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM} ' specified. "
86
- "Use CUDA v10.x minimum, Turing (75) was added at v10." )
92
+ if ("${CUDA_ARCH_ELEM} " GREATER_EQUAL 50 AND "${CUDA_ARCH_ELEM} " LESS 60 )
93
+ message (FATAL_ERROR "${CUDA_UNSUP} v11.x maximum, Maxwell (50/52/53) was dropped at v12.0" )
87
94
endif ()
88
- endif ()
89
-
90
- if (NOT CUDA_VERSION VERSION_LESS 9.0 )
91
- if (${CUDA_ARCH_ELEM} LESS 30 )
92
- message ("${MSG_CUDA_MAP} " )
93
- message (FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM} ' specified. "
94
- "Use CUDA v8.x maximum, Fermi (20/21) was dropped at v9." )
95
+ if ("${CUDA_ARCH_ELEM} " GREATER_EQUAL 70 AND "${CUDA_ARCH_ELEM} " LESS 80 )
96
+ if ("${CUDA_ARCH_ELEM} " LESS 72 )
97
+ message (FATAL_ERROR "${CUDA_UNSUP} v9.0 minimum, Volta (70) was added at v9.0" )
98
+ elseif ("${CUDA_ARCH_ELEM} " LESS 75 )
99
+ message (FATAL_ERROR "${CUDA_UNSUP} v9.1 minimum, Volta (72) was added at v9.1" )
100
+ else ()
101
+ message (FATAL_ERROR "${CUDA_UNSUP} v10.0 minimum, Turing (75) was added at v10.0" )
102
+ endif ()
95
103
endif ()
96
- else ()
97
- if (NOT ${CUDA_ARCH_ELEM} LESS 70 )
98
- message ("${MSG_CUDA_MAP} " )
99
- message (FATAL_ERROR "Unsupported CUDA architecture '${CUDA_ARCH_ELEM} ' specified. "
100
- "Use CUDA v9.x minimum, Volta (70/72) was added at v9." )
104
+ if ("${CUDA_ARCH_ELEM} " GREATER_EQUAL 80 AND "${CUDA_ARCH_ELEM} " LESS 90 )
105
+ if ("${CUDA_ARCH_ELEM} " LESS 86 )
106
+ message (FATAL_ERROR "${CUDA_UNSUP} v11.0 minimum, Ampere (80) was added at v11.0" )
107
+ elseif ("${CUDA_ARCH_ELEM} " EQUAL 86 )
108
+ message (FATAL_ERROR "${CUDA_UNSUP} v11.1 minimum, Ampere (86) was added at v11.1" )
109
+ else ()
110
+ message (FATAL_ERROR "${CUDA_UNSUP} v11.4 minimum, Ampere (87) was added at v11.4" )
111
+ endif ()
101
112
endif ()
102
113
endif ()
103
114
endforeach ()
104
115
116
+ unset (POS )
117
+ unset (CUDA_ARCH_ELEM )
118
+ unset (SUPPORT_CUDA_ARCH )
105
119
unset (MSG_CUDA_MAP )
106
120
list (SORT CUDA_ARCH )
121
+ list (REMOVE_DUPLICATES CUDA_ARCH )
122
+ list (REMOVE_ITEM CUDA_ARCH "" )
123
+ message (STATUS "CUDA Architectures being built: ${CUDA_ARCH} " )
107
124
108
125
add_definitions (-DCUB_IGNORE_DEPRECATED_CPP_DIALECT -DTHRUST_IGNORE_DEPRECATED_CPP_DIALECT )
109
126
0 commit comments