If event status is an Error code, the status of events wait on this event also should set to Error code.
V2: should not execute the enqueue command wait on the event whose status is error.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
typedef cl_gpgpu_event (cl_gpgpu_event_new_cb)(cl_gpgpu);
extern cl_gpgpu_event_new_cb *cl_gpgpu_event_new;
-/* new a event for a batch buffer */
+/* update the batch buffer of this event */
typedef int (cl_gpgpu_event_update_status_cb)(cl_gpgpu_event, int);
extern cl_gpgpu_event_update_status_cb *cl_gpgpu_event_update_status;
-/* new a event for a batch buffer */
+/* pending flush the batch buffer of this event */
typedef void (cl_gpgpu_event_pending_cb)(cl_gpgpu, cl_gpgpu_event);
extern cl_gpgpu_event_pending_cb *cl_gpgpu_event_pending;
-/* new a event for a batch buffer */
+/* flush the batch buffer of this event */
typedef void (cl_gpgpu_event_resume_cb)(cl_gpgpu_event);
extern cl_gpgpu_event_resume_cb *cl_gpgpu_event_resume;
-/* new a event for a batch buffer */
+/* cancel exec batch buffer of this event */
+typedef void (cl_gpgpu_event_cancel_cb)(cl_gpgpu_event);
+extern cl_gpgpu_event_cancel_cb *cl_gpgpu_event_cancel;
+
+/* delete a gpgpu event */
typedef void (cl_gpgpu_event_delete_cb)(cl_gpgpu_event);
extern cl_gpgpu_event_delete_cb *cl_gpgpu_event_delete;
LOCAL cl_gpgpu_event_update_status_cb *cl_gpgpu_event_update_status = NULL;
LOCAL cl_gpgpu_event_pending_cb *cl_gpgpu_event_pending = NULL;
LOCAL cl_gpgpu_event_resume_cb *cl_gpgpu_event_resume = NULL;
+LOCAL cl_gpgpu_event_cancel_cb *cl_gpgpu_event_cancel = NULL;
LOCAL cl_gpgpu_event_delete_cb *cl_gpgpu_event_delete = NULL;
LOCAL cl_gpgpu_event_get_exec_timestamp_cb *cl_gpgpu_event_get_exec_timestamp = NULL;
LOCAL cl_gpgpu_event_get_gpu_cur_timestamp_cb *cl_gpgpu_event_get_gpu_cur_timestamp = NULL;
if(status <= CL_COMPLETE) {
if(event->enqueue_cb) {
- cl_enqueue_handle(event, &event->enqueue_cb->data);
- if(event->gpgpu_event)
- cl_gpgpu_event_update_status(event->gpgpu_event, 1); //now set complet, need refine
+ if(status == CL_COMPLETE) {
+ cl_enqueue_handle(event, &event->enqueue_cb->data);
+ if(event->gpgpu_event)
+ cl_gpgpu_event_update_status(event->gpgpu_event, 1); //now set complet, need refine
+ } else {
+ if(event->gpgpu_event)
+ cl_gpgpu_event_cancel(event->gpgpu_event); //Error cancel the enqueue
+ }
+
event->status = status; //Change the event status after enqueue and befor unlock
pthread_mutex_unlock(&event->ctx->event_lock);
/* Call the pending operation */
evt = cb->event;
- cl_event_set_status(cb->event, CL_COMPLETE);
+ /* TODO: if this event wait on several events, one event's
+ status is error, the others is complete, what's the status
+ of this event? Can't find the description in OpenCL spec.
+ Simply update to latest finish wait event.*/
+ cl_event_set_status(cb->event, status);
if(evt->emplict == CL_FALSE) {
cl_event_delete(evt);
}
}
static void
+intel_gpgpu_event_cancel(intel_event_t *event)
+{
+ assert(event->batch); //This command have pending.
+ intel_batchbuffer_delete(event->batch);
+ event->batch = NULL;
+}
+
+static void
intel_gpgpu_event_delete(intel_event_t *event)
{
assert(event->batch == NULL); //This command must have been flushed.
cl_gpgpu_event_update_status = (cl_gpgpu_event_update_status_cb *)intel_gpgpu_event_update_status;
cl_gpgpu_event_pending = (cl_gpgpu_event_pending_cb *)intel_gpgpu_event_pending;
cl_gpgpu_event_resume = (cl_gpgpu_event_resume_cb *)intel_gpgpu_event_resume;
+ cl_gpgpu_event_cancel = (cl_gpgpu_event_cancel_cb *)intel_gpgpu_event_cancel;
cl_gpgpu_event_delete = (cl_gpgpu_event_delete_cb *)intel_gpgpu_event_delete;
cl_gpgpu_event_get_exec_timestamp = (cl_gpgpu_event_get_exec_timestamp_cb *)intel_gpgpu_event_get_exec_timestamp;
cl_gpgpu_event_get_gpu_cur_timestamp = (cl_gpgpu_event_get_gpu_cur_timestamp_cb *)intel_gpgpu_event_get_gpu_cur_timestamp;