-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
function(cuda_arch_probe) | ||
if(NOT "" STREQUAL "${CMAKE_CUDA_COMPILER}") | ||
set(_nvcc "${CMAKE_CUDA_COMPILER}") | ||
elseif(NOT "" STREQUAL "${CUDA_COMPILER}") | ||
set(_nvcc "${CUDA_COMPILER}") | ||
elseif(NOT "" STREQUAL "${DEVICE_COMPILER}") | ||
set(_nvcc "${DEVICE_COMPILER}") | ||
endif() | ||
execute_process( | ||
COMMAND ${_nvcc} --help | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE _nvcc_help | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
string(REGEX REPLACE ";" "\\\\;" _nvcc_help "${_nvcc_help}") | ||
string(REGEX REPLACE "\n" ";" _nvcc_help "${_nvcc_help}") | ||
set(_archlist "") | ||
foreach(_line ${_nvcc_help}) | ||
string(REGEX MATCHALL "(sm|compute)_[0-9]+" _has_arch ${_line}) | ||
string(REGEX REPLACE "(sm|compute)_" "" _has_arch "${_has_arch}") | ||
if(_has_arch) | ||
string(REGEX REPLACE "\\;" ";" _has_arch "${_has_arch}") | ||
list(APPEND _archlist ${_has_arch}) | ||
endif() | ||
endforeach() | ||
list(SORT _archlist) | ||
list(REMOVE_DUPLICATES _archlist) | ||
if(APPLE) | ||
if("9.0" VERSION_EQUAL CUDA_VERSION) | ||
list(FIND _archlist "70" _hasVolta) | ||
if(NOT -1 EQUAL _hasVolta) | ||
message(WARNING "Removing \"70\" from valid CUDA architectures (OSX+CUDA9.0 detected)") | ||
list(REMOVE_ITEM VALID_CUDA_ARCHS "70") | ||
endif() | ||
endif() | ||
endif() | ||
set(CMAKE_CUDA_ARCHLIST ${_archlist} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(cuda_arch_filter _WHAT _VALID _OUT) | ||
#strip any chars except numbers and semicolons | sort | uniq | ||
string(REGEX REPLACE "[^;0-9]+" "" _WHAT "${_WHAT}") | ||
list(SORT _WHAT) | ||
list(REMOVE_DUPLICATES _WHAT) | ||
if(NOT "" STREQUAL "${_WHAT}") | ||
# validate architectures provided | ||
message(STATUS "Filtering provided compute architectures: ${_WHAT}") | ||
set(_archlist "") | ||
foreach(_arch ${_WHAT}) | ||
if(_arch MATCHES "^[0-9]$") | ||
#single digit, append a 0 | ||
set(_arch "${_arch}0") | ||
endif() | ||
list(FIND _VALID "${_arch}" _arch_good) | ||
if(NOT _arch MATCHES "^[0-9][0-9]$") | ||
# only numbers are allowed | ||
message(STATUS "...architecture '${_arch}' is not a number") | ||
elseif(${_arch} LESS 20) | ||
message(STATUS "...architecture '${_arch}' does not support required math functions. " | ||
"Miner kernels require compute architecture 2.0 or higher.") | ||
elseif(-1 EQUAL ${_arch_good}) | ||
message(STATUS "...architecture '${_arch}' is not supported by this nvcc") | ||
else() | ||
# nothing disqualified _arch above, keep it | ||
list(APPEND _archlist ${_arch}) | ||
endif() | ||
endforeach() | ||
message(STATUS "Filtered result: ${_archlist}") | ||
unset(_arch_good) | ||
unset(_arch) | ||
endif() | ||
set("${_OUT}" "${_archlist}" PARENT_SCOPE) | ||
endfunction() | ||
# vim: et sw=4 sts=4 ts=4: |
File renamed without changes.