13 #include <helper_cuda.h>
22 T
DtCheckCuda(T result,
char const *
const func,
const char *
const file,
int const line,
DtDe& de)
26 de.DT_LOG_WARN <<
"CUDA error at " << file <<
":" << line <<
27 "code=" <<
static_cast<unsigned int>(result) <<
"(" << _cudaGetErrorEnum(result) <<
28 ") \"" << func <<
"\"" << std::endl;
43 #define DtCheckCudaErrors(val, de) DtCheckCuda((val), #val, __FILE__, __LINE__, de)
48 int current_device = 0, sm_per_multiproc = 0;
49 int max_perf_device = 0;
50 int device_count = 0, best_SM_arch = 0;
51 int devices_prohibited = 0;
53 uint64_t max_compute_perf = 0;
54 cudaDeviceProp deviceProp;
57 if (device_count == 0)
59 de.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;
65 while (current_device < device_count)
67 cudaGetDeviceProperties(&deviceProp, current_device);
71 if (deviceProp.computeMode != cudaComputeModeProhibited)
73 if (deviceProp.major > 0 && deviceProp.major < 9999)
75 best_SM_arch =
MAX(best_SM_arch, deviceProp.major);
86 if (devices_prohibited == device_count)
88 de.DT_LOG_WARN <<
"gpuGetMaxGflopsDeviceId() CUDA error:" <<
89 " all devices have compute mode prohibited." << std::endl;
96 while (current_device < device_count)
98 cudaGetDeviceProperties(&deviceProp, current_device);
102 if (deviceProp.computeMode != cudaComputeModeProhibited)
104 if (deviceProp.major == 9999 && deviceProp.minor == 9999)
106 sm_per_multiproc = 1;
111 _ConvertSMVer2Cores(deviceProp.major, deviceProp.minor);
114 uint64_t compute_perf = (uint64_t)deviceProp.multiProcessorCount *
115 sm_per_multiproc * deviceProp.clockRate;
117 if (compute_perf > max_compute_perf)
120 if (best_SM_arch > 2)
123 if (deviceProp.major == best_SM_arch)
125 max_compute_perf = compute_perf;
126 max_perf_device = current_device;
131 max_compute_perf = compute_perf;
132 max_perf_device = current_device;
140 return max_perf_device;
Contains makVrv::DtDe class.
#define DtCheckCudaErrors(val, de)
This is exactly the same function as checkCudaErrors() from helper_cuda.h (From NVidia CUDA) except i...
Definition: DtHelperCuda.h:43
int DtGpuGetMaxGflopsDeviceId(DtDe &de)
This function returns the best GPU (with maximum GFLOPS)
Definition: DtHelperCuda.h:46
T DtCheckCuda(T result, char const *const func, const char *const file, int const line, DtDe &de)
This is exactly the same function as check() from helper_cuda.h (From NVidia CUDA) except it does not...
Definition: DtHelperCuda.h:22
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:72
#define MAX(x, y)
{secret}
Definition: trpage_io.h:40