Bläddra i källkod

Code refactoring

HE Kun 3 år sedan
förälder
incheckning
8f1c992d4d

+ 77 - 169
src/datawizard/interfaces/block_filters.c

@@ -18,28 +18,82 @@
 #include <common/config.h>
 #include <datawizard/filters.h>
 
-void starpu_block_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
-			       unsigned id, unsigned nparts)
+static void _starpu_block_filter_block(int dim, void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
+			       unsigned id, unsigned nparts, uintptr_t shadow_size)
 {
-        struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
+	struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
         struct starpu_block_interface *block_child = (struct starpu_block_interface *) child_interface;
 
-	uint32_t nx = block_father->nx;
-        uint32_t ny = block_father->ny;
-        uint32_t nz = block_father->nz;
+        unsigned blocksize;
+	/* the element will be split, in case horizontal, it's nx, in case vertical, it's ny, in case depth, it's nz*/
+	uint32_t nn;
+	uint32_t nx;
+	uint32_t ny;
+	uint32_t nz;
+
+	switch(dim)
+	{
+		/* horizontal*/
+		case 1:
+			/* actual number of elements */
+			nx = block_father->nx - 2 * shadow_size;
+			ny = block_father->ny;
+			nz = block_father->nz;
+			nn = nx;
+			blocksize = 1;
+			break;
+		/* vertical*/
+		case 2:
+			nx = block_father->nx;
+			/* actual number of elements */
+			ny = block_father->ny - 2 * shadow_size;
+			nz = block_father->nz;
+			nn = ny;
+			blocksize = block_father->ldy;
+			break;
+		/* depth*/
+		case 3:
+			nx = block_father->nx;
+			ny = block_father->ny;
+			/* actual number of elements */
+			nz = block_father->nz - 2 * shadow_size;
+			nn = nz;
+			blocksize = block_father->ldz;
+			break;
+	}
+
 	size_t elemsize = block_father->elemsize;
 
-	STARPU_ASSERT_MSG(nparts <= nx, "cannot split %u elements in %u parts", nx, nparts);
+	STARPU_ASSERT_MSG(nparts <= nn, "cannot split %u elements in %u parts", nn, nparts);
 
-	uint32_t chunk_size;
+	uint32_t child_nn;
 	size_t offset;
-	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nparts, elemsize, id, 1, &chunk_size, &offset);
+	starpu_filter_nparts_compute_chunk_size_and_offset(nn, nparts, elemsize, id, blocksize, &child_nn, &offset);
+
+	child_nn += 2 * shadow_size;
 
 	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
 	block_child->id = block_father->id;
-	block_child->nx = chunk_size;
-	block_child->ny = ny;
-	block_child->nz = nz;
+
+	switch(dim)
+	{
+		case 1:
+			block_child->nx = child_nn;
+			block_child->ny = ny;
+			block_child->nz = nz;
+			break;
+		case 2:
+			block_child->nx = nx;
+			block_child->ny = child_nn;
+			block_child->nz = nz;
+			break;
+		case 3:
+			block_child->nx = nx;
+			block_child->ny = ny;
+			block_child->nz = child_nn;
+			break;
+	}
+
 	block_child->elemsize = elemsize;
 
 	if (block_father->dev_handle)
@@ -53,190 +107,44 @@ void starpu_block_filter_block(void *father_interface, void *child_interface, ST
 	}
 }
 
