diff options
author | Francisco Jerez <[email protected]> | 2015-06-09 22:59:43 +0300 |
---|---|---|
committer | Jan Vesely <[email protected]> | 2017-09-20 18:48:41 -0400 |
commit | bc4000ee40c78efe1e5e8a6244d4bb55389d8418 (patch) | |
tree | 54e58efa118b9e65ff4184a8c402d62e7b19487b /src/gallium/state_trackers/clover | |
parent | 02f8ac6b70033a1b240d497c4664c359d2398cc3 (diff) |
clover: Run the associated action before an event is signalled.
And define a method for other threads to wait until the action
function associated with an event has been executed to completion.
For hard events, this will mean waiting until the corresponding
command has been submitted to the pipe driver, without necessarily
flushing the pipe_context and waiting for the actual command to be
processed by the GPU (which is what hard_event::wait() already does).
This weaker kind of event wait will allow implementing blocking memory
transfers efficiently.
Acked-by: Aaron Watry <[email protected]>
Reviewed-by: Jan Vesely <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover')
-rw-r--r-- | src/gallium/state_trackers/clover/core/event.cpp | 22 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/event.hpp | 1 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/gallium/state_trackers/clover/core/event.cpp b/src/gallium/state_trackers/clover/core/event.cpp index 4f8531e407e..cd5d786604d 100644 --- a/src/gallium/state_trackers/clover/core/event.cpp +++ b/src/gallium/state_trackers/clover/core/event.cpp @@ -44,19 +44,16 @@ event::trigger_self() { if (!--_wait_count) std::swap(_chain, evs); + cv.notify_all(); return evs; } void event::trigger() { - auto evs = trigger_self(); - - if (signalled()) { + if (wait_count() == 1) action_ok(*this); - cv.notify_all(); - } - for (event &ev : evs) + for (event &ev : trigger_self()) ev.trigger(); } @@ -73,11 +70,9 @@ event::abort_self(cl_int status) { void event::abort(cl_int status) { - auto evs = abort_self(status); - action_fail(*this); - for (event &ev : evs) + for (event &ev : abort_self(status)) ev.abort(status); } @@ -112,12 +107,17 @@ event::chain(event &ev) { } void +event::wait_signalled() const { + std::unique_lock<std::mutex> lock(mutex); + cv.wait(lock, [=]{ return !_wait_count; }); +} + +void event::wait() const { for (event &ev : deps) ev.wait(); - std::unique_lock<std::mutex> lock(mutex); - cv.wait(lock, [=]{ return !_wait_count; }); + wait_signalled(); } hard_event::hard_event(command_queue &q, cl_command_type command, diff --git a/src/gallium/state_trackers/clover/core/event.hpp b/src/gallium/state_trackers/clover/core/event.hpp index 53dac686f8e..03c97bcf4da 100644 --- a/src/gallium/state_trackers/clover/core/event.hpp +++ b/src/gallium/state_trackers/clover/core/event.hpp @@ -69,6 +69,7 @@ namespace clover { virtual cl_int status() const; virtual command_queue *queue() const = 0; virtual cl_command_type command() const = 0; + void wait_signalled() const; virtual void wait() const; virtual struct pipe_fence_handle *fence() const { |