13 #include <helper_cuda.h>
19 void DtCheck(T result,
char const *
const func,
const char *
const file,
int const line,
DtDe* theDe)
25 theDe->DT_LOG_WARN <<
"CUDA error at " << file <<
":" << line <<
26 "code=" <<
static_cast<unsigned int>(result) <<
"(" << _cudaGetErrorEnum(result) <<
27 ") \"" << func <<
"\"" << std::endl;
41 #define DtCheckCudaErrors(val, theDe) DtCheck((val), #val, __FILE__, __LINE__, theDe)
46 int current_device = 0, sm_per_multiproc = 0;
47 int max_perf_device = 0;
48 int device_count = 0, best_SM_arch = 0;
49 int devices_prohibited = 0;
51 uint64_t max_compute_perf = 0;
52 cudaDeviceProp deviceProp;
55 if (device_count == 0)
59 theDe->DT_LOG_WARN <<
"gpuGetMaxGflopsDeviceId() CUDA error:" <<
60 " no devices supporting CUDA. Try updating your NVidia driver to a more recent one that support the CUDA version of this application." << std::endl;
66 while (current_device < device_count)
68 cudaGetDeviceProperties(&deviceProp, current_device);
72 if (deviceProp.computeMode != cudaComputeModeProhibited)
74 if (deviceProp.major > 0 && deviceProp.major < 9999)
76 best_SM_arch =
MAX(best_SM_arch, deviceProp.major);
87 if (devices_prohibited == device_count)
91 theDe->DT_LOG_WARN <<
"gpuGetMaxGflopsDeviceId() CUDA error:" <<
92 " all devices have compute mode prohibited." << std::endl;
100 while (current_device < device_count)
102 cudaGetDeviceProperties(&deviceProp, current_device);
106 if (deviceProp.computeMode != cudaComputeModeProhibited)
108 if (deviceProp.major == 9999 && deviceProp.minor == 9999)
110 sm_per_multiproc = 1;
115 _ConvertSMVer2Cores(deviceProp.major, deviceProp.minor);
118 uint64_t compute_perf = (uint64_t)deviceProp.multiProcessorCount *
119 sm_per_multiproc * deviceProp.clockRate;
121 if (compute_perf > max_compute_perf)
124 if (best_SM_arch > 2)
127 if (deviceProp.major == best_SM_arch)
129 max_compute_perf = compute_perf;
130 max_perf_device = current_device;
135 max_compute_perf = compute_perf;
136 max_perf_device = current_device;
144 return max_perf_device;
void 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) ...
Definition: DtHelperCuda.h:19
#define DtCheckCudaErrors(val, theDe)
This is exactly the same function as checkCudaErrors() from helper_cuda.h (From NVidia CUDA) This wil...
Definition: DtHelperCuda.h:41
int DtGpuGetMaxGflopsDeviceId(DtDe *theDe)
This function returns the best GPU (with maximum GFLOPS)
Definition: DtHelperCuda.h:44
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