Browse Source

Fix disabling asynchronous copy for any_to_any. Instead of modifying the copy structure, test the flag before invoking the functions.

Samuel Thibault 12 years ago
parent
commit
ed1bcb3d3a

+ 1 - 1
examples/filters/custom_mf/custom_interface.c

@@ -46,7 +46,7 @@ static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node,
 				    cl_event *event);
 #endif /* !STARPU_USE_OPENCL */
 
-static struct starpu_data_copy_methods custom_copy_data_methods_s =
+static const struct starpu_data_copy_methods custom_copy_data_methods_s =
 {
 	.ram_to_ram = NULL,
 #ifdef STARPU_USE_CUDA

+ 1 - 1
examples/interface/complex_interface.c

@@ -265,7 +265,7 @@ static int copy_opencl_to_ram(void *src_interface, unsigned src_node, void *dst_
 }
 #endif
 
-static struct starpu_data_copy_methods complex_copy_methods =
+static const struct starpu_data_copy_methods complex_copy_methods =
 {
 #ifdef STARPU_USE_CUDA
 	.ram_to_cuda = copy_ram_to_cuda,

+ 1 - 1
include/starpu_data_interfaces.h

@@ -104,7 +104,7 @@ struct starpu_data_interface_ops
 	/* Free data of the interface on a given node. */
 	void (*free_data_on_node)(void *data_interface, unsigned node);
 	/* ram/cuda/opencl synchronous and asynchronous transfer methods */
-	struct starpu_data_copy_methods *copy_methods;
+	const struct starpu_data_copy_methods *copy_methods;
 	/* Return the current pointer (if any) for the handle on the given node. */
 	void * (*handle_to_pointer)(starpu_data_handle_t handle, unsigned node);
 	/* Return an estimation of the size of data, for performance models */

+ 12 - 6
src/datawizard/copy_driver.c

@@ -145,7 +145,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 #if !defined(HAVE_CUDA_MEMCPY_PEER)
 		STARPU_ASSERT(_starpu_memory_node_get_local_key() == src_node);
 #endif
-		if (!req || !(copy_methods->cuda_to_ram_async || copy_methods->any_to_any))
+		if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_cuda_copy_disabled() ||
+				!(copy_methods->cuda_to_ram_async || copy_methods->any_to_any))
 		{
 			/* this is not associated to a request so it's synchronous */
 			STARPU_ASSERT(copy_methods->cuda_to_ram);
@@ -176,7 +177,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 #if !defined(HAVE_CUDA_MEMCPY_PEER)
 		STARPU_ASSERT(_starpu_memory_node_get_local_key() == dst_node);
 #endif
-		if (!req || !(copy_methods->ram_to_cuda_async || copy_methods->any_to_any))
+		if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_cuda_copy_disabled() ||
+				!(copy_methods->ram_to_cuda_async || copy_methods->any_to_any))
 		{
 			/* this is not associated to a request so it's synchronous */
 			STARPU_ASSERT(copy_methods->ram_to_cuda);
@@ -205,7 +207,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 		break;
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CUDA_RAM,STARPU_CUDA_RAM):
 		/* CUDA - CUDA transfer */
-		if (!req || !(copy_methods->cuda_to_cuda_async || copy_methods->any_to_any))
+		if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_cuda_copy_disabled() ||
+				!(copy_methods->cuda_to_cuda_async || copy_methods->any_to_any))
 		{
 			STARPU_ASSERT(copy_methods->cuda_to_cuda);
 			/* this is not associated to a request so it's synchronous */
@@ -235,7 +238,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_OPENCL_RAM,STARPU_CPU_RAM):
 		/* OpenCL -> RAM */
 		STARPU_ASSERT(_starpu_memory_node_get_local_key() == src_node);
-		if (!req || !(copy_methods->opencl_to_ram_async || copy_methods->any_to_any))
+		if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_opencl_copy_disabled() ||
+				!(copy_methods->opencl_to_ram_async || copy_methods->any_to_any))
 		{
 			STARPU_ASSERT(copy_methods->opencl_to_ram);
 			/* this is not associated to a request so it's synchronous */
@@ -256,7 +260,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_CPU_RAM,STARPU_OPENCL_RAM):
 		/* STARPU_CPU_RAM -> STARPU_OPENCL_RAM */
 		STARPU_ASSERT(_starpu_memory_node_get_local_key() == dst_node);
-		if (!req || !(copy_methods->ram_to_opencl_async || copy_methods->any_to_any))
+		if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_opencl_copy_disabled() ||
+				!(copy_methods->ram_to_opencl_async || copy_methods->any_to_any))
 		{
 			STARPU_ASSERT(copy_methods->ram_to_opencl);
 			/* this is not associated to a request so it's synchronous */
@@ -277,7 +282,8 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_OPENCL_RAM,STARPU_OPENCL_RAM):
 		/* STARPU_OPENCL_RAM -> STARPU_OPENCL_RAM */
 		STARPU_ASSERT(_starpu_memory_node_get_local_key() == dst_node || _starpu_memory_node_get_local_key() == src_node);
-		if (!req || !(copy_methods->opencl_to_opencl_async || copy_methods->any_to_any))
+		if (!req || starpu_asynchronous_copy_disabled() || starpu_asynchronous_opencl_copy_disabled() ||
+				!(copy_methods->opencl_to_opencl_async || copy_methods->any_to_any))
 		{
 			STARPU_ASSERT(copy_methods->opencl_to_opencl);
 			/* this is not associated to a request so it's synchronous */

+ 1 - 1
src/datawizard/interfaces/bcsr_interface.c

@@ -33,7 +33,7 @@
 
 static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *async_data);
 
