Browse Source

Include the size of the interface structure in the data_interface_ops_t
structure.

Cédric Augonnet 16 years ago
parent
commit
6fee32672b

+ 3 - 1
include/starpu-data-filters.h

@@ -33,7 +33,9 @@ typedef struct starpu_filter_t {
 void starpu_partition_data(starpu_data_handle initial_data, starpu_filter *f); 
 void starpu_unpartition_data(starpu_data_handle root_data, uint32_t gathering_node);
 
-void starpu_data_create_children(starpu_data_handle handle, unsigned nchildren, size_t interfacesize);
+struct data_interface_ops_t;
+void starpu_data_create_children(starpu_data_handle handle, unsigned nchildren,
+		 struct data_interface_ops_t *children_interface_ops);
 
 starpu_data_handle starpu_data_get_child(starpu_data_handle handle, unsigned i);
 

+ 2 - 1
include/starpu-data.h

@@ -40,7 +40,8 @@ typedef struct starpu_buffer_descr_t {
 	starpu_access_mode mode;
 } starpu_buffer_descr;
 
-starpu_data_handle starpu_data_state_create(size_t interfacesize);
+struct data_interface_ops_t;
+starpu_data_handle starpu_data_state_create(struct data_interface_ops_t *interface_ops);
 
 void starpu_unpartition_data(starpu_data_handle root_data, uint32_t gathering_node);
 void starpu_delete_data(starpu_data_handle state);

+ 1 - 1
src/datawizard/coherency.c

@@ -368,7 +368,7 @@ int fetch_task_input(struct starpu_task *task, uint32_t mask)
 
 		void *src_interface = starpu_data_get_interface_on_node(handle, local_memory_node);
 
-		memcpy(&interface[index], src_interface, handle->interface_size);
+		memcpy(&interface[index], src_interface, handle->ops->interface_size);
 	}
 
 	TRACE_END_FETCH_INPUT(NULL);

+ 0 - 1
src/datawizard/coherency.h

