summaryrefslogtreecommitdiff
path: root/src/cl_command_queue.h
diff options
context:
space:
mode:
authorJunyan He <junyan.he@intel.com>2016-09-21 17:47:19 +0800
committerYang Rong <rong.r.yang@intel.com>2016-09-23 12:52:43 +0800
commit7fd45f155d1603cdcb20498598308064e5054096 (patch)
tree3fcda46e8c59ff2c2c7208cf5efa51b00530c026 /src/cl_command_queue.h
parent84898f0ea50a8e617c3d5f69f161adcae2d8abc6 (diff)
Add command queue's enqueue thread.
According to Spec, event should be more suitable to implement in async mode. We now add a thread to each command queue to handle the event commands. The basic idea is: 1. If a command depends on other events which are not COMPLETED, this command must be queued to that thread. Every event's status change will notify the command queue, and give that thread a chance to dequeue and run the enqueued commands. 2. For some BLOCK API, such as MapBuffer with BLOCK flag set, we will wait for all the events in wait list ready and execute it in sync mode, no event will be queued to that thread. 3. For NDRange like commands, because we want to gain the best performance, we will check its wait list, if all are COMPLETED, we SUBMIT that NDRange command, and set the event to SUBMUTTED status. Event will also be queued to that thread, and that thread will wait for it COMPLETED. Signed-off-by: Junyan He <junyan.he@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_command_queue.h')
-rw-r--r--src/cl_command_queue.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cl_command_queue.h b/src/cl_command_queue.h
index f0b421da..34886f8e 100644
--- a/src/cl_command_queue.h
+++ b/src/cl_command_queue.h
@@ -29,9 +29,21 @@
struct intel_gpgpu;
+typedef struct _cl_command_queue_enqueue_worker {
+ cl_command_queue queue;
+ pthread_t tid;
+ cl_uint cookie;
+ cl_bool quit;
+ list_head enqueued_events;
+ cl_uint in_exec_status; // Same value as CL_COMPLETE, CL_SUBMITTED ...
+} _cl_command_queue_enqueue_worker;
+
+typedef _cl_command_queue_enqueue_worker *cl_command_queue_enqueue_worker;
+
/* Basically, this is a (kind-of) batch buffer */
struct _cl_command_queue {
_cl_base_object base;
+ _cl_command_queue_enqueue_worker worker;
cl_context ctx; /* Its parent context */
cl_event* barrier_events; /* Point to array of non-complete user events that block this command queue */
cl_int barrier_events_num; /* Number of Non-complete user events */
@@ -102,5 +114,14 @@ extern void cl_command_queue_insert_barrier_event(cl_command_queue queue, cl_eve
extern void cl_command_queue_remove_barrier_event(cl_command_queue queue, cl_event event);
+extern void cl_command_queue_notify(cl_command_queue queue);
+extern void cl_command_queue_enqueue_event(cl_command_queue queue, cl_event event);
+extern cl_int cl_command_queue_init_enqueue(cl_command_queue queue);
+extern void cl_command_queue_destroy_enqueue(cl_command_queue queue);
+extern cl_int cl_command_queue_wait_finish(cl_command_queue queue);
+extern cl_int cl_command_queue_wait_flush(cl_command_queue queue);
+/* Note: Must call this function with queue's lock. */
+extern cl_event *cl_command_queue_record_in_queue_events(cl_command_queue queue, cl_uint *list_num);
+
#endif /* __CL_COMMAND_QUEUE_H__ */