[Mesa-dev] [PATCH 1/2] clover: fix event handling of buffer operations

Grigori Goronzy greg at chown.ath.cx
Thu Jun 4 12:34:34 PDT 2015


On 28.05.2015 10:10, Grigori Goronzy wrote:
> Wrap MapBuffer and MapImage as hard_event actions, like other
> operations. This enables correct profiling. Also make sure to wait
> for events to finish when blocking is requested by the caller.
> ---

Ping?

>  src/gallium/state_trackers/clover/api/transfer.cpp | 50 ++++++++++++++++++++--
>  1 file changed, 46 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp
> index fdb9405..4986f53 100644
> --- a/src/gallium/state_trackers/clover/api/transfer.cpp
> +++ b/src/gallium/state_trackers/clover/api/transfer.cpp
> @@ -270,6 +270,18 @@ namespace {
>                                     src_obj->resource(q), src_orig);
>        };
>     }
> +
> +   ///
> +   /// Resource mapping
> +   ///
> +   template<typename T>
> +   std::function<void (event &)>
> +   map_resource_op(command_queue &q, T obj, cl_map_flags flags, bool blocking,
> +                   const vector_t &origin, const vector_t &region, void **map) {
> +      return [=, &q](event &) {
> +         *map = obj->resource(q).add_map(q, flags, blocking, origin, region);
> +      };
> +   }
>  }
>  
>  CLOVER_API cl_int
> @@ -363,6 +375,10 @@ clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>                     region));
>  
>     ret_object(rd_ev, hev);
> +
> +   if (blocking)
> +      hev().wait();
> +
>     return CL_SUCCESS;
>  
>  } catch (error &e) {
> @@ -400,6 +416,10 @@ clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>                     region));
>  
>     ret_object(rd_ev, hev);
> +
> +   if (blocking)
> +      hev().wait();
> +
>     return CL_SUCCESS;
>  
>  } catch (error &e) {
> @@ -505,6 +525,10 @@ clEnqueueReadImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>                     region));
>  
>     ret_object(rd_ev, hev);
> +
> +   if (blocking)
> +      hev().wait();
> +
>     return CL_SUCCESS;
>  
>  } catch (error &e) {
> @@ -539,6 +563,10 @@ clEnqueueWriteImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>                     region));
>  
>     ret_object(rd_ev, hev);
> +
> +   if (blocking)
> +      hev().wait();
> +
>     return CL_SUCCESS;
>  
>  } catch (error &e) {
> @@ -665,10 +693,17 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>     validate_object(q, mem, obj_origin, obj_pitch, region);
>     validate_map_flags(mem, flags);
>  
> -   void *map = mem.resource(q).add_map(q, flags, blocking, obj_origin, region);
> +   void *map = nullptr;
> +   auto hev = create<hard_event>(
> +      q, CL_COMMAND_MAP_BUFFER, deps,
> +      map_resource_op(q, &mem, flags, blocking, obj_origin, region, &map));
>  
> -   ret_object(rd_ev, create<hard_event>(q, CL_COMMAND_MAP_BUFFER, deps));
> +   ret_object(rd_ev, hev);
>     ret_error(r_errcode, CL_SUCCESS);
> +
> +   if (blocking)
> +      hev().wait();
> +
>     return map;
>  
>  } catch (error &e) {
> @@ -693,10 +728,17 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>     validate_object(q, img, origin, region);
>     validate_map_flags(img, flags);
>  
> -   void *map = img.resource(q).add_map(q, flags, blocking, origin, region);
> +   void *map = nullptr;
> +   auto hev = create<hard_event>(
> +      q, CL_COMMAND_MAP_IMAGE, deps,
> +      map_resource_op(q, &img, flags, blocking, origin, region, &map));
>  
> -   ret_object(rd_ev, create<hard_event>(q, CL_COMMAND_MAP_IMAGE, deps));
> +   ret_object(rd_ev, hev);
>     ret_error(r_errcode, CL_SUCCESS);
> +
> +   if (blocking)
> +      hev().wait();
> +
>     return map;
>  
>  } catch (error &e) {
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150604/7e4d654a/attachment.sig>


More information about the mesa-dev mailing list