Mesa (master): clover: Stub implementation of CL 1.2 sub-devices.
Francisco Jerez
currojerez at kemper.freedesktop.org
Tue Apr 29 14:19:02 UTC 2014
Module: Mesa
Branch: master
Commit: 7fb05f929802bf32391e416ceb62a34b4571905c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fb05f929802bf32391e416ceb62a34b4571905c
Author: EdB <edb+mesa at sigluy.net>
Date: Sun Apr 27 19:23:25 2014 +0200
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 <currojerez at riseup.net>
---
src/gallium/state_trackers/clover/api/device.cpp | 57 ++++++++++++++++++++
src/gallium/state_trackers/clover/api/dispatch.cpp | 6 +--
src/gallium/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 7bc8d0a..b77a50d 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -63,6 +63,37 @@ clGetDeviceIDs(cl_platform_id d_platform, cl_device_type device_type,
}
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 {
property_buffer buf { r_buf, size, r_size };
@@ -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<cl_device_id>() = NULL;
+ break;
+
+ case CL_DEVICE_PARTITION_MAX_SUB_DEVICES:
+ buf.as_scalar<cl_uint>() = 0;
+ break;
+
+ case CL_DEVICE_PARTITION_PROPERTIES:
+ buf.as_vector<cl_device_partition_property>() =
+ desc(property_list<cl_device_partition_property>());
+ break;
+
+ case CL_DEVICE_PARTITION_AFFINITY_DOMAIN:
+ buf.as_scalar<cl_device_affinity_domain>() = 0;
+ break;
+
+ case CL_DEVICE_PARTITION_TYPE:
+ buf.as_vector<cl_device_partition_property>() =
+ desc(property_list<cl_device_partition_property>());
+ break;
+
+ case CL_DEVICE_REFERENCE_COUNT:
+ buf.as_scalar<cl_uint>() = 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 e4f7ea3..2ee6208 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 47f9e39..833fb0e 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);
More information about the mesa-commit
mailing list