[Beignet] [PATCH] Only provide device IDs if the type matches

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Thu Feb 9 22:45:40 UTC 2017


If the user is asking for (say) CPU devices only, we should not return
a GPU device instead. This fixes a regression introduced with the
refactoring done in 494081299ac3f6970b906cb4d7d1eb1fc2fb23c8, by
reinstating the check that used to be in cl_check_device_type() (except
that instead of hard-coding CL_DEVICE_TYPE_GPU we use the device type
reported by the device).

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
---
 src/cl_device_id.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index b2810635..b8184486 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -880,8 +880,14 @@ cl_get_device_ids(cl_platform_id    platform,
 
   openlog("beignet", LOG_CONS, LOG_USER);
 
-  /* Do we have a usable device? */
   device = cl_get_gt_device();
+
+  /* Is the device of the correct type? */
+  if (device &&
+     ((device->device_type | CL_DEVICE_TYPE_DEFAULT) & device_type) == 0)
+    device = 0;
+
+  /* Do we have a usable device? */
   if (device) {
     cl_self_test_res ret = cl_self_test(device, SELF_TEST_PASS);
     if (ret == SELF_TEST_ATOMIC_FAIL) {
-- 
2.11.1.658.g6a0cb3eb68



More information about the Beignet mailing list