summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@intel.com>2016-04-25 18:16:51 +0800
committerJunyan He <junyan.he@intel.com>2016-04-25 18:16:51 +0800
commit7029757e545d64ac879171e22835cdc56c374350 (patch)
tree1d1f213deb3a018106f527684e20123778cce6b8
parent1ca82c1cd31c29b96effe0565332cfb4b7eb08e2 (diff)
move worker to cl
-rw-r--r--include/cl_command_queue.h3
-rw-r--r--libclapi/cl_enqueue.c42
2 files changed, 44 insertions, 1 deletions
diff --git a/include/cl_command_queue.h b/include/cl_command_queue.h
index ee6c5c3b..c4b93638 100644
--- a/include/cl_command_queue.h
+++ b/include/cl_command_queue.h
@@ -44,9 +44,10 @@ typedef struct _cl_command_queue_work_item {
struct _cl_command_queue_work_item *prev, *next;
cl_int status; // Same as event->status, but sometimes the event maybe NULL
cl_event event; // The event represent this work.
+ cl_command_queue queue;
cl_event* depend_events;
cl_uint depend_event_num;
- void* content;
+ void* pdata;
} _cl_command_queue_work_item;
typedef _cl_command_queue_work_item* cl_command_queue_work_item;
diff --git a/libclapi/cl_enqueue.c b/libclapi/cl_enqueue.c
index d48299a5..d7dba5c8 100644
--- a/libclapi/cl_enqueue.c
+++ b/libclapi/cl_enqueue.c
@@ -180,6 +180,48 @@ static void *worker_thread_function(void *Arg)
return NULL;
}
+LOCAL cl_command_queue_work_item cl_enqueue_create_work_item(cl_command_queue queue,
+ cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
+{
+ cl_command_queue_work_item it;
+ int i;
+
+ assert(queue);
+ it = CL_CALLOC(1, sizeof(_cl_command_queue_work_item));
+ if (it == NULL)
+ return NULL;
+
+ cl_retain_command_queue(queue);
+ it->queue = queue;
+
+ if (num_events_in_wait_list > 0) {
+ assert(event_wait_list);
+ it->depend_events = CL_CALLOC(num_events_in_wait_list, sizeof(cl_command_queue_work_item));
+ if (it->depend_events == NULL) {
+ CL_FREE(it);
+ return NULL;
+ }
+
+ for (i = 0; i < num_events_in_wait_list; i++) {
+ assert(!IS_MARKER_EVENT(event_wait_list[i]));
+ assert(!IS_BARRIER_EVENT(event_wait_list[i]));
+ cl_retain_event(event_wait_list[i]);
+ it->depend_events[i] = event_wait_list[i];
+ }
+
+ it->depend_event_num = num_events_in_wait_list;
+ }
+
+ if (event) {
+ cl_retain_event(event);
+ it->event = event;
+ assert(cl_event_get_status(event) == CL_QUEUED);
+ }
+
+ it->status = CL_QUEUED;
+ return it;
+}
+
LOCAL cl_int cl_command_queue_worker_init(cl_command_queue queue)
{
cl_command_queue_worker worker = NULL;