[Beignet] [PATCH] Fix a bug for event error status.

junyan.he at inbox.com junyan.he at inbox.com
Wed Aug 3 11:12:10 UTC 2016


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 src/cl_api.c   |  5 +++--
 src/cl_event.c | 16 +++++++++-------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 91ba5c5..33e5d93 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1280,6 +1280,7 @@ clGetEventInfo(cl_event      event,
                size_t *      param_value_size_ret)
 {
   cl_int err = CL_SUCCESS;
+  cl_int status;
   CHECK_EVENT(event);
 
   if (param_name == CL_EVENT_COMMAND_QUEUE) {
@@ -1289,8 +1290,8 @@ clGetEventInfo(cl_event      event,
   } else if (param_name == CL_EVENT_COMMAND_TYPE) {
     FILL_GETINFO_RET (cl_command_type, 1, &event->event_type, CL_SUCCESS);
   } else if (param_name == CL_EVENT_COMMAND_EXECUTION_STATUS) {
-    cl_event_get_status(event);
-    FILL_GETINFO_RET (cl_int, 1, &event->status, CL_SUCCESS);
+    status = cl_event_get_status(event);
+    FILL_GETINFO_RET (cl_int, 1, &status, CL_SUCCESS);
   } else if (param_name == CL_EVENT_REFERENCE_COUNT) {
     cl_uint ref = CL_OBJECT_GET_REF(event);
     FILL_GETINFO_RET (cl_int, 1, &ref, CL_SUCCESS);
diff --git a/src/cl_event.c b/src/cl_event.c
index c13ab0e..1021755 100644
--- a/src/cl_event.c
+++ b/src/cl_event.c
@@ -433,6 +433,8 @@ cl_event_wait_for_events_list(cl_uint num_events, const cl_event *event_list)
     while (e->status > CL_COMPLETE) {
       CL_OBJECT_WAIT_ON_COND(e);
     }
+
+    assert(e->status <= CL_COMPLETE);
     /* Iff some error happened, return the error. */
     if (e->status < CL_COMPLETE) {
       ret = CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
@@ -469,11 +471,6 @@ cl_event_check_waitlist(cl_uint num_events_in_wait_list, const cl_event *event_w
         break;
       }
 
-      if (cl_event_get_status(event_wait_list[i]) < CL_COMPLETE) {
-        err = CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
-        break;
-      }
-
       if (event == event_wait_list + i) { /* Pointer of element of the wait list */
         err = CL_INVALID_EVENT_WAIT_LIST;
         break;
@@ -538,16 +535,21 @@ cl_event_is_ready(cl_event event)
 {
   int i;
   int status;
+  int ret_status = CL_COMPLETE;
 
   for (i = 0; i < event->depend_event_num; i++) {
     status = cl_event_get_status(event->depend_events[i]);
 
-    if (status != CL_COMPLETE) {
+    if (status > CL_COMPLETE) { // Find some not ready, just OK
       return status;
     }
+
+    if (status < CL_COMPLETE) { // Record some error.
+      ret_status = status;
+    }
   }
 
-  return CL_COMPLETE;
+  return ret_status;
 }
 
 LOCAL cl_event
-- 
2.7.4

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
Check it out at http://www.inbox.com/earth




More information about the Beignet mailing list