Forráskód Böngészése

src/core/perfmodel/perfmodel_bus.c: only initialise OpenCL context if it is not already done by starpu_init

Nathalie Furmento 13 éve
szülő
commit
7b7121a3bd
1 módosított fájl, 10 hozzáadás és 3 törlés
  1. 10 3
      src/core/perfmodel/perfmodel_bus.c

+ 10 - 3
src/core/perfmodel/perfmodel_bus.c

@@ -237,12 +237,18 @@ static void measure_bandwidth_between_host_and_dev_on_cpu_with_opencl(int dev, i
         cl_command_queue queue;
         cl_int err=0;
 	size_t size = SIZE;
+	int not_initialized;
 
         struct _starpu_machine_config *config = _starpu_get_machine_config();
 	_starpu_bind_thread_on_cpu(config, cpu);
 
-	/* Initialize OpenCL context on the device */
-        _starpu_opencl_init_context(dev);
+	/* Is the context already initialised ? */
+        starpu_opencl_get_context(dev, &context);
+	not_initialized = (context == NULL);
+	if (not_initialized == 1)
+	     _starpu_opencl_init_context(dev);
+
+	/* Get context and queue */
         starpu_opencl_get_context(dev, &context);
         starpu_opencl_get_queue(dev, &queue);
 
@@ -319,7 +325,8 @@ static void measure_bandwidth_between_host_and_dev_on_cpu_with_opencl(int dev, i
 	free(h_buffer);
 
 	/* Uninitiliaze OpenCL context on the device */
-        _starpu_opencl_deinit_context(dev);
+	if (not_initialized == 1)
+	     _starpu_opencl_deinit_context(dev);
 }
 #endif