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 <awatry@gmail.com> Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
This commit is contained in:
committed by
Jan Vesely
parent
02f8ac6b70
commit
bc4000ee40
@@ -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);
|
||||
}
|
||||
|
||||
@@ -111,13 +106,18 @@ event::chain(event &ev) {
|
||||
ev.deps.push_back(*this);
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user