Преглед на файлове

src: fix code with simgrid

Nathalie Furmento преди 6 години
родител
ревизия
d92c77975f
променени са 3 файла, в които са добавени 96 реда и са изтрити 31 реда
  1. 32 0
      src/drivers/cuda/driver_cuda.c
  2. 63 30
      src/drivers/opencl/driver_opencl.c
  3. 1 1
      src/drivers/opencl/driver_opencl.h

+ 32 - 0
src/drivers/cuda/driver_cuda.c

@@ -1560,6 +1560,37 @@ struct _starpu_driver_ops _starpu_driver_cuda_ops =
 	.deinit = _starpu_cuda_driver_deinit_from_worker
 };
 
+#ifdef STARPU_SIMGRID
+struct _starpu_node_ops _starpu_driver_cuda_node_ops =
+{
+	.copy_data_to[STARPU_UNUSED] = NULL,
+	.copy_data_to[STARPU_CPU_RAM] = NULL,
+	.copy_data_to[STARPU_CUDA_RAM] = NULL,
+	.copy_data_to[STARPU_OPENCL_RAM] = NULL,
+	.copy_data_to[STARPU_DISK_RAM] = NULL,
+	.copy_data_to[STARPU_MIC_RAM] = NULL,
+	.copy_data_to[STARPU_SCC_RAM] = NULL,
+	.copy_data_to[STARPU_SCC_SHM] = NULL,
+	.copy_data_to[STARPU_MPI_MS_RAM] = NULL,
+
+	.copy_interface_to[STARPU_UNUSED] = NULL,
+	.copy_interface_to[STARPU_CPU_RAM] = NULL,
+	.copy_interface_to[STARPU_CUDA_RAM] = NULL,
+	.copy_interface_to[STARPU_OPENCL_RAM] = NULL,
+	.copy_interface_to[STARPU_DISK_RAM] = NULL,
+	.copy_interface_to[STARPU_MIC_RAM] = NULL,
+	.copy_interface_to[STARPU_SCC_RAM] = NULL,
+	.copy_interface_to[STARPU_SCC_SHM] = NULL,
+	.copy_interface_to[STARPU_MPI_MS_RAM] = NULL,
+
+	.wait_request_completion = NULL,
+	.test_request_completion = NULL,
+	.is_direct_access_supported = _starpu_cuda_is_direct_access_supported,
+	.malloc_on_node = _starpu_cuda_malloc_on_node,
+	.free_on_node = _starpu_cuda_free_on_node,
+	.name = "cuda driver"
+};
+#else
 struct _starpu_node_ops _starpu_driver_cuda_node_ops =
 {
 	.copy_data_to[STARPU_UNUSED] = NULL,
@@ -1589,3 +1620,4 @@ struct _starpu_node_ops _starpu_driver_cuda_node_ops =
 	.free_on_node = _starpu_cuda_free_on_node,
 	.name = "cuda driver"
 };
+#endif

+ 63 - 30
src/drivers/opencl/driver_opencl.c

@@ -1094,6 +1094,29 @@ static void _starpu_opencl_execute_job(struct starpu_task *task, struct _starpu_
 }
 
 #ifdef STARPU_USE_OPENCL
