[Mesa-stable] [PATCH] clover: Fix bug with computing hard_event status

Tom Stellard thomas.stellard at amd.com
Fri Jul 10 18:53:43 PDT 2015


pipe_context::flush() can return a NULL fence if the queue is already
empty, so we should not assume that an event with a NULL fence
has the status of CL_QUEUED.

CC: 10.6 <mesa-stable at lists.freedesktop.org>
---
 src/gallium/state_trackers/clover/core/event.cpp | 7 ++++---
 src/gallium/state_trackers/clover/core/event.hpp | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/event.cpp b/src/gallium/state_trackers/clover/core/event.cpp
index d75b839..b973c78 100644
--- a/src/gallium/state_trackers/clover/core/event.cpp
+++ b/src/gallium/state_trackers/clover/core/event.cpp
@@ -118,7 +118,7 @@ event::wait() const {
 hard_event::hard_event(command_queue &q, cl_command_type command,
                        const ref_vector<event> &deps, action action) :
    event(q.context(), deps, profile(q, action), [](event &ev){}),
-   _queue(q), _command(command), _fence(NULL) {
+   _queue(q), _command(command), _fence(NULL), _fenced(false) {
    if (q.profiling_enabled())
       _time_queued = timestamp::current(q);
 
@@ -138,7 +138,7 @@ hard_event::status() const {
    if (event::status() < 0)
       return event::status();
 
-   else if (!_fence)
+   else if (!_fenced)
       return CL_QUEUED;
 
    else if (!screen->fence_finish(screen, _fence, 0))
@@ -167,7 +167,7 @@ hard_event::wait() const {
    if (status() == CL_QUEUED)
       queue()->flush();
 
-   if (!_fence ||
+   if (!_fenced ||
        !screen->fence_finish(screen, _fence, PIPE_TIMEOUT_INFINITE))
       throw error(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
 }
@@ -196,6 +196,7 @@ void
 hard_event::fence(pipe_fence_handle *fence) {
    pipe_screen *screen = queue()->device().pipe;
    screen->fence_reference(screen, &_fence, fence);
+   _fenced = true;
 }
 
 event::action
diff --git a/src/gallium/state_trackers/clover/core/event.hpp b/src/gallium/state_trackers/clover/core/event.hpp
index 6469e48..fac62d2 100644
--- a/src/gallium/state_trackers/clover/core/event.hpp
+++ b/src/gallium/state_trackers/clover/core/event.hpp
@@ -137,6 +137,7 @@ namespace clover {
       const intrusive_ref<command_queue> _queue;
       cl_command_type _command;
       pipe_fence_handle *_fence;
+      bool _fenced;
       lazy<cl_ulong> _time_queued, _time_submit, _time_start, _time_end;
    };
 
-- 
2.0.4



More information about the mesa-stable mailing list