+void starpu_block_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
+			       unsigned id, unsigned nparts)
+{
+	_starpu_block_filter_block(1, father_interface, child_interface, f, id, nparts, 0);
+}
+
 void starpu_block_filter_block_shadow(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
 				      unsigned id, unsigned nparts)
 {
-        struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
-        struct starpu_block_interface *block_child = (struct starpu_block_interface *) child_interface;
-
         uintptr_t shadow_size = (uintptr_t) f->filter_arg_ptr;
 
-	/* actual number of elements */
-	uint32_t nx = block_father->nx - 2 * shadow_size;
-        uint32_t ny = block_father->ny;
-        uint32_t nz = block_father->nz;
-	size_t elemsize = block_father->elemsize;
-
-	STARPU_ASSERT_MSG(nparts <= nx, "cannot split %u elements in %u parts", nx, nparts);
-
-	uint32_t child_nx;
-	size_t offset;
-	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nparts, elemsize, id, 1, &child_nx, &offset);
-
-	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
-	block_child->id = block_father->id;
-	block_child->nx = child_nx + 2 * shadow_size;
-	block_child->ny = ny;
-	block_child->nz = nz;
-	block_child->elemsize = elemsize;
-
-	if (block_father->dev_handle)
-	{
-		if (block_father->ptr)
-                	block_child->ptr = block_father->ptr + offset;
-                block_child->ldy = block_father->ldy;
-                block_child->ldz = block_father->ldz;
-                block_child->dev_handle = block_father->dev_handle;
-                block_child->offset = block_father->offset + offset;
-	}
+        _starpu_block_filter_block(1, father_interface, child_interface, f, id, nparts, shadow_size);
 }
 
 void starpu_block_filter_vertical_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
 					unsigned id, unsigned nparts)
 {
-        struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
-        struct starpu_block_interface *block_child = (struct starpu_block_interface *) child_interface;
-
-	uint32_t nx = block_father->nx;
-        uint32_t ny = block_father->ny;
-        uint32_t nz = block_father->nz;
-	size_t elemsize = block_father->elemsize;
-
-	STARPU_ASSERT_MSG(nparts <= ny, "cannot split %u elements in %u parts", ny, nparts);
-
-	uint32_t child_ny;
-	size_t offset;
-	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nparts, elemsize, id, block_father->ldy, &child_ny, &offset);
-
-	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
-	block_child->id = block_father->id;
-	block_child->nx = nx;
-	block_child->ny = child_ny;
-	block_child->nz = nz;
-	block_child->elemsize = elemsize;
-
-	if (block_father->dev_handle)
-	{
-		if (block_father->ptr)
-                	block_child->ptr = block_father->ptr + offset;
-                block_child->ldy = block_father->ldy;
-                block_child->ldz = block_father->ldz;
-                block_child->dev_handle = block_father->dev_handle;
-                block_child->offset = block_father->offset + offset;
-	}
+	_starpu_block_filter_block(2, father_interface, child_interface, f, id, nparts, 0);
 }
 
 void starpu_block_filter_vertical_block_shadow(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
 					       unsigned id, unsigned nparts)
 {
-        struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
-        struct starpu_block_interface *block_child = (struct starpu_block_interface *) child_interface;
-
         uintptr_t shadow_size = (uintptr_t) f->filter_arg_ptr;
 
-	uint32_t nx = block_father->nx;
-	/* actual number of elements */
-        uint32_t ny = block_father->ny - 2 * shadow_size;
-        uint32_t nz = block_father->nz;
-	size_t elemsize = block_father->elemsize;
-
-	STARPU_ASSERT_MSG(nparts <= ny, "cannot split %u elements in %u parts", ny, nparts);
-
-	uint32_t child_ny;
-	size_t offset;
-
-	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nparts, elemsize, id, block_father->ldy, &child_ny, &offset);
-
-	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
-	block_child->id = block_father->id;
-	block_child->nx = nx;
-	block_child->ny = child_ny + 2 * shadow_size;
-	block_child->nz = nz;
-	block_child->elemsize = elemsize;
-
-	if (block_father->dev_handle)
-	{
-		if (block_father->ptr)
-                	block_child->ptr = block_father->ptr + offset;
-                block_child->ldy = block_father->ldy;
-                block_child->ldz = block_father->ldz;
-                block_child->dev_handle = block_father->dev_handle;
-                block_child->offset = block_father->offset + offset;
-	}
+        _starpu_block_filter_block(2, father_interface, child_interface, f, id, nparts, shadow_size);
 }
 
 void starpu_block_filter_depth_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
 				     unsigned id, unsigned nparts)
 {
-        struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
-        struct starpu_block_interface *block_child = (struct starpu_block_interface *) child_interface;
-
-	uint32_t nx = block_father->nx;
-        uint32_t ny = block_father->ny;
-        uint32_t nz = block_father->nz;
-	size_t elemsize = block_father->elemsize;
-
-	STARPU_ASSERT_MSG(nparts <= nz, "cannot split %u elements in %u parts", nz, nparts);
-
-	uint32_t child_nz;
-	size_t offset;
-
-	starpu_filter_nparts_compute_chunk_size_and_offset(nz, nparts, elemsize, id,
-				       block_father->ldz, &child_nz, &offset);
-
-	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
-	block_child->id = block_father->id;
-	block_child->nx = nx;
-	block_child->ny = ny;
-	block_child->nz = child_nz;
-	block_child->elemsize = elemsize;
-
-	if (block_father->dev_handle)
-	{
-		if (block_father->ptr)
-                	block_child->ptr = block_father->ptr + offset;
-                block_child->ldy = block_father->ldy;
-                block_child->ldz = block_father->ldz;
-                block_child->dev_handle = block_father->dev_handle;
-                block_child->offset = block_father->offset + offset;
-	}
+	_starpu_block_filter_block(3, father_interface, child_interface, f, id, nparts, 0);
 }
 
 void starpu_block_filter_depth_block_shadow(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f,
 					    unsigned id, unsigned nparts)
 {
-        struct starpu_block_interface *block_father = (struct starpu_block_interface *) father_interface;
-        struct starpu_block_interface *block_child = (struct starpu_block_interface *) child_interface;
-
         uintptr_t shadow_size = (uintptr_t) f->filter_arg_ptr;
 
-	uint32_t nx = block_father->nx;
-        uint32_t ny = block_father->ny;
-	/* actual number of elements */
-        uint32_t nz = block_father->nz - 2 * shadow_size;
-	size_t elemsize = block_father->elemsize;
-
-	STARPU_ASSERT_MSG(nparts <= nz, "cannot split %u elements into %u parts", nz, nparts);
-
-	uint32_t child_nz;
-	size_t offset;
-
-	starpu_filter_nparts_compute_chunk_size_and_offset(nz, nparts, elemsize, id, block_father->ldz, &child_nz, &offset);
-
-	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
-	block_child->id = block_father->id;
-	block_child->nx = nx;
-	block_child->ny = ny;
-	block_child->nz = child_nz + 2 * shadow_size;
-	block_child->elemsize = elemsize;
-
-	if (block_father->dev_handle)
-	{
-		if (block_father->ptr)
-                	block_child->ptr = block_father->ptr + offset;
-                block_child->ldy = block_father->ldy;
-                block_child->ldz = block_father->ldz;
-                block_child->dev_handle = block_father->dev_handle;
-                block_child->offset = block_father->offset + offset;
-	}
+        _starpu_block_filter_block(3, father_interface, child_interface, f, id, nparts, shadow_size);
 }

