clover: Stub implementation of CL 1.2 sub-devices.
authorEdB <edb+mesa@sigluy.net>
Sun, 27 Apr 2014 17:23:25 +0000 (19:23 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 29 Apr 2014 14:14:50 +0000 (16:14 +0200)
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@riseup.net>
src/gallium/state_trackers/clover/api/device.cpp
src/gallium/state_trackers/clover/api/dispatch.cpp
src/gallium/state_trackers/clover/api/dispatch.hpp

index 7bc8d0a7142f96b3857c7d8493290587f7c0ca13..b77a50dafeaf47536af518cb047870973f190899 100644 (file)
@@ -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<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);
    }
index e4f7ea3cc74282ff748d56c661e2aed279508959..2ee62086dc8b13f5e54268704ac3bcce277176a5 100644 (file)
@@ -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
index 47f9e3916efa82310978018925e0e3cf69e56747..833fb0e800831ddf0289a1afcf6e2f97a42b9c8a 100644 (file)
@@ -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);