[Mesa-dev] [PATCH] clover: Implement clSetCommandQueueProperty() from OpenCL 1.0

Edward O'Callaghan funfunctor at folklore1984.net
Fri Nov 18 03:28:41 UTC 2016



On 11/18/2016 02:25 PM, Edward O'Callaghan wrote:
> Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
> ---
>  include/CL/cl.h                                    |  6 ++++
>  src/gallium/state_trackers/clover/api/dispatch.cpp |  2 +-
>  src/gallium/state_trackers/clover/api/queue.cpp    | 34 ++++++++++++++++++++++
>  src/gallium/state_trackers/clover/core/queue.cpp   |  3 ++
>  src/gallium/state_trackers/clover/core/queue.hpp   |  1 +
>  5 files changed, 45 insertions(+), 1 deletion(-)
> 
> diff --git a/include/CL/cl.h b/include/CL/cl.h
> index 316565d..51adf65 100644
> --- a/include/CL/cl.h
> +++ b/include/CL/cl.h
> @@ -656,6 +656,12 @@ clGetCommandQueueInfo(cl_command_queue      /* command_queue */,
>                        void *                /* param_value */,
>                        size_t *              /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
>  
> +extern CL_API_ENTRY cl_int CL_API_CALL
> +clSetCommandQueueProperty(cl_command_queue            /* command_queue */,
> +                          cl_command_queue_properties /* properties */,
> +                          cl_bool                     /* param_value */,
> +                          cl_command_queue_properties /* properties */) CL_API_SUFFIX__VERSION_1_0;
> +
>  /* Memory Object APIs */
>  extern CL_API_ENTRY cl_mem CL_API_CALL
>  clCreateBuffer(cl_context   /* context */,
> diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp
> index 8f4cfdc..0f64914 100644
> --- a/src/gallium/state_trackers/clover/api/dispatch.cpp
> +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp
> @@ -37,7 +37,7 @@ namespace clover {
>        clRetainCommandQueue,
>        clReleaseCommandQueue,
>        clGetCommandQueueInfo,
> -      NULL, // clSetCommandQueueProperty
> +      clSetCommandQueueProperty,
>        clCreateBuffer,
>        clCreateImage2D,
>        clCreateImage3D,
> diff --git a/src/gallium/state_trackers/clover/api/queue.cpp b/src/gallium/state_trackers/clover/api/queue.cpp
> index 06a2863..7734e19 100644
> --- a/src/gallium/state_trackers/clover/api/queue.cpp
> +++ b/src/gallium/state_trackers/clover/api/queue.cpp
> @@ -105,6 +105,40 @@ clGetCommandQueueInfo(cl_command_queue d_q, cl_command_queue_info param,
>  }
>  
>  CLOVER_API cl_int
> +clSetCommandQueueProperty(cl_command_queue d_q,
> +                     cl_command_queue_properties props, cl_bool enabled,
> +                     cl_command_queue_properties *old_props) try {
> +   //throws CL_INVALID_COMMAND_QUEUE if command_queue is not a valid.
> +   auto &q = obj(d_q);
> +
> +   if (props & ~(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE |
> +                 CL_QUEUE_PROFILING_ENABLE))
> +      throw error(CL_INVALID_VALUE);
> +
> +   if (!old_props) // If old_properties is NULL, it is ignored.
ugh, just noticed that after submit.. fixed locally..

> +	   *old_props = q.propertices();
> +
> +   if (enabled == CL_TRUE) {
> +      if (q.propertices() & props)
> +         return CL_SUCCESS;
> +   } else { // CL_FALSE
> +      if (q.propertices() & ~props)
> +         return CL_SUCCESS;
> +   }
> +
> +   // TODO how to determine if device supports props???
> +   if (1)
> +      q.propertices(props);
> +   else
> +      throw error(CL_INVALID_QUEUE_PROPERTIES);
> +
> +   return CL_SUCCESS;
> +
> +} catch (error &e) {
> +   return e.get();
> +}
> +
> +CLOVER_API cl_int
>  clFlush(cl_command_queue d_q) try {
>     obj(d_q).flush();
>     return CL_SUCCESS;
> diff --git a/src/gallium/state_trackers/clover/core/queue.cpp b/src/gallium/state_trackers/clover/core/queue.cpp
> index c91b97a..24b15f3 100644
> --- a/src/gallium/state_trackers/clover/core/queue.cpp
> +++ b/src/gallium/state_trackers/clover/core/queue.cpp
> @@ -87,6 +87,9 @@ command_queue::properties() const {
>     return props;
>  }
>  
> +void
> +command_queue::properties(cl_command_queue_properties props) : props(props);
> +
>  bool
>  command_queue::profiling_enabled() const {
>     return props & CL_QUEUE_PROFILING_ENABLE;
> diff --git a/src/gallium/state_trackers/clover/core/queue.hpp b/src/gallium/state_trackers/clover/core/queue.hpp
> index bddb86c..8c0906d 100644
> --- a/src/gallium/state_trackers/clover/core/queue.hpp
> +++ b/src/gallium/state_trackers/clover/core/queue.hpp
> @@ -49,6 +49,7 @@ namespace clover {
>        void flush();
>  
>        cl_command_queue_properties properties() const;
> +      void command_queue::properties(cl_command_queue_properties props);
>        bool profiling_enabled() const;
>  
>        const intrusive_ref<clover::context> context;
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161118/ed6fd8c8/attachment-0001.sig>


More information about the mesa-dev mailing list