浏览代码

- Move the functions prototypes and the structures required to create new data
interfaces into the public headers
- rename _starpu_register_data_handle into starpu_data_register
- rename struct starpu_copy_data_methods_s into struct starpu_data_copy_methods

Cédric Augonnet 15 年之前
父节点
当前提交
9a1e274278

+ 75 - 1
include/starpu_data_interfaces.h

@@ -1,6 +1,6 @@
 /*
  * StarPU
- * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,10 +20,84 @@
 #include <starpu.h>
 #include <starpu_data.h>
 
+#ifdef STARPU_USE_GORDON
+/* to get the gordon_strideSize_t data structure from gordon */
+#include <gordon.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/* The following structures are used to describe data interfaces */
+
+/* This structure contains the different methods to transfer data between the
+ * different types of memory nodes */
+struct starpu_data_copy_methods {
+	/* src type is ram */
+	int (*ram_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*ram_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*ram_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*ram_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+
+	/* src type is cuda */
+	int (*cuda_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*cuda_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*cuda_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*cuda_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+
+	/* src type is spu */
+	int (*spu_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*spu_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*spu_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*spu_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+
+	/* src type is opencl */
+	int (*opencl_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*opencl_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*opencl_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+	int (*opencl_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
+
+#ifdef STARPU_USE_CUDA
+	/* for asynchronous CUDA transfers */
+	int (*ram_to_cuda_async)(starpu_data_handle handle, uint32_t src,
+					uint32_t dst, cudaStream_t *stream);
+	int (*cuda_to_ram_async)(starpu_data_handle handle, uint32_t src,
+					uint32_t dst, cudaStream_t *stream);
+	int (*cuda_to_cuda_async)(starpu_data_handle handle, uint32_t src,
+					uint32_t dst, cudaStream_t *stream);
+#endif
+
+#ifdef STARPU_USE_OPENCL
+	/* for asynchronous OpenCL transfers */
+        int (*ram_to_opencl_async)(starpu_data_handle handle, uint32_t src, uint32_t dst, cl_event *event);
+	int (*opencl_to_ram_async)(starpu_data_handle handle, uint32_t src, uint32_t dst, cl_event *event);
+	int (*opencl_to_opencl_async)(starpu_data_handle handle, uint32_t src, uint32_t dst, cl_event *event);
+#endif
+};
+
+struct starpu_data_interface_ops_t {
+	void (*register_data_handle)(starpu_data_handle handle,
+					uint32_t home_node, void *interface);
+	size_t (*allocate_data_on_node)(void *interface, uint32_t node);
+	void (*free_data_on_node)(void *interface, uint32_t node);
+	const struct starpu_data_copy_methods *copy_methods;
+	size_t (*get_size)(starpu_data_handle handle);
+	uint32_t (*footprint)(starpu_data_handle handle);
+	int (*compare)(void *interface_a, void *interface_b);
+	void (*display)(starpu_data_handle handle, FILE *f);
+#ifdef STARPU_USE_GORDON
+	int (*convert_to_gordon)(void *interface, uint64_t *ptr, gordon_strideSize_t *ss); 
+#endif
+	/* an identifier that is unique to each interface */
+	unsigned interfaceid;
+	size_t interface_size;
+};
+
+void starpu_data_register(starpu_data_handle *handleptr, uint32_t home_node,
+				void *interface,
+				struct starpu_data_interface_ops_t *ops);
+
 /* "node" means memory node: 0 for main RAM, then 1, 2, etc. for various GPUs,
  * etc.
  *

+ 1 - 1
src/datawizard/copy_driver.c

@@ -82,7 +82,7 @@ static int copy_data_1_to_1_generic(starpu_data_handle handle, uint32_t src_node
 
 	//ret = handle->ops->copy_data_1_to_1(handle, src_node, dst_node);
 
-	const struct starpu_copy_data_methods_s *copy_methods = handle->ops->copy_methods;
+	const struct starpu_data_copy_methods *copy_methods = handle->ops->copy_methods;
 
 	starpu_node_kind src_kind = _starpu_get_node_kind(src_node);
 	starpu_node_kind dst_kind = _starpu_get_node_kind(dst_node);

+ 0 - 43
src/datawizard/copy_driver.h

@@ -46,49 +46,6 @@ typedef union {
 #endif
 } starpu_async_channel;
 
-struct starpu_copy_data_methods_s {
-	/* src type is ram */
-	int (*ram_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*ram_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*ram_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*ram_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-
-	/* src type is cuda */
-	int (*cuda_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*cuda_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*cuda_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*cuda_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-
-	/* src type is spu */
-	int (*spu_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*spu_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*spu_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*spu_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-
-	/* src type is opencl */
-	int (*opencl_to_ram)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*opencl_to_cuda)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*opencl_to_opencl)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-	int (*opencl_to_spu)(starpu_data_handle handle, uint32_t src, uint32_t dst);
-
-#ifdef STARPU_USE_CUDA
-	/* for asynchronous CUDA transfers */
-	int (*ram_to_cuda_async)(starpu_data_handle handle, uint32_t src,
-					uint32_t dst, cudaStream_t *stream);
-	int (*cuda_to_ram_async)(starpu_data_handle handle, uint32_t src,
-					uint32_t dst, cudaStream_t *stream);
-	int (*cuda_to_cuda_async)(starpu_data_handle handle, uint32_t src,
-					uint32_t dst, cudaStream_t *stream);
-#endif
-
-#ifdef STARPU_USE_OPENCL
-	/* for asynchronous OpenCL transfers */
-        int (*ram_to_opencl_async)(starpu_data_handle handle, uint32_t src, uint32_t dst, cl_event *event);
-	int (*opencl_to_ram_async)(starpu_data_handle handle, uint32_t src, uint32_t dst, cl_event *event);
-	int (*opencl_to_opencl_async)(starpu_data_handle handle, uint32_t src, uint32_t dst, cl_event *event);
-#endif
-};
-
 void _starpu_wake_all_blocked_workers_on_node(unsigned nodeid);
 
 __attribute__((warn_unused_result))

+ 1 - 1
src/datawizard/filters.c

@@ -178,7 +178,7 @@ void starpu_data_unpartition(starpu_data_handle root_handle, uint32_t gathering_
 		 * really */
 		STARPU_ASSERT(ret == 0); 
 
-		starpu_data_free_interfaces(&root_handle->children[child]);
+		_starpu_data_free_interfaces(&root_handle->children[child]);
 	}
 
 	/* the gathering_node should now have a valid copy of all the children.

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

@@ -41,7 +41,7 @@ static int copy_ram_to_opencl(starpu_data_handle handle, uint32_t src_node, uint
 static int copy_opencl_to_ram(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node);
 #endif
 
-static const struct starpu_copy_data_methods_s bcsr_copy_data_methods_s = {
+static const struct starpu_data_copy_methods bcsr_copy_data_methods_s = {
 	.ram_to_ram = dummy_copy_ram_to_ram,
 	.ram_to_spu = NULL,
 #ifdef STARPU_USE_CUDA
@@ -126,7 +126,7 @@ void starpu_bcsr_data_register(starpu_data_handle *handleptr, uint32_t home_node
 		.elemsize = elemsize
 	};
 
-	_starpu_register_data_handle(handleptr, home_node, &interface, &interface_bcsr_ops);
+	starpu_data_register(handleptr, home_node, &interface, &interface_bcsr_ops);
 }
 
 static uint32_t footprint_bcsr_interface_crc32(starpu_data_handle handle)

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

@@ -41,7 +41,7 @@ static int copy_ram_to_opencl_async(starpu_data_handle handle, uint32_t src_node
 static int copy_opencl_to_ram_async(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, cl_event *event);
 #endif
 
-static const struct starpu_copy_data_methods_s block_copy_data_methods_s = {
+static const struct starpu_data_copy_methods block_copy_data_methods_s = {
 	.ram_to_ram = dummy_copy_ram_to_ram,
 	.ram_to_spu = NULL,
 #ifdef STARPU_USE_CUDA
@@ -150,7 +150,7 @@ void starpu_block_data_register(starpu_data_handle *handleptr, uint32_t home_nod
 		.elemsize = elemsize
 	};
 
-	_starpu_register_data_handle(handleptr, home_node, &interface, &interface_block_ops);
+	starpu_data_register(handleptr, home_node, &interface, &interface_block_ops);
 }
 
 static uint32_t footprint_block_interface_crc32(starpu_data_handle handle)

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

@@ -37,7 +37,7 @@ static int copy_ram_to_opencl(starpu_data_handle handle, uint32_t src_node, uint
 static int copy_opencl_to_ram(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node);
 #endif
 
-static const struct starpu_copy_data_methods_s csr_copy_data_methods_s = {
+static const struct starpu_data_copy_methods csr_copy_data_methods_s = {
 	.ram_to_ram = dummy_copy_ram_to_ram,
 	.ram_to_spu = NULL,
 #ifdef STARPU_USE_CUDA
@@ -117,7 +117,7 @@ void starpu_csr_data_register(starpu_data_handle *handleptr, uint32_t home_node,
 		.elemsize = elemsize
 	};
 
-	_starpu_register_data_handle(handleptr, home_node, &interface, &interface_csr_ops);
+	starpu_data_register(handleptr, home_node, &interface, &interface_csr_ops);
 }
 
 static uint32_t footprint_csr_interface_crc32(starpu_data_handle handle)

+ 3 - 3
src/datawizard/interfaces/data_interface.c

@@ -107,7 +107,7 @@ static starpu_data_handle _starpu_data_handle_allocate(struct starpu_data_interf
 	return handle;
 }
 
-void _starpu_register_data_handle(starpu_data_handle *handleptr, uint32_t home_node,
+void starpu_data_register(starpu_data_handle *handleptr, uint32_t home_node,
 				void *interface,
 				struct starpu_data_interface_ops_t *ops)
 {
@@ -127,7 +127,7 @@ void _starpu_register_data_handle(starpu_data_handle *handleptr, uint32_t home_n
  * Stop monitoring a piece of data
  */
 
-void starpu_data_free_interfaces(starpu_data_handle handle)
+void _starpu_data_free_interfaces(starpu_data_handle handle)
 {
 	unsigned node;
 	for (node = 0; node < STARPU_MAXNODES; node++)
@@ -231,7 +231,7 @@ void starpu_data_unregister(starpu_data_handle handle)
 
 	starpu_data_requester_list_delete(handle->req_list);
 
-	starpu_data_free_interfaces(handle);
+	_starpu_data_free_interfaces(handle);
 
 	free(handle);
 }

+ 1 - 29
src/datawizard/interfaces/data_interface.h

@@ -20,36 +20,8 @@
 #include <starpu.h>
 #include <common/config.h>
 
-#ifdef STARPU_USE_GORDON
-/* to get the gordon_strideSize_t data structure from gordon */
-#include <gordon.h>
-#endif
-
-struct starpu_data_interface_ops_t {
-	void (*register_data_handle)(starpu_data_handle handle,
-					uint32_t home_node, void *interface);
-	size_t (*allocate_data_on_node)(void *interface, uint32_t node);
-	void (*free_data_on_node)(void *interface, uint32_t node);
-	const struct starpu_copy_data_methods_s *copy_methods;
-	size_t (*get_size)(starpu_data_handle handle);
-	uint32_t (*footprint)(starpu_data_handle handle);
-	int (*compare)(void *interface_a, void *interface_b);
-	void (*display)(starpu_data_handle handle, FILE *f);
-#ifdef STARPU_USE_GORDON
-	int (*convert_to_gordon)(void *interface, uint64_t *ptr, gordon_strideSize_t *ss); 
-#endif
-	/* an identifier that is unique to each interface */
-	unsigned interfaceid;
-	size_t interface_size;
-};
-
-void _starpu_register_data_handle(starpu_data_handle *handleptr, uint32_t home_node,
-				void *interface,
-				struct starpu_data_interface_ops_t *ops);
-
 /* Some data interfaces or filters use this interface internally */
 extern struct starpu_data_interface_ops_t _starpu_interface_matrix_ops;
-
-void starpu_data_free_interfaces(starpu_data_handle handle);
+void _starpu_data_free_interfaces(starpu_data_handle handle);
 
 #endif // __DATA_INTERFACE_H__

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

@@ -45,7 +45,7 @@ static int copy_ram_to_opencl_async(starpu_data_handle handle, uint32_t src_node
 static int copy_opencl_to_ram_async(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, cl_event *event);
 #endif
 
-static const struct starpu_copy_data_methods_s matrix_copy_data_methods_s = {
+static const struct starpu_data_copy_methods matrix_copy_data_methods_s = {
 	.ram_to_ram = dummy_copy_ram_to_ram,
 	.ram_to_spu = NULL,
 #ifdef STARPU_USE_CUDA
@@ -156,7 +156,7 @@ void starpu_matrix_data_register(starpu_data_handle *handleptr, uint32_t home_no
                 .offset = 0
 	};
 
-	_starpu_register_data_handle(handleptr, home_node, &interface, &_starpu_interface_matrix_ops);
+	starpu_data_register(handleptr, home_node, &interface, &_starpu_interface_matrix_ops);
 }
 
 static uint32_t footprint_matrix_interface_crc32(starpu_data_handle handle)

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

@@ -45,7 +45,7 @@ static int copy_ram_to_opencl_async(starpu_data_handle handle, uint32_t src_node
 static int copy_opencl_to_ram_async(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, cl_event *event);
 #endif
 
-static const struct starpu_copy_data_methods_s variable_copy_data_methods_s = {
+static const struct starpu_data_copy_methods variable_copy_data_methods_s = {
 	.ram_to_ram = dummy_copy_ram_to_ram,
 	.ram_to_spu = NULL,
 #ifdef STARPU_USE_CUDA
@@ -132,7 +132,7 @@ void starpu_variable_data_register(starpu_data_handle *handleptr, uint32_t home_
 		.elemsize = elemsize
 	};	
 
-	_starpu_register_data_handle(handleptr, home_node, &variable, &interface_variable_ops); 
+	starpu_data_register(handleptr, home_node, &variable, &interface_variable_ops); 
 }
 
 

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

@@ -44,7 +44,7 @@ static int copy_ram_to_opencl_async(starpu_data_handle handle, uint32_t src_node
 static int copy_opencl_to_ram_async(starpu_data_handle handle, uint32_t src_node, uint32_t dst_node, cl_event *event);
 #endif
 
-static const struct starpu_copy_data_methods_s vector_copy_data_methods_s = {
+static const struct starpu_data_copy_methods vector_copy_data_methods_s = {
 	.ram_to_ram = dummy_copy_ram_to_ram,
 	.ram_to_spu = NULL,
 #ifdef STARPU_USE_CUDA
@@ -143,7 +143,7 @@ void starpu_vector_data_register(starpu_data_handle *handleptr, uint32_t home_no
                 .offset = 0
 	};	
 
-	_starpu_register_data_handle(handleptr, home_node, &vector, &interface_vector_ops); 
+	starpu_data_register(handleptr, home_node, &vector, &interface_vector_ops); 
 }