summaryrefslogtreecommitdiff
path: root/src/cl_api.c
diff options
context:
space:
mode:
authorJunyan He <junyan.he@linux.intel.com>2014-06-11 09:33:36 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-06-13 17:20:25 +0800
commit7f6a3d69473d60147eb7d24dba4409e34d20b233 (patch)
tree103c8ef08ea740aa77980cb86ba7689921854215 /src/cl_api.c
parenta93733abb4ed1c913ca2acb2d35532bf80846941 (diff)
Implement the clEnqueueMigrateMemObjects API
So far, we just support 1 device and no subdevices. So all the command queues should belong to the small context. There is no need to migrate the mem objects from one subcontext to another by now. We just do the checks and fill the event. Signed-off-by: Junyan He <junyan.he@linux.intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src/cl_api.c')
-rw-r--r--src/cl_api.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cl_api.c b/src/cl_api.c
index 25b5870f..96c102c7 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -2681,6 +2681,58 @@ error:
}
cl_int
+clEnqueueMigrateMemObjects(cl_command_queue command_queue,
+ cl_uint num_mem_objects,
+ const cl_mem * mem_objects,
+ cl_mem_migration_flags flags,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event)
+{
+ /* So far, we just support 1 device and no subdevice. So all the command queues
+ belong to the small context. There is no need to migrate the mem objects by now. */
+ cl_int err = CL_SUCCESS;
+ cl_uint i = 0;
+ enqueue_data *data, defer_enqueue_data = { 0 };
+
+ if (!flags & CL_MIGRATE_MEM_OBJECT_HOST)
+ CHECK_QUEUE(command_queue);
+
+ if (num_mem_objects == 0 || mem_objects == NULL) {
+ err = CL_INVALID_VALUE;
+ goto error;
+ }
+
+ if (flags && flags & ~(CL_MIGRATE_MEM_OBJECT_HOST |
+ CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED)) {
+ err = CL_INVALID_VALUE;
+ goto error;
+ }
+
+ for (i = 0; i < num_mem_objects; i++) {
+ CHECK_MEM(mem_objects[i]);
+ if (mem_objects[i]->ctx != command_queue->ctx) {
+ err = CL_INVALID_CONTEXT;
+ goto error;
+ }
+ }
+
+ /* really nothing to do, fill the event. */
+ TRY(cl_event_check_waitlist, num_events_in_wait_list, event_wait_list, event, command_queue->ctx);
+ data = &defer_enqueue_data;
+ data->type = EnqueueMigrateMemObj;
+
+ if(handle_events(command_queue, num_events_in_wait_list, event_wait_list,
+ event, data, CL_COMMAND_READ_BUFFER) == CL_ENQUEUE_EXECUTE_IMM) {
+ err = cl_enqueue_handle(event ? *event : NULL, data);
+ if(event) cl_event_set_status(*event, CL_COMPLETE);
+ }
+
+error:
+ return err;
+}
+
+cl_int
clEnqueueNDRangeKernel(cl_command_queue command_queue,
cl_kernel kernel,
cl_uint work_dim,