[Beignet] [PATCH] Runtime: fix get non support type device bug.
Yang Rong
rong.r.yang at intel.com
Fri Feb 10 08:11:13 UTC 2017
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
More information about the Beignet
mailing list