summaryrefslogtreecommitdiff
path: root/backend/src/driver
diff options
context:
space:
mode:
authorJunyan He <junyan.he@intel.com>2016-04-08 15:10:25 +0800
committerJunyan He <junyan.he@intel.com>2016-04-08 15:10:25 +0800
commitff0a2dae03b2b5f559c1ea3c209d7e8b5ebee19e (patch)
treec3069e7917e25ab1f5476e91aba12f3a8ffb7f2f /backend/src/driver
parent42a0ce0761a79f8ce6aaed049c068ea6a178e112 (diff)
event
Diffstat (limited to 'backend/src/driver')
-rw-r--r--backend/src/driver/cl_gen_command_queue.cpp34
-rw-r--r--backend/src/driver/cl_gen_driver.hpp3
2 files changed, 34 insertions, 3 deletions
diff --git a/backend/src/driver/cl_gen_command_queue.cpp b/backend/src/driver/cl_gen_command_queue.cpp
index bfd7ce89..6ca63d94 100644
--- a/backend/src/driver/cl_gen_command_queue.cpp
+++ b/backend/src/driver/cl_gen_command_queue.cpp
@@ -30,13 +30,43 @@ extern "C" { // for the C header files
#include "sys/alloc.hpp"
#include "cl_gen_driver.hpp"
+bool GenGPUWorkItem::setStatus(cl_int status)
+{
+ if (this->event == NULL)
+ return false;
+
+ pthread_mutex_lock(&event->lock);
+ GBE_ASSERT(status < event->status); //Should never go back.
+ event->status = status;
+ cl_event_user_cb user_cb = event->user_cb;
+ while (user_cb) {
+ if (user_cb->status < event->status)
+ continue;
+
+ if (user_cb->executed)
+ continue;
+
+ user_cb->executed = CL_TRUE;
+ user_cb->pfn_notify(event, event->status, user_cb->user_data);
+ user_cb = user_cb->next;
+ }
+ pthread_mutex_unlock(&event->lock);
+ return true;
+}
+
cl_int GenGPUWorkItem::isReady(void)
{
for (auto e : dependEvents) {
- if (e->status > CL_COMPLETE)
+ pthread_mutex_lock(&e->lock);
+ if (e->status > CL_COMPLETE) {
+ pthread_mutex_unlock(&e->lock);
return 1;
- if (e->status < 0)
+ }
+ if (e->status < 0) {
+ pthread_mutex_unlock(&e->lock);
return -1;
+ }
+ pthread_mutex_unlock(&e->lock);
}
return 0;
diff --git a/backend/src/driver/cl_gen_driver.hpp b/backend/src/driver/cl_gen_driver.hpp
index 689d74e6..b4fee18a 100644
--- a/backend/src/driver/cl_gen_driver.hpp
+++ b/backend/src/driver/cl_gen_driver.hpp
@@ -229,7 +229,8 @@ struct GenGPUWorkItem { // Represent Some real work for GPU to do.
GenGPUWorkItem(cl_event event, const cl_event* dependEvents, cl_uint num_events);
virtual bool submit(void) = 0;
virtual bool complete(void) = 0;
- virtual cl_int isReady(void); // >0 means ready, =0 means not ready, <0 means error and cancel
+ cl_int isReady(void); // >0 means ready, =0 means not ready, <0 means error and cancel
+ bool setStatus(cl_int status);
virtual ~GenGPUWorkItem() { };
};