Ver código fonte

Provide helpers to get a direct access to the current context and the current
command queue when running code from a thread controling an OpenCL device.

Cédric Augonnet 14 anos atrás
pai
commit
f60e74d9e8
2 arquivos alterados com 16 adições e 0 exclusões
  1. 2 0
      include/starpu_opencl.h
  2. 14 0
      src/drivers/opencl/driver_opencl.c

+ 2 - 0
include/starpu_opencl.h

@@ -181,6 +181,8 @@ struct starpu_opencl_program {
 void starpu_opencl_get_context(int devid, cl_context *context);
 void starpu_opencl_get_device(int devid, cl_device_id *device);
 void starpu_opencl_get_queue(int devid, cl_command_queue *queue);
+void starpu_opencl_get_current_context(cl_context *context);
+void starpu_opencl_get_current_queue(cl_command_queue *queue);
 
 int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct starpu_opencl_program *opencl_programs);
 int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, struct starpu_opencl_program *opencl_programs);

+ 14 - 0
src/drivers/opencl/driver_opencl.c

@@ -94,6 +94,20 @@ void starpu_opencl_get_queue(int devid, cl_command_queue *queue)
         *queue = queues[devid];
 }
 
+void starpu_opencl_get_current_queue(cl_command_queue *queue)
+{
+	struct starpu_worker_s *worker = _starpu_get_local_worker_key();
+	STARPU_ASSERT(queue);
+        *queue = queues[worker->devid];
+}
+
+void starpu_opencl_get_current_context(cl_context *context)
+{
+	struct starpu_worker_s *worker = _starpu_get_local_worker_key();
+	STARPU_ASSERT(context);
+        *context = contexts[worker->devid];
+}
+
 cl_int _starpu_opencl_init_context(int devid)
 {
 	cl_int err;