diff options
author | Junyan He <junyan.he@intel.com> | 2016-04-26 16:22:16 +0800 |
---|---|---|
committer | Junyan He <junyan.he@intel.com> | 2016-04-26 16:22:16 +0800 |
commit | ab96a06791a21afb1d3d37f71499272bd36a4021 (patch) | |
tree | 550e5ac6360ac60cfc0cc549489947ee123ec18a | |
parent | b9ab4ae79f7dcbfe8c891f8dfe04eeda10b6ca84 (diff) |
add flush
-rw-r--r-- | libclapi/cl_command_queue.c | 2 | ||||
-rw-r--r-- | libclapi/cl_enqueue.c | 7 | ||||
-rw-r--r-- | libclapi/cl_internals.h | 1 |
3 files changed, 6 insertions, 4 deletions
diff --git a/libclapi/cl_command_queue.c b/libclapi/cl_command_queue.c index d529f79c..f0e7ecf2 100644 --- a/libclapi/cl_command_queue.c +++ b/libclapi/cl_command_queue.c @@ -145,7 +145,7 @@ LOCAL cl_int cl_retain_command_queue(cl_command_queue queue) static cl_int cl_flush(cl_command_queue queue) { cl_int err = CL_SUCCESS; - err = queue->device->driver->flush_command_queue(queue); + err = cl_enqueue_wait_for_flush(queue); return err; } diff --git a/libclapi/cl_enqueue.c b/libclapi/cl_enqueue.c index 8d4470a5..3874b927 100644 --- a/libclapi/cl_enqueue.c +++ b/libclapi/cl_enqueue.c @@ -342,7 +342,7 @@ LOCAL void cl_command_queue_worker_destroy(cl_command_queue queue) queue->worker = NULL; } -LOCAL void cl_enqueue_wait_for_flush(cl_command_queue queue) +LOCAL cl_int cl_enqueue_wait_for_flush(cl_command_queue queue) { cl_command_queue_worker worker = NULL; cl_command_queue_work_item it, start_it; @@ -354,7 +354,7 @@ LOCAL void cl_enqueue_wait_for_flush(cl_command_queue queue) if (worker->quit) { // already destroy the queue? CL_MUTEX_UNLOCK(&worker->mutex); - return; + return CL_INVALID_COMMAND_QUEUE; } while (worker->quit == CL_FALSE) { @@ -363,7 +363,7 @@ LOCAL void cl_enqueue_wait_for_flush(cl_command_queue queue) start_it = it; while (it) { - if (it->status > CL_SUBMITTED) { + if (it->status > CL_SUBMITTED) {// Need not to lock, ready has been deleted from list need_to_wait = CL_TRUE; break; } @@ -381,5 +381,6 @@ LOCAL void cl_enqueue_wait_for_flush(cl_command_queue queue) } CL_MUTEX_UNLOCK(&worker->mutex); + return CL_SUCCESS; } diff --git a/libclapi/cl_internals.h b/libclapi/cl_internals.h index eaa728dd..70662f90 100644 --- a/libclapi/cl_internals.h +++ b/libclapi/cl_internals.h @@ -493,5 +493,6 @@ extern cl_command_queue_work_item cl_enqueue_create_work_item(cl_command_queue q extern void cl_enqueue_destroy_work_item(cl_command_queue queue, cl_command_queue_work_item item); extern cl_int cl_command_queue_worker_init(cl_command_queue queue); extern void cl_command_queue_worker_destroy(cl_command_queue queue); +extern cl_int cl_enqueue_wait_for_flush(cl_command_queue queue); #endif /* __CL_INTERNALS_H__ */ |