+ 54 - 108
src/datawizard/interfaces/matrix_filters.c

@@ -22,28 +22,66 @@
 /*
  * an example of a dummy partition function : blocks ...
  */
-void starpu_matrix_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
+
+static void _starpu_matrix_filter_block(int dim, void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks, uintptr_t shadow_size)
 {
 	struct starpu_matrix_interface *matrix_father = (struct starpu_matrix_interface *) father_interface;
 	struct starpu_matrix_interface *matrix_child = (struct starpu_matrix_interface *) child_interface;
 
-	uint32_t nx = matrix_father->nx;
-	uint32_t ny = matrix_father->ny;
+	unsigned blocksize;
+	/* the element will be split, in case horizontal, it's nx, in case vertical, it's ny*/
+	uint32_t nn;
+	uint32_t nx;
+	uint32_t ny;
+
+	switch(dim)
+	{
+		/* horizontal*/
+		case 1:
+			/* actual number of elements */
+			nx = matrix_father->nx - 2 * shadow_size;
+			ny = matrix_father->ny;
+			nn = nx;
+			blocksize = 1;
+			break;
+		/* vertical*/
+		case 2:
+			nx = matrix_father->nx;
+			/* actual number of elements */
+			ny = matrix_father->ny - 2 * shadow_size;
+			nn = ny;
+			blocksize = matrix_father->ld;
+			break;
+	}
+	
 	size_t elemsize = matrix_father->elemsize;
 
-	STARPU_ASSERT_MSG(nchunks <= nx, "cannot split %u elements in %u parts", nx, nchunks);
+	STARPU_ASSERT_MSG(nchunks <= nn, "cannot split %u elements in %u parts", nn, nchunks);
 
-	uint32_t child_nx;
+	uint32_t child_nn;
 	size_t offset;
 
-	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1, &child_nx, &offset);
+	starpu_filter_nparts_compute_chunk_size_and_offset(nn, nchunks, elemsize, id, blocksize, &child_nn, &offset);
+
+	child_nn += 2 * shadow_size;
 
 	STARPU_ASSERT_MSG(matrix_father->id == STARPU_MATRIX_INTERFACE_ID, "%s can only be applied on a matrix data", __func__);
 
 	/* update the child's interface */
 	matrix_child->id = matrix_father->id;
