From 7fb05f929802bf32391e416ceb62a34b4571905c Mon Sep 17 00:00:00 2001 From: EdB Date: Sun, 27 Apr 2014 19:23:25 +0200 Subject: [PATCH] clover: Stub implementation of CL 1.2 sub-devices. The implementation is basically a NOP but it conforms with OpenCL 1.2. [ Francisco Jerez: Initialize property return buffer for CL_DEVICE_PARTITION_PROPERTIES, CL_DEVICE_PARTITION_TYPE, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, and make the latter a scalar rather than a vector. Some clean-up and code style fixes. ] Reviewed-by: Francisco Jerez --- .../state_trackers/clover/api/device.cpp | 57 +++++++++++++++++++ .../state_trackers/clover/api/dispatch.cpp | 6 +- .../state_trackers/clover/api/dispatch.hpp | 7 ++- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp index 7bc8d0a7142..b77a50dafea 100644 --- a/src/gallium/state_trackers/clover/api/device.cpp +++ b/src/gallium/state_trackers/clover/api/device.cpp @@ -62,6 +62,37 @@ clGetDeviceIDs(cl_platform_id d_platform, cl_device_type device_type, return e.get(); } +CLOVER_API cl_int +clCreateSubDevices(cl_device_id d_dev, + const cl_device_partition_property *props, + cl_uint num_devs, cl_device_id *rd_devs, + cl_uint *rnum_devs) { + // There are no currently supported partitioning schemes. + return CL_INVALID_VALUE; +} + +CLOVER_API cl_int +clRetainDevice(cl_device_id d_dev) try { + obj(d_dev); + + // The reference count doesn't change for root devices. + return CL_SUCCESS; + +} catch (error &e) { + return e.get(); +} + +CLOVER_API cl_int +clReleaseDevice(cl_device_id d_dev) try { + obj(d_dev); + + // The reference count doesn't change for root devices. + return CL_SUCCESS; + +} catch (error &e) { + return e.get(); +} + CLOVER_API cl_int clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, size_t size, void *r_buf, size_t *r_size) try { @@ -295,6 +326,32 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, buf.as_string() = "OpenCL C 1.1"; break; + case CL_DEVICE_PARENT_DEVICE: + buf.as_scalar() = NULL; + break; + + case CL_DEVICE_PARTITION_MAX_SUB_DEVICES: + buf.as_scalar() = 0; + break; + + case CL_DEVICE_PARTITION_PROPERTIES: + buf.as_vector() = + desc(property_list()); + break; + + case CL_DEVICE_PARTITION_AFFINITY_DOMAIN: + buf.as_scalar() = 0; + break; + + case CL_DEVICE_PARTITION_TYPE: + buf.as_vector() = + desc(property_list()); + break; + + case CL_DEVICE_REFERENCE_COUNT: + buf.as_scalar() = 1; + break; + default: throw error(CL_INVALID_VALUE); } diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp index e4f7ea3cc74..2ee62086dc8 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.cpp +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp @@ -117,9 +117,9 @@ namespace clover { NULL, // clRetainDeviceEXT NULL, // clReleaseDeviceEXT NULL, // clCreateEventFromGLsyncKHR - NULL, // clCreateSubDevices - NULL, // clRetainDevice - NULL, // clReleaseDevice + clCreateSubDevices, + clRetainDevice, + clReleaseDevice, NULL, // clCreateImage NULL, // clCreateProgramWithBuiltInKernels NULL, // clCompileProgram diff --git a/src/gallium/state_trackers/clover/api/dispatch.hpp b/src/gallium/state_trackers/clover/api/dispatch.hpp index 47f9e3916ef..833fb0e8008 100644 --- a/src/gallium/state_trackers/clover/api/dispatch.hpp +++ b/src/gallium/state_trackers/clover/api/dispatch.hpp @@ -640,7 +640,12 @@ struct _cl_icd_dispatch { cl_GLsync sync, cl_int *errcode_ret); - void *clCreateSubDevices; + CL_API_ENTRY cl_int (CL_API_CALL *clCreateSubDevices)( + cl_device_id in_device, + const cl_device_partition_property *partition_properties, + cl_uint num_entries, + cl_device_id *out_devices, + cl_uint *num_devices); CL_API_ENTRY cl_int (CL_API_CALL *clRetainDevice)( cl_device_id device); -- 2.30.2