13 #include <helper_cuda.h>
20 T
DtCheck(T result,
char const *
const func,
const char *
const file,
int const line,
DtDe* theDe)
26 theDe->DT_LOG_WARN <<
"CUDA error at " << file <<
":" << line <<
27 "code=" <<
static_cast<unsigned int>(result) <<
"(" << _cudaGetErrorEnum(result) <<
28 ") \"" << func <<
"\"" << std::endl;
44 #define DtCheckCudaErrors(val, theDe) DtCheck((val), #val, __FILE__, __LINE__, theDe)
49 int current_device = 0, sm_per_multiproc = 0;
50 int max_perf_device = 0;
51 int device_count = 0, best_SM_arch = 0;
52 int devices_prohibited = 0;
54 uint64_t max_compute_perf = 0;
55 cudaDeviceProp deviceProp;
58 if (device_count == 0)
62 theDe->DT_LOG_WARN <<
"gpuGetMaxGflopsDeviceId() CUDA error:" <<
63 " no devices supporting CUDA. Try updating your NVidia driver to a more recent one that support the CUDA version of this application." << std::endl;
69 while (current_device < device_count)
71 cudaGetDeviceProperties(&deviceProp, current_device);
75 if (deviceProp.computeMode != cudaComputeModeProhibited)
77 if (deviceProp.major > 0 && deviceProp.major < 9999)
79 best_SM_arch =
MAX(best_SM_arch, deviceProp.major);
90 if (devices_prohibited == device_count)
94 theDe->DT_LOG_WARN <<
"gpuGetMaxGflopsDeviceId() CUDA error:" <<
95 " all devices have compute mode prohibited." << std::endl;
103 while (current_device < device_count)
105 cudaGetDeviceProperties(&deviceProp, current_device);
109 if (deviceProp.computeMode != cudaComputeModeProhibited)
111 if (deviceProp.major == 9999 && deviceProp.minor == 9999)
113 sm_per_multiproc = 1;
118 _ConvertSMVer2Cores(deviceProp.major, deviceProp.minor);
121 uint64_t compute_perf = (uint64_t)deviceProp.multiProcessorCount *
122 sm_per_multiproc * deviceProp.clockRate;
124 if (compute_perf > max_compute_perf)
127 if (best_SM_arch > 2)
130 if (deviceProp.major == best_SM_arch)
132 max_compute_perf = compute_perf;
133 max_perf_device = current_device;
138 max_compute_perf = compute_perf;
139 max_perf_device = current_device;
147 return max_perf_device;
#define DtCheckCudaErrors(val, theDe)
This is exactly the same function as checkCudaErrors() from helper_cuda.h (From NVidia CUDA) except i...
Definition: DtHelperCuda.h:44
int DtGpuGetMaxGflopsDeviceId(DtDe *theDe)
This function returns the best GPU (with maximum GFLOPS)
Definition: DtHelperCuda.h:47
T DtCheck(T result, char const *const func, const char *const file, int const line, DtDe *theDe)
This is exactly the same function as check() from helper_cuda.h (From NVidia CUDA) except it does not...
Definition: DtHelperCuda.h:20
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
#define MAX(x, y)
{secret}
Definition: trpage_io.h:40