-static struct starpu_data_copy_methods bcsr_copy_data_methods_s =
+static const struct starpu_data_copy_methods bcsr_copy_data_methods_s =
 {
 	.any_to_any = copy_any_to_any,
 };

+ 1 - 1
src/datawizard/interfaces/block_interface.c

@@ -44,7 +44,7 @@ static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node STARP
 static int copy_opencl_to_opencl_async(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, cl_event *event);
 #endif
 
-static struct starpu_data_copy_methods block_copy_data_methods_s =
+static const struct starpu_data_copy_methods block_copy_data_methods_s =
 {
 	.ram_to_ram = copy_ram_to_ram,
 #ifdef STARPU_USE_CUDA

+ 1 - 1
src/datawizard/interfaces/coo_interface.c

@@ -57,7 +57,7 @@ copy_any_to_any(void *src_interface, unsigned src_node,
 	return ret;
 }
 
-static struct starpu_data_copy_methods coo_copy_data_methods =
+static const struct starpu_data_copy_methods coo_copy_data_methods =
 {
 	.any_to_any          = copy_any_to_any,
 };

+ 1 - 1
src/datawizard/interfaces/csr_interface.c

@@ -30,7 +30,7 @@
 
 static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *async_data);
 
-static struct starpu_data_copy_methods csr_copy_data_methods_s =
+static const struct starpu_data_copy_methods csr_copy_data_methods_s =
 {
 	.any_to_any = copy_any_to_any,
 };

+ 0 - 35
src/datawizard/interfaces/data_interface.c

@@ -290,41 +290,6 @@ void starpu_data_register(starpu_data_handle_t *handleptr, unsigned home_node,
 	STARPU_ASSERT(handleptr);
 	*handleptr = handle;
 
-	int asynchronous_copy_disabled = starpu_asynchronous_copy_disabled();
-	if (STARPU_UNLIKELY(asynchronous_copy_disabled))
-	{
-#ifdef STARPU_USE_CUDA
-		ops->copy_methods->ram_to_cuda_async = NULL;
-		ops->copy_methods->cuda_to_ram_async = NULL;
-		ops->copy_methods->cuda_to_cuda_async = NULL;
-#endif
-#ifdef STARPU_USE_OPENCL
-		ops->copy_methods->ram_to_opencl_async = NULL;
-		ops->copy_methods->opencl_to_ram_async = NULL;
-		ops->copy_methods->opencl_to_opencl_async = NULL;
-#endif
-	}
-
-#ifdef STARPU_USE_CUDA
-	int asynchronous_cuda_copy_disabled = starpu_asynchronous_cuda_copy_disabled();
-	if (STARPU_UNLIKELY(asynchronous_cuda_copy_disabled))
-	{
-		ops->copy_methods->ram_to_cuda_async = NULL;
-		ops->copy_methods->cuda_to_ram_async = NULL;
-		ops->copy_methods->cuda_to_cuda_async = NULL;
-	}
-#endif
-
-#ifdef STARPU_USE_OPENCL
-	int asynchronous_opencl_copy_disabled = starpu_asynchronous_opencl_copy_disabled();
-	if (STARPU_UNLIKELY(asynchronous_opencl_copy_disabled))
-	{
-		ops->copy_methods->ram_to_opencl_async = NULL;
-		ops->copy_methods->opencl_to_ram_async = NULL;
-		ops->copy_methods->opencl_to_opencl_async = NULL;
-	}
-#endif
-
 	/* fill the interface fields with the appropriate method */
 	STARPU_ASSERT(ops->register_data_handle);
 	ops->register_data_handle(handle, home_node, data_interface);

+ 1 - 1
src/datawizard/interfaces/matrix_interface.c

@@ -48,7 +48,7 @@ static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node STARP
 static int copy_opencl_to_opencl_async(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, cl_event *event);
 #endif
 
-static struct starpu_data_copy_methods matrix_copy_data_methods_s =
+static const struct starpu_data_copy_methods matrix_copy_data_methods_s =
 {
 	.ram_to_ram = copy_ram_to_ram,
 #ifdef STARPU_USE_CUDA

+ 1 - 1
src/datawizard/interfaces/multiformat_interface.c

@@ -42,7 +42,7 @@ static int copy_ram_to_opencl_async(void *src_interface, unsigned src_node STARP
 static int copy_opencl_to_ram_async(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node, cl_event *event);
 #endif
 
-static struct starpu_data_copy_methods multiformat_copy_data_methods_s =
+static const struct starpu_data_copy_methods multiformat_copy_data_methods_s =
 {
 	.ram_to_ram = copy_ram_to_ram,
 #ifdef STARPU_USE_CUDA

+ 1 - 1
src/datawizard/interfaces/variable_interface.c

@@ -27,7 +27,7 @@
 
 static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *async_data);
 
-static struct starpu_data_copy_methods variable_copy_data_methods_s =
+static const struct starpu_data_copy_methods variable_copy_data_methods_s =
 {
 	.any_to_any = copy_any_to_any,
 };

+ 1 - 1
src/datawizard/interfaces/vector_interface.c

@@ -27,7 +27,7 @@
 
 static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *async_data);
 
-static struct starpu_data_copy_methods vector_copy_data_methods_s =
+static const struct starpu_data_copy_methods vector_copy_data_methods_s =
 {
 	.any_to_any = copy_any_to_any,
 };

+ 1 - 1
src/datawizard/interfaces/void_interface.c

@@ -27,7 +27,7 @@
 
 static int dummy_copy(void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, void *async_data);
 
-static struct starpu_data_copy_methods void_copy_data_methods_s =
+static const struct starpu_data_copy_methods void_copy_data_methods_s =
 {
 	.any_to_any = dummy_copy,
 };