Skip to content

Commit afc9141

Browse files
committed
[GpuOclRuntime] Avoid error when iterating over non-gpu devices in gpu runner
1 parent 3c716fe commit afc9141

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/gc/ExecutionEngine/GPURuntime/ocl/GpuOclRuntime.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ OclRuntime::gcIntelDevices(size_t max) {
352352

353353
for (auto platform : platforms) {
354354
cl_uint numDevices;
355-
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numDevices);
355+
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, 0, nullptr, &numDevices);
356356
if (err != CL_SUCCESS) {
357357
gcLogE("Failed to get the number of devices on the platform.", platform,
358358
" Error: ", err);
@@ -363,7 +363,7 @@ OclRuntime::gcIntelDevices(size_t max) {
363363
}
364364

365365
SmallVector<cl_device_id> devices(numDevices);
366-
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices,
366+
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, numDevices,
367367
devices.data(), nullptr);
368368
if (err != CL_SUCCESS) {
369369
gcLogE("Failed to get the device ids on the platform ", platform,
@@ -372,6 +372,9 @@ OclRuntime::gcIntelDevices(size_t max) {
372372
}
373373

374374
for (auto dev : devices) {
375+
cl_device_type deviceType;
376+
clGetDeviceInfo(dev, CL_DEVICE_TYPE, sizeof(deviceType), &deviceType,
377+
nullptr);
375378
cl_uint vendorId;
376379
err = clGetDeviceInfo(dev, CL_DEVICE_VENDOR_ID, sizeof(cl_uint),
377380
&vendorId, nullptr);
@@ -380,6 +383,8 @@ OclRuntime::gcIntelDevices(size_t max) {
380383
continue;
381384
}
382385
if (vendorId == 0x8086) {
386+
if (!(deviceType & CL_DEVICE_TYPE_GPU))
387+
continue;
383388
intelDevices.emplace_back(dev);
384389
#ifndef NDEBUG
385390
size_t nameSize;

0 commit comments

Comments
 (0)