[Beignet] [PATCH] Runtime: fix get non support type device bug.

Pan, Xiuli xiuli.pan at intel.com
Tue Feb 14 06:51:16 UTC 2017


LGTM.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Yang Rong
Sent: Friday, February 10, 2017 4:11 PM
To: beignet at lists.freedesktop.org
Cc: Yang, Rong R <rong.r.yang at intel.com>
Subject: [Beignet] [PATCH] Runtime: fix get non support type device bug.

Only return support device type (GPU and default) in function cl_get_gt_device.

Contributor: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 src/cl_device_id.c | 10 +++++++---
 src/cl_device_id.h |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 31f8616..d4f4208 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -255,12 +255,16 @@ static struct _cl_device_id intel_kbl_gt4_device = {  };
 
 LOCAL cl_device_id
-cl_get_gt_device(void)
+cl_get_gt_device(cl_device_type device_type)
 {
   cl_device_id ret = NULL;
   const int device_id = cl_driver_get_device_id();
   cl_device_id device = NULL;
 
+  //cl_get_gt_device only return GPU type device.
+  if (((CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_DEFAULT) & device_type) == 0)
+    return NULL;
+
 #define DECL_INFO_STRING(BREAK, STRUCT, FIELD, STRING) \
     STRUCT.FIELD = STRING; \
     STRUCT.JOIN(FIELD,_sz) = sizeof(STRING); \
@@ -877,7 +881,7 @@ cl_get_device_ids(cl_platform_id    platform,
   cl_device_id device;
 
   /* Do we have a usable device? */
-  device = cl_get_gt_device();
+  device = cl_get_gt_device(device_type);
   if (device) {
     cl_self_test_res ret = cl_self_test(device, SELF_TEST_PASS);
     if (ret == SELF_TEST_ATOMIC_FAIL) { @@ -1603,7 +1607,7 @@ cl_devices_list_check(cl_uint num_devices, const cl_device_id *devices)
     }
 
     // TODO: We now just support Gen Device.
-    if (devices[i] != cl_get_gt_device()) {
+    if (devices[i] != cl_get_gt_device(devices[i]->device_type)) {
       return CL_INVALID_DEVICE;
     }
   }
diff --git a/src/cl_device_id.h b/src/cl_device_id.h index 9d8b512..6b8f2eb 100644
--- a/src/cl_device_id.h
+++ b/src/cl_device_id.h
@@ -154,7 +154,7 @@ extern cl_int cl_get_device_ids(cl_platform_id    platform,
                                 cl_uint *         num_devices);
 
 /* Get the intel GPU device we currently have in this machine (if any) */ -extern cl_device_id cl_get_gt_device(void);
+extern cl_device_id cl_get_gt_device(cl_device_type device_type);
 
 /* Provide info about the device */
 extern cl_int cl_get_device_info(cl_device_id     device,
--
2.7.4

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list