-	matrix_child->nx = child_nx;
-	matrix_child->ny = ny;
+
+	switch(dim)
+	{
+		case 1:
+			matrix_child->nx = child_nn;
+			matrix_child->ny = ny;
+			break;
+		case 2:
+			matrix_child->nx = nx;
+			matrix_child->ny = child_nn;
+			break;
+	}
+
 	matrix_child->elemsize = elemsize;
 	STARPU_ASSERT_MSG(matrix_father->allocsize == matrix_father->nx * matrix_father->ny * matrix_father->elemsize, "partitioning matrix with non-trivial allocsize not supported yet, patch welcome");
 	matrix_child->allocsize = matrix_child->nx * matrix_child->ny * elemsize;
@@ -59,121 +97,29 @@ void starpu_matrix_filter_block(void *father_interface, void *child_interface, S
 	}
 }
 
+void starpu_matrix_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
+{
+	_starpu_matrix_filter_block(1, father_interface, child_interface, f, id, nchunks, 0);
+}
+
 /*
  * an example of a dummy partition function : blocks ...
  */
 void starpu_matrix_filter_block_shadow(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
 {
-	struct starpu_matrix_interface *matrix_father = (struct starpu_matrix_interface *) father_interface;
-	struct starpu_matrix_interface *matrix_child = (struct starpu_matrix_interface *) child_interface;
-
 	uintptr_t shadow_size = (uintptr_t) f->filter_arg_ptr;
 
-	/* actual number of elements */
-	uint32_t nx = matrix_father->nx - 2 * shadow_size;
-	uint32_t ny = matrix_father->ny;
-	size_t elemsize = matrix_father->elemsize;
-
-	STARPU_ASSERT_MSG(nchunks <= nx, "cannot split %u elements in %u parts", nx, nchunks);
-
-	uint32_t child_nx;
-	size_t offset;
-
-	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1, &child_nx, &offset);
-
-	child_nx += 2 * shadow_size;
-
-	STARPU_ASSERT_MSG(matrix_father->id == STARPU_MATRIX_INTERFACE_ID, "%s can only be applied on a matrix data", __func__);
-
-	/* update the child's interface */
-	matrix_child->id = matrix_father->id;
-	matrix_child->nx = child_nx;
-	matrix_child->ny = ny;
-	matrix_child->elemsize = elemsize;
-	STARPU_ASSERT_MSG(matrix_father->allocsize == matrix_father->nx * matrix_father->ny * matrix_father->elemsize, "partitioning matrix with non-trivial allocsize not supported yet, patch welcome");
-	matrix_child->allocsize = matrix_child->nx * matrix_child->ny * elemsize;
-
-	/* is the information on this node valid ? */
-	if (matrix_father->dev_handle)
-	{
-		if (matrix_father->ptr)
-			matrix_child->ptr = matrix_father->ptr + offset;
-		matrix_child->ld = matrix_father->ld;
-		matrix_child->dev_handle = matrix_father->dev_handle;
-		matrix_child->offset = matrix_father->offset + offset;
-	}
+	_starpu_matrix_filter_block(1, father_interface, child_interface, f, id, nchunks, shadow_size);
 }
 
 void starpu_matrix_filter_vertical_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
 {
-        struct starpu_matrix_interface *matrix_father = (struct starpu_matrix_interface *) father_interface;
-        struct starpu_matrix_interface *matrix_child = (struct starpu_matrix_interface *) child_interface;
-
-	uint32_t nx = matrix_father->nx;
-	uint32_t ny = matrix_father->ny;
-	size_t elemsize = matrix_father->elemsize;
-
-	STARPU_ASSERT_MSG(nchunks <= ny, "cannot split %u elements in %u parts", ny, nchunks);
-
-	uint32_t child_ny;
-	size_t offset;
-
-	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nchunks, elemsize, id, matrix_father->ld, &child_ny, &offset);
-
-	STARPU_ASSERT_MSG(matrix_father->id == STARPU_MATRIX_INTERFACE_ID, "%s can only be applied on a matrix data", __func__);
-	matrix_child->id = matrix_father->id;
-	matrix_child->nx = nx;
-	matrix_child->ny = child_ny;
-	matrix_child->elemsize = elemsize;
-	STARPU_ASSERT_MSG(matrix_father->allocsize == matrix_father->nx * matrix_father->ny * matrix_father->elemsize, "partitioning matrix with non-trivial allocsize not supported yet, patch welcome");
-	matrix_child->allocsize = matrix_child->nx * matrix_child->ny * elemsize;
-
-	/* is the information on this node valid ? */
-	if (matrix_father->dev_handle)
-	{
-		if (matrix_father->ptr)
-			matrix_child->ptr = matrix_father->ptr + offset;
-		matrix_child->ld = matrix_father->ld;
-		matrix_child->dev_handle = matrix_father->dev_handle;
-		matrix_child->offset = matrix_father->offset + offset;
-	}
+	_starpu_matrix_filter_block(2, father_interface, child_interface, f, id, nchunks, 0);
 }
 
 void starpu_matrix_filter_vertical_block_shadow(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
 {
-        struct starpu_matrix_interface *matrix_father = (struct starpu_matrix_interface *) father_interface;
-        struct starpu_matrix_interface *matrix_child = (struct starpu_matrix_interface *) child_interface;
-
 	uintptr_t shadow_size = (uintptr_t) f->filter_arg_ptr;
 
-	uint32_t nx = matrix_father->nx;
-	/* actual number of elements */
-	uint32_t ny = matrix_father->ny - 2 * shadow_size;
-	size_t elemsize = matrix_father->elemsize;
-
-	STARPU_ASSERT_MSG(nchunks <= ny, "cannot split %u elements in %u parts", ny, nchunks);
-
-	uint32_t child_ny;
-	size_t offset;
-
-	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nchunks, elemsize, id, matrix_father->ld, &child_ny, &offset);
-	child_ny += 2 * shadow_size;
-
-	STARPU_ASSERT_MSG(matrix_father->id == STARPU_MATRIX_INTERFACE_ID, "%s can only be applied on a matrix data", __func__);
-	matrix_child->id = matrix_father->id;
-	matrix_child->nx = nx;
-	matrix_child->ny = child_ny;
-	matrix_child->elemsize = elemsize;
-	STARPU_ASSERT_MSG(matrix_father->allocsize == matrix_father->nx * matrix_father->ny * matrix_father->elemsize, "partitioning matrix with non-trivial allocsize not supported yet, patch welcomed");
-	matrix_child->allocsize = matrix_child->nx * matrix_child->ny * elemsize;
-
-	/* is the information on this node valid ? */
-	if (matrix_father->dev_handle)
-	{
-		if (matrix_father->ptr)
-			matrix_child->ptr = matrix_father->ptr + offset;
-		matrix_child->ld = matrix_father->ld;
-		matrix_child->dev_handle = matrix_father->dev_handle;
-		matrix_child->offset = matrix_father->offset + offset;
-	}
+	_starpu_matrix_filter_block(2, father_interface, child_interface, f, id, nchunks, shadow_size);
 }

