提交 8be259fe 编写于 作者: M Matt Pharr

Improve GPU SM version checking.

Require SM 5.3 and up (half floats...)
Print a more useful error when the GPU's shader model is insufficient.
上级 757a5ab8
......@@ -159,16 +159,16 @@ if (CMAKE_CUDA_COMPILER)
# https://wagonhelm.github.io/articles/2018-03/detecting-cuda-capability-with-cmake
# Get CUDA compute capability
set (OUTPUTFILE ${CMAKE_BINARY_DIR}/checkcuda)
set (CHECK_CUDA_OUTPUT_EXE ${CMAKE_BINARY_DIR}/checkcuda)
if (MSVC)
execute_process (COMMAND nvcc -lcuda ${CMAKE_SOURCE_DIR}/cmake/checkcuda.cu -ccbin ${CMAKE_CXX_COMPILER} -o ${OUTPUTFILE})
execute_process (COMMAND nvcc -lcuda ${CMAKE_SOURCE_DIR}/cmake/checkcuda.cu -ccbin ${CMAKE_CXX_COMPILER} -o ${CHECK_CUDA_OUTPUT_EXE})
else ()
execute_process (COMMAND nvcc -lcuda ${CMAKE_SOURCE_DIR}/cmake/checkcuda.cu -o ${OUTPUTFILE})
execute_process (COMMAND nvcc -lcuda ${CMAKE_SOURCE_DIR}/cmake/checkcuda.cu -o ${CHECK_CUDA_OUTPUT_EXE})
endif ()
execute_process (COMMAND ${OUTPUTFILE}
execute_process (COMMAND ${CHECK_CUDA_OUTPUT_EXE}
RESULT_VARIABLE CUDA_RETURN_CODE
OUTPUT_VARIABLE ARCH)
OUTPUT_VARIABLE CHECK_CUDA_OUTPUT)
set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --std=c++17")
if (CMAKE_BUILD_TYPE MATCHES Debug)
......@@ -178,8 +178,9 @@ if (CMAKE_CUDA_COMPILER)
endif ()
if (NOT ${CUDA_RETURN_CODE} EQUAL 0)
message (SEND_ERROR "Unable to determine GPU's compute capability")
else ()
message (SEND_ERROR ${CHECK_CUDA_OUTPUT})
else ()
set(ARCH "${CHECK_CUDA_OUTPUT}")
message (STATUS "CUDA Architecture: ${ARCH}")
set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --gpu-architecture=${ARCH}")
endif ()
......
......@@ -5,16 +5,16 @@
int main(int argc, char **argv){
cudaDeviceProp dP;
float min_cc = 5.0; // TODO: figure out what this should be.
float min_cc = 5.3; // We need half floats...
int rc = cudaGetDeviceProperties(&dP, 0);
if(rc != cudaSuccess) {
cudaError_t error = cudaGetLastError();
printf("CUDA error: %s", cudaGetErrorString(error));
printf("CUDA error: %s\n", cudaGetErrorString(error));
return rc; /* Failure */
}
if((dP.major+(dP.minor/10)) < min_cc) {
printf("Min Compute Capability of %2.1f required: %d.%d found\n Not Building CUDA Code",
printf("Minimum Compute Capability of %2.1f required: %d.%d found. Not Building CUDA Code.\n",
min_cc, dP.major, dP.minor);
return 1; /* Failure */
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册