Hi Giuseppe,

You point about the device type is right, but the git commit you found is not 
right the function is just copy form somewhere else. And the this patch is not 
follow the OpenCL spec. As the Beignet does not have a CPU device, we should 
just return CL_INVALID_DEVICE_TYPE.

I will send a patch to fix this problem.

Thanks
Xiuli
-----Original Message-----
From: Beignet [mailto:[email protected]] On Behalf Of 
Giuseppe Bilotta
Sent: Friday, February 10, 2017 6:46 AM
To: Beignet ML <[email protected]>
Cc: Giuseppe Bilotta <[email protected]>
Subject: [Beignet] [PATCH] Only provide device IDs if the type matches

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 <[email protected]>
---
 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

_______________________________________________
Beignet mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to