+int _starpu_run_opencl(struct _starpu_worker *workerarg)
+{
+	_STARPU_DEBUG("Running OpenCL %u from the application\n", workerarg->devid);
+
+	workerarg->set = NULL;
+	workerarg->worker_is_initialized = 0;
+
+	/* Let's go ! */
+	_starpu_opencl_worker(workerarg);
+
+	return 0;
+}
+
+struct _starpu_driver_ops _starpu_driver_opencl_ops =
+{
+	.init = _starpu_opencl_driver_init,
+	.run = _starpu_run_opencl,
+	.run_once = _starpu_opencl_driver_run_once,
+	.deinit = _starpu_opencl_driver_deinit
+};
+#endif
+
+#if defined(STARPU_USE_OPENCL)
 unsigned _starpu_opencl_test_request_completion(struct _starpu_async_channel *async_channel)
 {
 	cl_int event_status;
@@ -1125,27 +1148,6 @@ void _starpu_opencl_wait_request_completion(struct _starpu_async_channel *async_
 		STARPU_OPENCL_REPORT_ERROR(err);
 }
 
-int _starpu_run_opencl(struct _starpu_worker *workerarg)
-{
-	_STARPU_DEBUG("Running OpenCL %u from the application\n", workerarg->devid);
-
-	workerarg->set = NULL;
-	workerarg->worker_is_initialized = 0;
-
-	/* Let's go ! */
-	_starpu_opencl_worker(workerarg);
-
-	return 0;
-}
-
-struct _starpu_driver_ops _starpu_driver_opencl_ops =
-{
-	.init = _starpu_opencl_driver_init,
-	.run = _starpu_run_opencl,
-	.run_once = _starpu_opencl_driver_run_once,
-	.deinit = _starpu_opencl_driver_deinit
-};
-
 int _starpu_opencl_copy_data_from_opencl_to_opencl(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req)
 {
 	int src_kind = starpu_node_get_kind(src_node);
@@ -1280,15 +1282,7 @@ int _starpu_opencl_copy_interface_from_cpu_to_opencl(uintptr_t src, size_t src_o
 					     size,
 					     &async_channel->event.opencl_event);
 }
-
-#endif /* STARPU_USE_OPENCL */
-
-int _starpu_opencl_is_direct_access_supported(unsigned node, unsigned handling_node)
-{
-	(void)node;
-	(void)handling_node;
-	return 0;
-}
+#endif
 
 uintptr_t _starpu_opencl_malloc_on_node(unsigned dst_node, size_t size, int flags)
 {
@@ -1342,6 +1336,44 @@ void _starpu_opencl_free_on_node(unsigned dst_node, uintptr_t addr, size_t size,
 #endif
 }
 
+int _starpu_opencl_is_direct_access_supported(unsigned node, unsigned handling_node)
+{
+	(void)node;
+	(void)handling_node;
+	return 0;
+}
+
+#ifdef STARPU_SIMGRID
+struct _starpu_node_ops _starpu_driver_opencl_node_ops =
+{
+	.copy_data_to[STARPU_UNUSED] = NULL,
+	.copy_data_to[STARPU_CPU_RAM] = NULL,
+	.copy_data_to[STARPU_CUDA_RAM] = NULL,
+	.copy_data_to[STARPU_OPENCL_RAM] = NULL,
+	.copy_data_to[STARPU_DISK_RAM] = NULL,
+	.copy_data_to[STARPU_MIC_RAM] = NULL,
+	.copy_data_to[STARPU_SCC_RAM] = NULL,
+	.copy_data_to[STARPU_SCC_SHM] = NULL,
+	.copy_data_to[STARPU_MPI_MS_RAM] = NULL,
+
+	.copy_interface_to[STARPU_UNUSED] = NULL,
+	.copy_interface_to[STARPU_CPU_RAM] = NULL,
+	.copy_interface_to[STARPU_CUDA_RAM] = NULL,
+	.copy_interface_to[STARPU_OPENCL_RAM] = NULL,
+	.copy_interface_to[STARPU_DISK_RAM] = NULL,
+	.copy_interface_to[STARPU_MIC_RAM] = NULL,
+	.copy_interface_to[STARPU_SCC_RAM] = NULL,
+	.copy_interface_to[STARPU_SCC_SHM] = NULL,
+	.copy_interface_to[STARPU_MPI_MS_RAM] = NULL,
+
+	.wait_request_completion = NULL,
+	.test_request_completion = NULL,
+	.is_direct_access_supported = _starpu_opencl_is_direct_access_supported,
+	.malloc_on_node = _starpu_opencl_malloc_on_node,
+	.free_on_node = _starpu_opencl_free_on_node,
+	.name = "opencl driver"
+};
+#else
 struct _starpu_node_ops _starpu_driver_opencl_node_ops =
 {
 	.copy_data_to[STARPU_UNUSED] = NULL,
@@ -1371,3 +1403,4 @@ struct _starpu_node_ops _starpu_driver_opencl_node_ops =
 	.free_on_node = _starpu_opencl_free_on_node,
 	.name = "opencl driver"
 };
+#endif

+ 1 - 1
src/drivers/opencl/driver_opencl.h

@@ -43,12 +43,12 @@ void _starpu_opencl_discover_devices(struct _starpu_machine_config *config);
 unsigned _starpu_opencl_get_device_count(void);
 void _starpu_opencl_init(void);
 void *_starpu_opencl_worker(void *);
+extern struct _starpu_node_ops _starpu_driver_opencl_node_ops;
 #else
 #define _starpu_opencl_discover_devices(config) ((void) (config))
 #endif
 
 #ifdef STARPU_USE_OPENCL
-extern struct _starpu_node_ops _starpu_driver_opencl_node_ops;
 extern struct _starpu_driver_ops _starpu_driver_opencl_ops;
 extern char *_starpu_opencl_program_dir;