[Mesa-dev] [PATCH] clover : Implement sub-devices

Francisco Jerez currojerez at riseup.net
Tue Apr 29 07:21:35 PDT 2014


EdB <edb+mesa at sigluy.net> writes:

> The implementation is basically a NOP
> but it conforms with OpenCL 1.2
>
> As before, it needed CL 1.2 headers

Pushed with a couple of minor-ish fixes [1].

[1] http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fb05f929802bf32391e416ceb62a34b4571905c

> ---
>  src/gallium/state_trackers/clover/api/device.cpp   | 59 ++++++++++++++++++++++
>  src/gallium/state_trackers/clover/api/dispatch.cpp |  6 +--
>  src/gallium/state_trackers/clover/api/dispatch.hpp |  7 ++-
>  3 files changed, 68 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..46a8548 100644
> --- a/src/gallium/state_trackers/clover/api/device.cpp
> +++ b/src/gallium/state_trackers/clover/api/device.cpp
> @@ -295,6 +295,28 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
>        buf.as_string() = "OpenCL C 1.1";
>        break;
>  
> +   // No suport for sub-devices. d_dev is always a root device
> +   case CL_DEVICE_PARENT_DEVICE:
> +      buf.as_scalar<cl_device_id>() = 0;
> +      break;
> +
> +   case CL_DEVICE_PARTITION_MAX_SUB_DEVICES:
> +      buf.as_scalar<cl_uint>() = 0;
> +      break;
> +
> +   case CL_DEVICE_PARTITION_PROPERTIES:
> +   case CL_DEVICE_PARTITION_TYPE:
> +      buf.as_vector<cl_device_partition_property>();
> +      break;
> +
> +   case CL_DEVICE_PARTITION_AFFINITY_DOMAIN:
> +      buf.as_vector<cl_device_affinity_domain>();
> +      break;
> +
> +   case CL_DEVICE_REFERENCE_COUNT:
> +      buf.as_scalar<cl_uint>() = 1;
> +      break;
> +
>     default:
>        throw error(CL_INVALID_VALUE);
>     }
> @@ -304,3 +326,40 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
>  } catch (error &e) {
>     return e.get();
>  }
> +
> +CLOVER_API cl_int
> +clCreateSubDevices(cl_device_id in_device,
> +                   const cl_device_partition_property *properties,
> +                   cl_uint num_devices, cl_device_id *out_devices,
> +                   cl_uint *num_devices_ret) {
> +   // sub-devices are not really suported
> +   // so there is no supported partitioning schemes
> +   // and we may return CL_INVALID_VALUE
> +   return CL_INVALID_VALUE;
> +}
> +
> +CLOVER_API cl_int
> +clRetainDevice(cl_device_id d_dev) try {
> +   // Sub-devices are not really suported
> +   // but d_dev has to be a valid device
> +   obj(d_dev);
> +
> +   // ref 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 {
> +   // sub-devices are not really suported
> +   // but d_dev has to be a valid device
> +   obj(d_dev);
> +
> +   // ref count doesn't change for root devices
> +   return CL_SUCCESS;
> +
> +} catch (error &e) {
> +   return e.get();
> +}
> 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 9dfb2b9..0b1fbf5 100644
> --- a/src/gallium/state_trackers/clover/api/dispatch.hpp
> +++ b/src/gallium/state_trackers/clover/api/dispatch.hpp
> @@ -638,7 +638,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);
> -- 
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140429/ff838193/attachment.sig>


More information about the mesa-dev mailing list