clover: Wait for requested operation if blocking flag is set
authorJan Vesely <jan.vesely@rutgers.edu>
Wed, 2 Aug 2017 21:04:24 +0000 (17:04 -0400)
committerJan Vesely <jan.vesely@rutgers.edu>
Wed, 20 Sep 2017 22:48:46 +0000 (18:48 -0400)
v2: wait in map_buffer and map_image as well
v3: use event::wait instead of wait (skips fence wait for hard_event)
v4: use wait_signalled()

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Aaron Watry <awatry@gmail.com>
src/gallium/state_trackers/clover/api/transfer.cpp

index f7046253be8ef35d7785ab0d4d867d029b9b12b4..34559042aec34eebcf712bc136dc17ccda3162a0 100644 (file)
@@ -295,6 +295,9 @@ clEnqueueReadBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
                    &mem, obj_origin, obj_pitch,
                    region));
 
+   if (blocking)
+       hev().wait_signalled();
+
    ret_object(rd_ev, hev);
    return CL_SUCCESS;
 
@@ -325,6 +328,9 @@ clEnqueueWriteBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
                    ptr, {}, obj_pitch,
                    region));
 
+   if (blocking)
+       hev().wait_signalled();
+
    ret_object(rd_ev, hev);
    return CL_SUCCESS;
 
@@ -362,6 +368,9 @@ clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
                    &mem, obj_origin, obj_pitch,
                    region));
 
+   if (blocking)
+       hev().wait_signalled();
+
    ret_object(rd_ev, hev);
    return CL_SUCCESS;
 
@@ -399,6 +408,9 @@ clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
                    ptr, host_origin, host_pitch,
                    region));
 
+   if (blocking)
+       hev().wait_signalled();
+
    ret_object(rd_ev, hev);
    return CL_SUCCESS;
 
@@ -504,6 +516,9 @@ clEnqueueReadImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
                    &img, src_origin, src_pitch,
                    region));
 
+   if (blocking)
+       hev().wait_signalled();
+
    ret_object(rd_ev, hev);
    return CL_SUCCESS;
 
@@ -538,6 +553,9 @@ clEnqueueWriteImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
                    ptr, {}, src_pitch,
                    region));
 
+   if (blocking)
+       hev().wait_signalled();
+
    ret_object(rd_ev, hev);
    return CL_SUCCESS;
 
@@ -667,7 +685,11 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
 
    void *map = mem.resource(q).add_map(q, flags, blocking, obj_origin, region);
 
-   ret_object(rd_ev, create<hard_event>(q, CL_COMMAND_MAP_BUFFER, deps));
+   auto hev = create<hard_event>(q, CL_COMMAND_MAP_BUFFER, deps);
+   if (blocking)
+       hev().wait_signalled();
+
+   ret_object(rd_ev, hev);
    ret_error(r_errcode, CL_SUCCESS);
    return map;
 
@@ -695,7 +717,11 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
 
    void *map = img.resource(q).add_map(q, flags, blocking, origin, region);
 
-   ret_object(rd_ev, create<hard_event>(q, CL_COMMAND_MAP_IMAGE, deps));
+   auto hev = create<hard_event>(q, CL_COMMAND_MAP_IMAGE, deps);
+   if (blocking)
+       hev().wait_signalled();
+
+   ret_object(rd_ev, hev);
    ret_error(r_errcode, CL_SUCCESS);
    return map;