summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunyan He <junyan.he@intel.com>2016-04-25 15:20:48 +0800
committerJunyan He <junyan.he@intel.com>2016-04-25 15:20:48 +0800
commitf0daeb7a225316cae4c63125db2a1421c72841a0 (patch)
tree8c76c4db18196a09ba2303747915f665e1706cc3
parentd8941d72b6d4476ff2fed76ac03b801044610405 (diff)
move worker to cl
-rw-r--r--include/cl_command_queue.h11
-rw-r--r--libclapi/CMakeLists.txt1
-rw-r--r--libclapi/cl_enqueue.c66
3 files changed, 78 insertions, 0 deletions
diff --git a/include/cl_command_queue.h b/include/cl_command_queue.h
index 88a9a12a..1cc29904 100644
--- a/include/cl_command_queue.h
+++ b/include/cl_command_queue.h
@@ -36,6 +36,17 @@ typedef struct _cl_command_queue {
cl_command_queue_properties props; /* Queue properties */
cl_command_queue prev, next; /* We chain the command queues together */
void* pdata; /* The private data for driver. */
+ void* worker; /* The worker thread related info. */
} _cl_command_queue;
+/* Represent one enqueued work item, eg, EnqueueNDRange. */
+typedef struct _cl_command_queue_work_item {
+ struct _cl_command_queue_work_item *prev, *next;
+ cl_event event; // The event represent this work.
+ cl_event* depend_events;
+ cl_uint depend_event_num;
+ void* content;
+} _cl_command_queue_work_item;
+typedef _cl_command_queue_work_item* cl_command_queue_work_item;
+
#endif /* __CL_COMMAND_QUEUE_H__ */
diff --git a/libclapi/CMakeLists.txt b/libclapi/CMakeLists.txt
index 79da0248..a26f4264 100644
--- a/libclapi/CMakeLists.txt
+++ b/libclapi/CMakeLists.txt
@@ -16,6 +16,7 @@ set(LIBCLAPI_SRC
cl_extension.c
cl_event.c
cl_mutex.c
+ cl_enqueue.c
)
add_library(clapi SHARED ${LIBCLAPI_SRC})
diff --git a/libclapi/cl_enqueue.c b/libclapi/cl_enqueue.c
new file mode 100644
index 00000000..018b263f
--- /dev/null
+++ b/libclapi/cl_enqueue.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <stdlib.h>
+#include <assert.h>
+#include <malloc.h>
+#include <pthread.h>
+#include <string.h>
+#include "cl_mutex.h"
+#include "cl_alloc.h"
+#include "cl_internals.h"
+#include "cl_command_queue.h"
+
+typedef struct _cl_command_queue_worker {
+ pthread_t tid;
+ pthread_cond_t cond;
+ pthread_mutex_t mutex;
+ cl_uint cookie;
+ cl_bool quit;
+ cl_bool in_exec;
+ cl_command_queue_work_item* work_items;
+ cl_int work_item_num;
+} _cl_command_queue_worker;
+typedef _cl_command_queue_worker* cl_command_queue_worker;
+
+LOCAL cl_int cl_command_queue_worker_init(cl_command_queue queue)
+{
+ cl_command_queue_worker worker = NULL;
+ assert(queue->worker == NULL);
+
+ worker = CL_CALLOC(1, sizeof(_cl_command_queue_worker));
+ if (worker == NULL)
+ return CL_OUT_OF_HOST_MEMORY;
+
+ worker->cookie = 1; // start from 1
+ worker->quit = CL_FALSE;
+ worker->in_exec = CL_FALSE;
+ worker->work_items = NULL;
+ worker->work_item_num = 0;
+}
+
+LOCAL void cl_command_queue_worker_destroy(cl_command_queue queue)
+{
+
+
+}
+
+static void *worker_thread_function(void *Arg)
+{
+
+}
+