summaryrefslogtreecommitdiff
path: root/src/cl_event.h
diff options
context:
space:
mode:
authorYang Rong <rong.r.yang@intel.com>2013-08-12 16:07:20 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-08-12 16:36:06 +0800
commit645a3895a01501aea55b99e5c87e9a25519454c6 (patch)
treedb2d8bce6b93833f1d5bad94854f79ab0958479c /src/cl_event.h
parentaaf25db296089f5ccde26713b0d3d3ab09b46bcc (diff)
downloadbeignet-645a3895a01501aea55b99e5c87e9a25519454c6.tar.gz
Add openCL event support.
Now use the defer execute to wait events. If there is no user event waited, then using wait rendering to wait GPU event complete and call the enqueue api immediately. If there is the user events waited, then should prepare the the enqueue data, and resume the enqueue when all user events that waited complete. The achieve these, add the enqueue callback to user event, and add the all user event and other wait event list to enqueue callback. When set user event to complete, check all enqueue callbacks wait this event. Now, clEnqueueMark/clEnqueueBarrier still not impletement, and clEnqueueMapBuffer /clEnqueueMapImage is not consistency with spec. Signed-off-by: Yang Rong <rong.r.yang@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src/cl_event.h')
-rw-r--r--src/cl_event.h66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/cl_event.h b/src/cl_event.h
index 23378e88..c921cb2a 100644
--- a/src/cl_event.h
+++ b/src/cl_event.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
@@ -20,9 +20,73 @@
#ifndef __CL_EVENT_H__
#define __CL_EVENT_H__
+#include <semaphore.h>
+
+#include "cl_enqueue.h"
+#include "cl_internals.h"
+#include "cl_driver.h"
+#include "CL/cl.h"
+
+#define CL_ENQUEUE_EXECUTE_IMM 0
+#define CL_ENQUEUE_EXECUTE_DEFER 1
+
+typedef struct _user_event {
+ cl_event event; /* The user event */
+ struct _user_event* next; /* Next user event in list */
+} user_event;
+
+typedef struct _enqueue_callback {
+ cl_event event; /* The event relative this enqueue callback */
+ enqueue_data data; /* Hold all enqueue callback's infomation */
+ cl_uint num_events; /* num events in wait list */
+ const cl_event* wait_list; /* All event wait list this callback wait on */
+ user_event* wait_user_events; /* The head of user event list the callback wait on */
+ struct _enqueue_callback* next; /* The next enqueue callback in wait list */
+} enqueue_callback;
+
+typedef void (CL_CALLBACK *EVENT_NOTIFY)(cl_event event, cl_int event_command_exec_status, void *user_data);
+
+typedef struct _user_callback {
+ cl_int status; /* The execution status */
+ cl_bool executed; /* Indicat the callback function been called or not */
+ EVENT_NOTIFY pfn_notify; /* Callback function */
+ void* user_data; /* Callback user data */
+ struct _user_callback* next; /* Next event callback in list */
+} user_callback;
+
struct _cl_event {
DEFINE_ICD(dispatch)
+ uint64_t magic; /* To identify it as a sampler object */
+ volatile int ref_n; /* We reference count this object */
+ cl_context ctx; /* The context associated with event */
+ cl_event prev, next; /* We chain the memory buffers together */
+ cl_command_queue queue; /* The command queue associated with event */
+ cl_command_type type; /* The command type associated with event */
+ cl_int status; /* The execution status */
+ cl_gpgpu_event gpgpu_event; /* The event object communicate with hardware */
+ user_callback* user_cb; /* The event callback functions */
+ enqueue_callback* enqueue_cb; /* This event's enqueue */
+ enqueue_callback* waits_head; /* The head of enqueues list wait on this event */
+ cl_bool emplict; /* Identify this event whether created by api emplict*/
};
+/* Create a new event object */
+cl_event cl_event_new(cl_context, cl_command_queue, cl_command_type, cl_bool);
+/* Unref the object and delete it if no more reference on it */
+void cl_event_delete(cl_event);
+/* Add one more reference to this object */
+void cl_event_add_ref(cl_event);
+/* Rigister a user callback function for specific commond execution status */
+cl_int cl_event_set_callback(cl_event, cl_int, EVENT_NOTIFY, void *);
+/* Check events wait list for enqueue commonds */
+cl_int cl_event_check_waitlist(cl_uint, const cl_event *, cl_event *, cl_context);
+/* Wait the all events in wait list complete */
+cl_int cl_event_wait_events(cl_uint, const cl_event *);
+/* New a enqueue suspend task */
+void cl_event_new_enqueue_callback(cl_event, enqueue_data *, cl_uint, const cl_event *);
+/* Set the event status and call all callbacks */
+void cl_event_set_status(cl_event, cl_int);
+/* Check and update event status */
+void cl_event_update_status(cl_event);
#endif /* __CL_EVENT_H__ */