+ 11 - 31
src/datawizard/interfaces/vector_filters.c

@@ -19,12 +19,13 @@
 #include <common/config.h>
 #include <datawizard/filters.h>
 
-void starpu_vector_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
+static void _starpu_vector_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks, uintptr_t shadow_size)
 {
-        struct starpu_vector_interface *vector_father = (struct starpu_vector_interface *) father_interface;
+	struct starpu_vector_interface *vector_father = (struct starpu_vector_interface *) father_interface;
         struct starpu_vector_interface *vector_child = (struct starpu_vector_interface *) child_interface;
 
-	uint32_t nx = vector_father->nx;
+        /* actual number of elements */
+	uint32_t nx = vector_father->nx - 2 * shadow_size;
 	size_t elemsize = vector_father->elemsize;
 
 	STARPU_ASSERT_MSG(nchunks <= nx, "cannot split %u elements in %u parts", nx, nchunks);
@@ -32,6 +33,7 @@ void starpu_vector_filter_block(void *father_interface, void *child_interface, S
 	uint32_t child_nx;
 	size_t offset;
 	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1, &child_nx, &offset);
+	child_nx += 2*shadow_size;
 
 	STARPU_ASSERT_MSG(vector_father->id == STARPU_VECTOR_INTERFACE_ID, "%s can only be applied on a vector data", __func__);
 	vector_child->id = vector_father->id;
@@ -49,39 +51,17 @@ void starpu_vector_filter_block(void *father_interface, void *child_interface, S
 	}
 }
 
