Skip to content

Commit 80f8eaf

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 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,8 @@ 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, nullptr);
375377
cl_uint vendorId;
376378
err = clGetDeviceInfo(dev, CL_DEVICE_VENDOR_ID, sizeof(cl_uint),
377379
&vendorId, nullptr);
@@ -380,6 +382,8 @@ OclRuntime::gcIntelDevices(size_t max) {
380382
continue;
381383
}
382384
if (vendorId == 0x8086) {
385+
if(!(deviceType & CL_DEVICE_TYPE_GPU))
386+
continue;
383387
intelDevices.emplace_back(dev);
384388
#ifndef NDEBUG
385389
size_t nameSize;

0 commit comments

Comments
 (0)