Skip to content

Commit 240fad5

Browse files
committed
GPU OpenCL: Use device timers only when supported + better debug output
1 parent 82a019b commit 240fad5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

GPU/GPUTracking/Base/opencl-common/GPUReconstructionOCL.cxx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime()
108108
}
109109
mInternals->platform = mInternals->platforms[mProcessingSettings.platformNum];
110110
found = true;
111+
if (mProcessingSettings.debugLevel >= 2) {
112+
char platform_profile[256] = {}, platform_version[256] = {}, platform_name[256] = {}, platform_vendor[256] = {};
113+
clGetPlatformInfo(mInternals->platform, CL_PLATFORM_PROFILE, sizeof(platform_profile), platform_profile, nullptr);
114+
clGetPlatformInfo(mInternals->platform, CL_PLATFORM_VERSION, sizeof(platform_version), platform_version, nullptr);
115+
clGetPlatformInfo(mInternals->platform, CL_PLATFORM_NAME, sizeof(platform_name), platform_name, nullptr);
116+
clGetPlatformInfo(mInternals->platform, CL_PLATFORM_VENDOR, sizeof(platform_vendor), platform_vendor, nullptr);
117+
GPUInfo("Selected Platform %d: (%s %s) %s %s", mProcessingSettings.platformNum, platform_profile, platform_version, platform_vendor, platform_name);
118+
}
111119
} else {
112120
for (uint32_t i_platform = 0; i_platform < num_platforms; i_platform++) {
113121
char platform_profile[256] = {}, platform_version[256] = {}, platform_name[256] = {}, platform_vendor[256] = {};
@@ -227,6 +235,8 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime()
227235
clGetDeviceInfo(mInternals->device, CL_DEVICE_VERSION, sizeof(deviceVersion) - 1, deviceVersion, nullptr);
228236
clGetDeviceInfo(mInternals->device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(maxWorkGroup), &maxWorkGroup, nullptr);
229237
clGetDeviceInfo(mInternals->device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(maxWorkItems), maxWorkItems, nullptr);
238+
int versionMajor, versionMinor;
239+
sscanf(deviceVersion, "OpenCL %d.%d", &versionMajor, &versionMinor);
230240
if (mProcessingSettings.debugLevel >= 2) {
231241
GPUInfo("Using OpenCL device %d: %s %s with properties:", bestDevice, device_vendor, device_name);
232242
GPUInfo("\tVersion = %s", deviceVersion);
@@ -277,9 +287,18 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime()
277287
quit("OPENCL Constant Memory Allocation Error");
278288
}
279289

290+
if (device_type & CL_DEVICE_TYPE_CPU) {
291+
if (mProcessingSettings.deviceTimers && mProcessingSettings.debugLevel >= 2) {
292+
GPUInfo("Disabling device timers for CPU device");
293+
}
294+
mProcessingSettings.deviceTimers = 0;
295+
}
280296
for (int32_t i = 0; i < mNStreams; i++) {
281297
#ifdef CL_VERSION_2_0
282-
cl_queue_properties prop = mProcessingSettings.deviceTimers ? CL_QUEUE_PROFILING_ENABLE : 0;
298+
cl_queue_properties prop = 0;
299+
if (versionMajor >= 2 && IsGPU() && mProcessingSettings.deviceTimers) {
300+
prop |= CL_QUEUE_PROFILING_ENABLE;
301+
}
283302
mInternals->command_queue[i] = clCreateCommandQueueWithProperties(mInternals->context, mInternals->device, &prop, &ocl_error);
284303
if (mProcessingSettings.deviceTimers && ocl_error == CL_INVALID_QUEUE_PROPERTIES) {
285304
GPUError("GPU device timers not supported by OpenCL platform, disabling");

0 commit comments

Comments
 (0)