+void starpu_vector_filter_block(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
+{
+	_starpu_vector_filter_block(father_interface, child_interface, f, id, nchunks, 0);
+}
+
 
 void starpu_vector_filter_block_shadow(void *father_interface, void *child_interface, STARPU_ATTRIBUTE_UNUSED struct starpu_data_filter *f, unsigned id, unsigned nchunks)
 {
-        struct starpu_vector_interface *vector_father = (struct starpu_vector_interface *) father_interface;
-        struct starpu_vector_interface *vector_child = (struct starpu_vector_interface *) child_interface;
-
         uintptr_t shadow_size = (uintptr_t) f->filter_arg_ptr;
 
-	/* actual number of elements */
-	uint32_t nx = vector_father->nx - 2 * shadow_size;
-	size_t elemsize = vector_father->elemsize;
-
-	STARPU_ASSERT_MSG(nchunks <= nx, "cannot split %u elements in %u parts", nx, nchunks);
-
-	uint32_t child_nx;
-	size_t offset;
-	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1, &child_nx, &offset);
-	child_nx += 2*shadow_size;
-
-	STARPU_ASSERT_MSG(vector_father->id == STARPU_VECTOR_INTERFACE_ID, "%s can only be applied on a vector data", __func__);
-	vector_child->id = vector_father->id;
-	vector_child->nx = child_nx;
-	vector_child->elemsize = elemsize;
-	STARPU_ASSERT_MSG(vector_father->allocsize == vector_father->nx * vector_father->elemsize, "partitioning vector with non-trival allocsize not supported yet, patch welcome");
-	vector_child->allocsize = vector_child->nx * elemsize;
-
-	if (vector_father->dev_handle)
-	{
-		if (vector_father->ptr)
-			vector_child->ptr = vector_father->ptr + offset;
-		vector_child->dev_handle = vector_father->dev_handle;
-		vector_child->offset = vector_father->offset + offset;
-	}
+        _starpu_vector_filter_block(father_interface, child_interface, f, id, nchunks, shadow_size);
 }