@@ -112,7 +112,6 @@ struct starpu_data_state_t {
 	/* describe the actual data layout */
 //	starpu_data_interface_t interface[MAXNODES];
 	void *interface[MAXNODES];
-	size_t interface_size;
 
 	struct data_interface_ops_t *ops;
 

+ 8 - 9
src/datawizard/hierarchy.c

@@ -200,11 +200,6 @@ void starpu_partition_data(starpu_data_handle initial_handle, starpu_filter *f)
 
 		children->is_not_important = initial_handle->is_not_important;
 
-		/* it is possible that the children does not use the same interface as the parent,
-		 * in that case, the starpu_filter must set the proper methods */
-		if (!children->ops)
-			children->ops = initial_handle->ops;
-
 		children->wb_mask = initial_handle->wb_mask;
 
 		/* initialize the chunk lock */
@@ -334,14 +329,16 @@ void starpu_advise_if_data_is_important(starpu_data_handle handle, unsigned is_i
 
 }
 
-starpu_data_handle starpu_data_state_create(size_t interfacesize)
+starpu_data_handle starpu_data_state_create(struct data_interface_ops_t *interface_ops)
 {
 	starpu_data_handle handle =
 		calloc(1, sizeof(struct starpu_data_state_t));
 
 	STARPU_ASSERT(handle);
 
-	handle->interface_size = interfacesize;
+	handle->ops = interface_ops;
+
+	size_t interfacesize = interface_ops->interface_size;
 
 	unsigned node;
 	for (node = 0; node < MAXNODES; node++)
@@ -354,7 +351,7 @@ starpu_data_handle starpu_data_state_create(size_t interfacesize)
 }
 
 void starpu_data_create_children(starpu_data_handle handle,
-		unsigned nchildren, size_t interfacesize)
+		unsigned nchildren, struct data_interface_ops_t *children_interface_ops)
 {
 	handle->children = calloc(nchildren, sizeof(struct starpu_data_state_t));
 	STARPU_ASSERT(handle->children);
@@ -366,7 +363,9 @@ void starpu_data_create_children(starpu_data_handle handle,
 	{
 		starpu_data_handle handle_child = &handle->children[child];
 
-		handle_child->interface_size = interfacesize;
+		handle_child->ops = children_interface_ops;
+
+		size_t interfacesize = children_interface_ops->interface_size;
 
 		for (node = 0; node < MAXNODES; node++)
 		{

+ 3 - 5
src/datawizard/interfaces/bcsr_filters.c

@@ -39,8 +39,8 @@ unsigned starpu_canonical_block_filter_bcsr(starpu_filter *f __attribute__((unus
 	/* we create as many subdata as there are blocks ... */
 	nchunks = nnz;
 	
-	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, nchunks, sizeof(starpu_blas_interface_t));
+	/* first allocate the children : it's a set of BLAS !*/
+	starpu_data_create_children(root_handle, nchunks, &interface_blas_ops);
 
 	/* actually create all the chunks */
 
@@ -58,7 +58,7 @@ unsigned starpu_canonical_block_filter_bcsr(starpu_filter *f __attribute__((unus
 		for (node = 0; node < MAXNODES; node++)
 		{
 			starpu_blas_interface_t *local =
-				starpu_data_get_interface_on_node(root_handle, node);
+				starpu_data_get_interface_on_node(sub_handle, node);
 
 			local->nx = c;
 			local->ny = r;
@@ -72,8 +72,6 @@ unsigned starpu_canonical_block_filter_bcsr(starpu_filter *f __attribute__((unus
 				local->ptr = (uintptr_t)&nzval[firstentry + ptr_offset];
 			}
 		}
-
-		sub_handle->ops = &interface_blas_ops;
 	}
 
 	return nchunks;

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

@@ -58,6 +58,7 @@ struct data_interface_ops_t interface_bcsr_ops = {
 	.copy_methods = &bcsr_copy_data_methods_s,
 	.get_size = bcsr_interface_get_size,
 	.interfaceid = STARPU_BCSCR_INTERFACE_ID,
+	.interface_size = sizeof(starpu_bcsr_interface_t),
 	.footprint = footprint_bcsr_interface_crc32
 };
 
@@ -65,7 +66,7 @@ void starpu_register_bcsr_data(starpu_data_handle *handleptr, uint32_t home_node
 		uint32_t nnz, uint32_t nrow, uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry,  uint32_t r, uint32_t c, size_t elemsize)
 {
 	starpu_data_handle handle =
-		starpu_data_state_create(sizeof(starpu_bcsr_interface_t));
+		starpu_data_state_create(&interface_bcsr_ops);
 
 	STARPU_ASSERT(handleptr);
 	*handleptr = handle;

+ 5 - 4
src/datawizard/interfaces/blas_filters.c

@@ -36,8 +36,9 @@ unsigned starpu_block_filter_func(starpu_filter *f, starpu_data_handle root_hand
 	/* we will have arg chunks */
 	nchunks = STARPU_MIN(nx, arg);
 
-	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, nchunks, sizeof(starpu_blas_interface_t));
+	/* first allocate the children, they have the same interface type as
+	 * the root (blas) */
+	starpu_data_create_children(root_handle, nchunks, root_handle->ops);
 
 	/* actually create all the chunks */
 	unsigned chunk;
@@ -90,8 +91,8 @@ unsigned starpu_vertical_block_filter_func(starpu_filter *f, starpu_data_handle
 	/* we will have arg chunks */
 	nchunks = STARPU_MIN(ny, arg);
 	
-	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, nchunks, sizeof(starpu_blas_interface_t));
+	/* first allocate the children: they also use a BLAS interface */
+	starpu_data_create_children(root_handle, nchunks, root_handle->ops);
 
 	/* actually create all the chunks */
 	unsigned chunk;

+ 2 - 1
src/datawizard/interfaces/blas_interface.c

@@ -73,6 +73,7 @@ struct data_interface_ops_t interface_blas_ops = {
 	.convert_to_gordon = convert_blas_to_gordon,
 #endif
 	.interfaceid = STARPU_BLAS_INTERFACE_ID, 
+	.interface_size = sizeof(starpu_blas_interface_t),
 	.display = display_blas_interface
 };
 
@@ -100,7 +101,7 @@ void starpu_register_blas_data(starpu_data_handle *handleptr, uint32_t home_node
 			uint32_t ny, size_t elemsize)
 {
 	starpu_data_handle handle =
-		starpu_data_state_create(sizeof(starpu_blas_interface_t));
+		starpu_data_state_create(&interface_blas_ops);
 
 	STARPU_ASSERT(handleptr);
 	*handleptr = handle;

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

@@ -67,6 +67,7 @@ struct data_interface_ops_t interface_block_ops = {
 	.convert_to_gordon = convert_block_to_gordon,
 #endif
 	.interfaceid = STARPU_BLOCK_INTERFACE_ID, 
+	.interface_size = sizeof(starpu_block_interface_t),
 	.display = display_block_interface
 };
 
@@ -86,7 +87,7 @@ void starpu_register_block_data(starpu_data_handle *handleptr, uint32_t home_nod
 			uint32_t ny, uint32_t nz, size_t elemsize)
 {
 	starpu_data_handle handle =
-		starpu_data_state_create(sizeof(starpu_block_interface_t));
+		starpu_data_state_create(&interface_block_ops);
 
 	STARPU_ASSERT(handleptr);
 	*handleptr = handle;

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

@@ -33,8 +33,8 @@ unsigned starpu_vertical_block_filter_func_csr(starpu_filter *f, starpu_data_han
 	/* we will have arg chunks */
 	nchunks = STARPU_MIN(nrow, arg);
 	
-	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, nchunks, sizeof(starpu_csr_interface_t));
+	/* first allocate the children (they also use the csr interface) */
+	starpu_data_create_children(root_handle, nchunks, root_handle->ops);
 
 	/* actually create all the chunks */
 	uint32_t chunk_size = (nrow + nchunks - 1)/nchunks;

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

@@ -55,6 +55,7 @@ struct data_interface_ops_t interface_csr_ops = {
 	.copy_methods = &csr_copy_data_methods_s,
 	.get_size = csr_interface_get_size,
 	.interfaceid = STARPU_CSR_INTERFACE_ID,
+	.interface_size = sizeof(starpu_csr_interface_t),
 	.footprint = footprint_csr_interface_crc32
 };
 
@@ -63,7 +64,7 @@ void starpu_register_csr_data(starpu_data_handle *handleptr, uint32_t home_node,
 		uint32_t nnz, uint32_t nrow, uintptr_t nzval, uint32_t *colind, uint32_t *rowptr, uint32_t firstentry, size_t elemsize)
 {
 	starpu_data_handle handle =
-		starpu_data_state_create(sizeof(starpu_csr_interface_t));	
+		starpu_data_state_create(&interface_csr_ops);	
 
 	STARPU_ASSERT(handleptr);
 	*handleptr = handle;

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

@@ -39,6 +39,7 @@ struct data_interface_ops_t {
 #endif
 	/* an identifier that is unique to each interface */
 	unsigned interfaceid;
+	size_t interface_size;
 };
 
 #endif // __DATA_INTERFACE_H__

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

@@ -33,7 +33,7 @@ unsigned starpu_block_filter_func_vector(starpu_filter *f, starpu_data_handle ro
 	nchunks = STARPU_MIN(nx, arg);
 
 	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, nchunks, sizeof(starpu_vector_interface_t));
+	starpu_data_create_children(root_handle, nchunks, root_handle->ops);
 
 	/* actually create all the chunks */
 	unsigned chunk;
@@ -81,7 +81,7 @@ unsigned starpu_divide_in_2_filter_func_vector(starpu_filter *f, starpu_data_han
 	size_t elemsize = vector_root->elemsize;
 
 	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, 2, sizeof(starpu_vector_interface_t));
+	starpu_data_create_children(root_handle, 2, root_handle->ops);
 
 	STARPU_ASSERT(length_first < nx);
 
@@ -139,7 +139,7 @@ unsigned starpu_list_filter_func_vector(starpu_filter *f, starpu_data_handle roo
 	size_t elemsize = vector_root->elemsize;
 
 	/* first allocate the children data_state */
-	starpu_data_create_children(root_handle, nchunks, sizeof(starpu_vector_interface_t));
+	starpu_data_create_children(root_handle, nchunks, root_handle->ops);
 
 	unsigned current_pos = 0;
 

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

@@ -71,6 +71,7 @@ struct data_interface_ops_t interface_vector_ops = {
 	.convert_to_gordon = convert_vector_to_gordon,
 #endif
 	.interfaceid = STARPU_VECTOR_INTERFACE_ID,
+	.interface_size = sizeof(starpu_vector_interface_t), 
 	.display = display_vector_interface
 };
 
@@ -89,7 +90,7 @@ void starpu_register_vector_data(starpu_data_handle *handleptr, uint32_t home_no
                         uintptr_t ptr, uint32_t nx, size_t elemsize)
 {
 	starpu_data_handle handle =
-		starpu_data_state_create(sizeof(starpu_vector_interface_t));
+		starpu_data_state_create(&interface_vector_ops);
 
 	STARPU_ASSERT(handleptr);
 	*handleptr = handle;

+ 2 - 2
src/datawizard/memalloc.c

@@ -431,10 +431,10 @@ static void register_mem_chunk(starpu_data_handle handle, uint32_t dst_node, siz
 	/* the interface was already filled by ops->allocate_data_on_node */
 	void *src_interface = starpu_data_get_interface_on_node(handle, dst_node);
 
-	mc->interface = malloc(handle->interface_size);
+	mc->interface = malloc(handle->ops->interface_size);
 	STARPU_ASSERT(mc->interface);
 
-	memcpy(mc->interface, src_interface, handle->interface_size);
+	memcpy(mc->interface, src_interface, handle->ops->interface_size);
 
 	res = pthread_rwlock_wrlock(&mc_rwlock[dst_node]);
 	STARPU_ASSERT(!res);