This makes sure that there are not too many concurrent fences. Also, simplify status handling by keeping track of the current state.
Signed-off-by: Niels Ole Salscheider <niels_...@salscheider-online.de> --- src/gallium/state_trackers/clover/core/event.cpp | 29 +++++++++++++++--------- src/gallium/state_trackers/clover/core/event.hpp | 12 +++++----- 2 Dateien geändert, 24 Zeilen hinzugefügt(+), 17 Zeilen entfernt(-) diff --git a/src/gallium/state_trackers/clover/core/event.cpp b/src/gallium/state_trackers/clover/core/event.cpp index cbb97bf..13e8130 100644 --- a/src/gallium/state_trackers/clover/core/event.cpp +++ b/src/gallium/state_trackers/clover/core/event.cpp @@ -28,7 +28,7 @@ using namespace clover; _cl_event::_cl_event(clover::context &ctx, std::vector<clover::event *> deps, action action_ok, action action_fail) : - ctx(ctx), __status(0), wait_count(1), + ctx(ctx), __status(CL_QUEUED), wait_count(1), action_ok(action_ok), action_fail(action_fail) { for (auto ev : deps) ev->chain(this); @@ -114,6 +114,7 @@ hard_event::trigger() { pipe->end_query(pipe, __query_end); __ts_submit = screen->get_timestamp(screen); } + __status = CL_SUBMITTED; while (!__chain.empty()) { __chain.back()->trigger(); @@ -123,20 +124,21 @@ hard_event::trigger() { } cl_int -hard_event::status() const { +hard_event::status() { pipe_screen *screen = queue()->dev.pipe; - if (__status < 0) + if (__status != CL_SUBMITTED) return __status; - else if (!__fence) - return CL_QUEUED; - - else if (!screen->fence_signalled(screen, __fence)) + else if (__fence && !screen->fence_signalled(screen, __fence)) return CL_SUBMITTED; - else + else { + if (__fence) + screen->fence_reference(screen, &__fence, NULL); + __status = CL_COMPLETE; return CL_COMPLETE; + } } cl_command_queue @@ -150,15 +152,20 @@ hard_event::command() const { } void -hard_event::wait() const { +hard_event::wait() { pipe_screen *screen = queue()->dev.pipe; if (status() == CL_QUEUED) queue()->flush(); + if (status() == CL_COMPLETE) + return; + if (!__fence || !screen->fence_finish(screen, __fence, PIPE_TIMEOUT_INFINITE)) throw error(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST); + screen->fence_reference(screen, &__fence, NULL); + __status = CL_COMPLETE; } cl_ulong @@ -231,7 +238,7 @@ soft_event::trigger() { } cl_int -soft_event::status() const { +soft_event::status() { if (__status < 0) return __status; @@ -256,7 +263,7 @@ soft_event::command() const { } void -soft_event::wait() const { +soft_event::wait() { for (auto ev : deps) ev->wait(); diff --git a/src/gallium/state_trackers/clover/core/event.hpp b/src/gallium/state_trackers/clover/core/event.hpp index de92de0..611b233 100644 --- a/src/gallium/state_trackers/clover/core/event.hpp +++ b/src/gallium/state_trackers/clover/core/event.hpp @@ -61,10 +61,10 @@ public: void abort(cl_int status); bool signalled() const; - virtual cl_int status() const = 0; + virtual cl_int status() = 0; virtual cl_command_queue queue() const = 0; virtual cl_command_type command() const = 0; - virtual void wait() const = 0; + virtual void wait() = 0; clover::context &ctx; @@ -101,10 +101,10 @@ namespace clover { virtual void trigger(); - virtual cl_int status() const; + virtual cl_int status(); virtual cl_command_queue queue() const; virtual cl_command_type command() const; - virtual void wait() const; + virtual void wait(); cl_ulong ts_queued() const; cl_ulong ts_submit() const; @@ -138,10 +138,10 @@ namespace clover { virtual void trigger(); - virtual cl_int status() const; + virtual cl_int status(); virtual cl_command_queue queue() const; virtual cl_command_type command() const; - virtual void wait() const; + virtual void wait(); }; } -- 1.7.11.7 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev