Browse Source

The filter functions need not return the number of children as the nchildren
field of the handle must already be filled.

Cédric Augonnet 15 years ago
parent
commit
a6b0a7fbee

+ 2 - 5
examples/pastix-wrappers/starpu-blas-wrapper.c

@@ -92,7 +92,7 @@ struct divide_vector_in_blas_filter_args {
 	uint32_t stride; /* stride of the first portion (need to be a multiple of n */
 };
 
-unsigned divide_vector_in_blas_filter(starpu_filter *f, starpu_data_handle root_data)
+void divide_vector_in_blas_filter(starpu_filter *f, starpu_data_handle root_data)
 {
 	starpu_vector_interface_t *vector_root = &root_data->interface[0].vector;
 		uint32_t nx = vector_root->nx;
@@ -107,8 +107,7 @@ unsigned divide_vector_in_blas_filter(starpu_filter *f, starpu_data_handle root_
 		
 
 	/* first allocate the children starpu_data_handle */
-	root_data->children = calloc((n1==0)?2:3, sizeof(starpu_data_handle));
-	STARPU_ASSERT(root_data->children);
+	starpu_data_create_children(root_data, (n1==0)?2:3, root_data->ops);
 
 	STARPU_ASSERT((n2 % args->stride) == 0);
 
@@ -163,8 +162,6 @@ unsigned divide_vector_in_blas_filter(starpu_filter *f, starpu_data_handle root_
 			local->ptr = root_data->interface[node].vector.ptr + (n1+n2)*elemsize;
 		}
 	}
-
-	return (n1==0)?2:3;
 }
 
 

+ 8 - 8
include/starpu-data-filters.h

@@ -25,7 +25,7 @@ extern "C" {
 #endif
 
 typedef struct starpu_filter_t {
-	unsigned (*filter_func)(struct starpu_filter_t *, starpu_data_handle); /* the actual partitionning function */
+	void (*filter_func)(struct starpu_filter_t *, starpu_data_handle); /* the actual partitionning function */
 	uint32_t filter_arg;
 	void *filter_arg_ptr;
 } starpu_filter;
@@ -48,16 +48,16 @@ void starpu_map_filters(starpu_data_handle root_data, unsigned nfilters, ...);
 /* a few examples of filters */
 
 /* for BCSR */
-unsigned starpu_canonical_block_filter_bcsr(starpu_filter *f, starpu_data_handle root_data);
-unsigned starpu_vertical_block_filter_func_csr(starpu_filter *f, starpu_data_handle root_data);
+void starpu_canonical_block_filter_bcsr(starpu_filter *f, starpu_data_handle root_data);
+void starpu_vertical_block_filter_func_csr(starpu_filter *f, starpu_data_handle root_data);
 /* (filters for BLAS interface) */
-unsigned starpu_block_filter_func(starpu_filter *f, starpu_data_handle root_data);
-unsigned starpu_vertical_block_filter_func(starpu_filter *f, starpu_data_handle root_data);
+void starpu_block_filter_func(starpu_filter *f, starpu_data_handle root_data);
+void starpu_vertical_block_filter_func(starpu_filter *f, starpu_data_handle root_data);
 
 /* for vector */
-unsigned starpu_block_filter_func_vector(starpu_filter *f, starpu_data_handle root_data);
-unsigned starpu_list_filter_func_vector(starpu_filter *f, starpu_data_handle root_data);
-unsigned starpu_divide_in_2_filter_func_vector(starpu_filter *f, starpu_data_handle root_data);
+void starpu_block_filter_func_vector(starpu_filter *f, starpu_data_handle root_data);
+void starpu_list_filter_func_vector(starpu_filter *f, starpu_data_handle root_data);
+void starpu_divide_in_2_filter_func_vector(starpu_filter *f, starpu_data_handle root_data);
 
 #ifdef __cplusplus
 }

+ 3 - 3
src/datawizard/hierarchy.c

@@ -184,10 +184,10 @@ void starpu_partition_data(starpu_data_handle initial_handle, starpu_filter *f)
 	STARPU_ASSERT(initial_handle->nchildren == 0);
 
 	/* this should update the pointers and size of the chunk */
-	nparts = f->filter_func(f, initial_handle);
-	STARPU_ASSERT(nparts > 0);
+	f->filter_func(f, initial_handle);
 
-	initial_handle->nchildren = nparts;
+	nparts = initial_handle->nchildren;
+	STARPU_ASSERT(nparts > 0);
 
 	for (i = 0; i < nparts; i++)
 	{

+ 1 - 4
src/datawizard/interfaces/bcsr_filters.c

@@ -20,7 +20,7 @@
 
 extern struct data_interface_ops_t interface_blas_ops;
 
-unsigned starpu_canonical_block_filter_bcsr(starpu_filter *f __attribute__((unused)), starpu_data_handle root_handle)
+void starpu_canonical_block_filter_bcsr(starpu_filter *f __attribute__((unused)), starpu_data_handle root_handle)
 {
 	unsigned nchunks;
 
@@ -73,7 +73,4 @@ unsigned starpu_canonical_block_filter_bcsr(starpu_filter *f __attribute__((unus
 			}
 		}
 	}
-
-	return nchunks;
-
 }

+ 2 - 6
src/datawizard/interfaces/blas_filters.c

@@ -21,7 +21,7 @@
 /*
  * an example of a dummy partition function : blocks ...
  */
-unsigned starpu_block_filter_func(starpu_filter *f, starpu_data_handle root_handle)
+void starpu_block_filter_func(starpu_filter *f, starpu_data_handle root_handle)
 {
 	unsigned nchunks;
 	uint32_t arg = f->filter_arg;
@@ -72,11 +72,9 @@ unsigned starpu_block_filter_func(starpu_filter *f, starpu_data_handle root_hand
 			}
 		}
 	}
-
-	return nchunks;
 }
 
-unsigned starpu_vertical_block_filter_func(starpu_filter *f, starpu_data_handle root_handle)
+void starpu_vertical_block_filter_func(starpu_filter *f, starpu_data_handle root_handle)
 {
 	unsigned nchunks;
 	uint32_t arg = f->filter_arg;
@@ -127,6 +125,4 @@ unsigned starpu_vertical_block_filter_func(starpu_filter *f, starpu_data_handle
 			}
 		}
 	}
-
-	return nchunks;
 }

+ 1 - 3
src/datawizard/interfaces/csr_filters.c

@@ -18,7 +18,7 @@
 #include <common/config.h>
 #include <datawizard/hierarchy.h>
 
-unsigned starpu_vertical_block_filter_func_csr(starpu_filter *f, starpu_data_handle root_handle)
+void starpu_vertical_block_filter_func_csr(starpu_filter *f, starpu_data_handle root_handle)
 {
 	unsigned nchunks;
 	uint32_t arg = f->filter_arg;
@@ -76,6 +76,4 @@ unsigned starpu_vertical_block_filter_func_csr(starpu_filter *f, starpu_data_han
 			}
 		}
 	}
-
-	return nchunks;
 }

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

@@ -18,7 +18,7 @@
 #include <common/config.h>
 #include <datawizard/hierarchy.h>
 
-unsigned starpu_block_filter_func_vector(starpu_filter *f, starpu_data_handle root_handle)
+void starpu_block_filter_func_vector(starpu_filter *f, starpu_data_handle root_handle)
 {
 	unsigned nchunks;
 	uint32_t arg = f->filter_arg;
@@ -65,12 +65,10 @@ unsigned starpu_block_filter_func_vector(starpu_filter *f, starpu_data_handle ro
 			}
 		}
 	}
-
-	return nchunks;
 }
 
 
-unsigned starpu_divide_in_2_filter_func_vector(starpu_filter *f, starpu_data_handle root_handle)
+void starpu_divide_in_2_filter_func_vector(starpu_filter *f, starpu_data_handle root_handle)
 {
 	uint32_t length_first = f->filter_arg;
 
@@ -123,11 +121,9 @@ unsigned starpu_divide_in_2_filter_func_vector(starpu_filter *f, starpu_data_han
 			local->ptr = local_root->ptr + length_first*elemsize;
 		}
 	}
-
-	return 2;
 }
 
-unsigned starpu_list_filter_func_vector(starpu_filter *f, starpu_data_handle root_handle)
+void starpu_list_filter_func_vector(starpu_filter *f, starpu_data_handle root_handle)
 {
 	uint32_t nchunks = f->filter_arg;
 	uint32_t *length_tab = f->filter_arg_ptr;
@@ -173,6 +169,4 @@ unsigned starpu_list_filter_func_vector(starpu_filter *f, starpu_data_handle roo
 	}
 
 	STARPU_ASSERT(current_pos == nx);
-
-	return nchunks;
 }