[Beignet] [PATCH] Refine error check in cl_get_device_ids
Ruiling Song
ruiling.song at intel.com
Mon May 27 18:32:03 PDT 2013
This has impact on clGetDeviceIDs and clCreateContextFromType.
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
src/cl_device_id.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 136f3b1..8fa2b7c 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -106,17 +106,19 @@ cl_get_device_ids(cl_platform_id platform,
cl_uint * num_devices)
{
/* Check parameter consistency */
- if (UNLIKELY(num_entries == 0 && devices == NULL && num_devices == NULL))
- return CL_SUCCESS;
+ if (UNLIKELY(num_entries == 0 && devices != NULL))
+ return CL_INVALID_VALUE;
if (UNLIKELY(devices == NULL && num_devices == NULL))
return CL_INVALID_VALUE;
if (UNLIKELY(platform != NULL && platform != intel_platform))
return CL_INVALID_PLATFORM;
- if (num_devices && (device_type == CL_DEVICE_TYPE_CPU)) {
- *num_devices = 0;
- return CL_SUCCESS;
+ if(!(device_type & CL_DEVICE_TYPE_GPU)) {
+ if(num_devices)
+ *num_devices = 0;
+ return CL_DEVICE_NOT_FOUND;
}
+
/* Detect our device (reject a non intel one or gen<6) */
if (devices && UNLIKELY((*devices = cl_get_gt_device()) != NULL)) {
if (num_devices)
--
1.7.9.5
More information about the Beignet
mailing list