提交 28f605c8 编写于 作者: G gineshidalgo99

Display error message if wrong GPU device id

上级 252e7f09
......@@ -98,12 +98,6 @@ if (WIN32)
endif (${INSTRUCTION_SET} MATCHES "SSE")
endif (WIN32)
# Look for CUDA
find_package(CUDA)
# Look for OpenCL
set(OpenCL_FOUND FALSE)
find_package(OpenCL)
# Set the acceleration library
set(GPU_MODE CUDA CACHE STRING "Select the acceleration GPU library or CPU otherwise.")
# Display proper options to user
......@@ -118,6 +112,16 @@ set(GPU_MODE CUDA CACHE STRING "Select the acceleration GPU library or CPU other
# endif ()
set_property(CACHE GPU_MODE PROPERTY STRINGS CUDA)
# Look for CUDA
if (${GPU_MODE} MATCHES "CUDA")
find_package(CUDA)
endif (${GPU_MODE} MATCHES "CUDA")
# Look for OpenCL
set(OpenCL_FOUND FALSE)
if (${GPU_MODE} MATCHES "OPENCL")
find_package(OpenCL)
endif (${GPU_MODE} MATCHES "OPENCL")
# Code to avoid crash at compiling time if OpenCL is not found
if (NOT OpenCL_FOUND)
set(OpenCL_LIBRARIES "")
......
......@@ -469,14 +469,14 @@ namespace op
// GPU --> user picks (<= #GPUs)
else
{
// Get total number GPUs
const auto totalGpuNumber = getGpuNumber();
// If number GPU < 0 --> set it to all the available GPUs
if (numberThreads < 0)
{
// Get total number GPUs
const auto totalGpuNumber = getGpuNumber();
if (totalGpuNumber <= gpuNumberStart)
error("Number of initial GPUs (`--number_gpu_start`) must be lower than the total number of used"
" GPUs (`--number_gpu`)", __LINE__, __FUNCTION__, __FILE__);
error("Number of initial GPU (`--number_gpu_start`) must be lower than the total number of"
" used GPUs (`--number_gpu`)", __LINE__, __FUNCTION__, __FILE__);
numberThreads = totalGpuNumber - gpuNumberStart;
// Reset initial GPU to 0 (we want them all)
// Logging message
......@@ -484,6 +484,14 @@ namespace op
+ " GPU(s), using " + std::to_string(numberThreads) + " of them starting at GPU "
+ std::to_string(gpuNumberStart) + ".", Priority::High);
}
// Security check
if (gpuNumberStart + numberThreads > totalGpuNumber)
error("Initial GPU selected (`--number_gpu_start`) + number GPUs to use (`--number_gpu`) must"
" be lower or equal than the total number of GPUs in your machine ("
+ std::to_string(gpuNumberStart) + " + "
+ std::to_string(numberThreads) + " vs. "
+ std::to_string(totalGpuNumber) + ").",
__LINE__, __FUNCTION__, __FILE__);
}
// Proper format
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册