Browse Source

spmv: Use the StarPU-provided filtering function instead of keeping a copy

Samuel Thibault 5 years ago
parent
commit
671c54398c
1 changed files with 1 additions and 37 deletions
  1. 1 37
      examples/spmv/spmv.c

+ 1 - 37
examples/spmv/spmv.c

@@ -48,46 +48,10 @@ static void parse_args(int argc, char **argv)
 	}
 }
 
-/* This filter function takes a CSR matrix, and divides it into nparts with the
- * same number of rows. */
-static void csr_filter_func(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
-{
-	(void)f;
-	struct starpu_csr_interface *csr_father = (struct starpu_csr_interface *) father_interface;
-	struct starpu_csr_interface *csr_child = (struct starpu_csr_interface *) child_interface;
-
-	uint32_t nrow = csr_father->nrow;
-	size_t elemsize = csr_father->elemsize;
-	uint32_t firstentry = csr_father->firstentry;
-
-	/* Every sub-parts should contain the same number of non-zero entries */
-	uint32_t chunk_size = (nrow + nparts - 1)/nparts;
-	uint32_t *rowptr = csr_father->rowptr;
-
-	uint32_t first_index = id*chunk_size - firstentry;
-	uint32_t local_firstentry = rowptr[first_index];
-
-	uint32_t child_nrow = STARPU_MIN(chunk_size, nrow - id*chunk_size);
-	uint32_t local_nnz = rowptr[first_index + child_nrow] - rowptr[first_index];
-
-	csr_child->id = csr_father->id;
-	csr_child->nnz = local_nnz;
-	csr_child->nrow = child_nrow;
-	csr_child->firstentry = local_firstentry;
-	csr_child->elemsize = elemsize;
-
-	if (csr_father->nzval)
-	{
-		csr_child->rowptr = &csr_father->rowptr[first_index];
-		csr_child->colind = &csr_father->colind[local_firstentry];
-		csr_child->nzval = csr_father->nzval + local_firstentry * elemsize;
-	}
-}
-
 /* partition the CSR matrix along a block distribution */
 static struct starpu_data_filter csr_f =
 {
-	.filter_func = csr_filter_func,
+	.filter_func = starpu_csr_filter_vertical_block,
 	/* This value is defined later on */
 	.nchildren = -1,
 	/* the children also use a csr interface */