瀏覽代碼

Add starpu_filter_nparts_compute_chunk_size_and_offset helper.

Samuel Thibault 6 年之前
父節點
當前提交
e32db6e20a

+ 3 - 0
ChangeLog

@@ -23,6 +23,9 @@ New features:
 StarPU 1.3.1 (git revision xxx)
 ==============================================
 
+Small features:
+  * Add starpu_filter_nparts_compute_chunk_size_and_offset helper.
+
 StarPU 1.3.0 (git revision 24ca83c6dbb102e1cfc41db3bb21c49662067062)
 ==============================================
 

+ 9 - 0
doc/doxygen/chapters/310_data_management.doxy

@@ -480,6 +480,8 @@ additional filters can be defined by the application. The principle is that the
 filter function just fills the memory location of the <c>i-th</c> subpart of a data.
 Examples are provided in <c>src/datawizard/interfaces/*_filters.c</c>,
 and see \ref starpu_data_filter::filter_func for the details.
+The starpu_filter_nparts_compute_chunk_size_and_offset() helper can be used to
+compute the division of pieces of data.
 
 \section DataReduction Data Reduction
 
@@ -790,6 +792,13 @@ void starpu_complex_data_register(starpu_data_handle_t *handle,
 }
 \endcode
 
+The <c>starpu_complex_interface</c> structure is here used just to store the
+parameters that the user provided to <c>starpu_complex_data_register</c>.
+starpu_data_register() will first allocate the handle, and
+then pass the <c>starpu_complex_interface</c> structure to the
+starpu_data_interface_ops::register_data_handle method, which records them
+within the data handle (it is called once per node by starpu_data_register()).
+
 Different operations need to be defined for a data interface through
 the type starpu_data_interface_ops. We only define here the basic
 operations needed to run simple applications. The source code for the

+ 13 - 1
include/starpu_data_filters.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011                                     Antoine Lucas
- * Copyright (C) 2009-2012,2014,2015,2017                 Université de Bordeaux
+ * Copyright (C) 2009-2012,2014,2015,2017,2019            Université de Bordeaux
  * Copyright (C) 2010                                     Mehdi Juhoor
  * Copyright (C) 2010-2013,2015,2017,2018,2019            CNRS
  * Copyright (C) 2011                                     Inria
@@ -505,6 +505,18 @@ void starpu_block_filter_depth_block(void *father_interface, void *child_interfa
 */
 void starpu_block_filter_depth_block_shadow(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts);
 
+/**
+   Given an integer \p n, \p n the number of parts it must be divided in, \p id the
+   part currently considered, determines the \p chunk_size and the \p offset, taking
+   into account the size of the elements stored in the data structure \p elemsize
+   and \p ld, the leading dimension, which is most often 1.
+ */
+void
+starpu_filter_nparts_compute_chunk_size_and_offset(unsigned n, unsigned nparts,
+					     size_t elemsize, unsigned id,
+					     unsigned ld, unsigned *chunk_size,
+					     size_t *offset);
+
 /** @} */
 
 /** @} */

+ 1 - 7
src/datawizard/filters.c

@@ -1042,14 +1042,8 @@ void _starpu_data_partition_access_submit(starpu_data_handle_t target, int write
 	_starpu_data_partition_access_look_up(target, NULL, write);
 }
 
-/*
- * Given an integer N, NPARTS the number of parts it must be divided in, ID the
- * part currently considered, determines the CHUNK_SIZE and the OFFSET, taking
- * into account the size of the elements stored in the data structure ELEMSIZE
- * and LD, the leading dimension.
- */
 void
-_starpu_filter_nparts_compute_chunk_size_and_offset(unsigned n, unsigned nparts,
+starpu_filter_nparts_compute_chunk_size_and_offset(unsigned n, unsigned nparts,
 					     size_t elemsize, unsigned id,
 					     unsigned ld, unsigned *chunk_size,
 					     size_t *offset)

+ 7 - 7
src/datawizard/interfaces/block_filters.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012                                     Inria
  * Copyright (C) 2010,2011,2013,2015,2017                 CNRS
- * Copyright (C) 2011-2014,2016                           Université de Bordeaux
+ * Copyright (C) 2011-2014,2016, 2019                           Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -35,7 +35,7 @@ void starpu_block_filter_block(void *father_interface, void *child_interface, ST
 
 	uint32_t chunk_size;
 	size_t offset;
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nx, nparts, elemsize, id, 1,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nparts, elemsize, id, 1,
 				       &chunk_size, &offset);
 
 	STARPU_ASSERT_MSG(block_father->id == STARPU_BLOCK_INTERFACE_ID, "%s can only be applied on a block data", __func__);
@@ -74,7 +74,7 @@ void starpu_block_filter_block_shadow(void *father_interface, void *child_interf
 
 	uint32_t child_nx;
 	size_t offset;
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nx, nparts, elemsize, id, 1,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nparts, elemsize, id, 1,
 						     &child_nx, &offset);
 	
 
@@ -111,7 +111,7 @@ void starpu_block_filter_vertical_block(void *father_interface, void *child_inte
 
 	uint32_t child_ny;
 	size_t offset;
-	_starpu_filter_nparts_compute_chunk_size_and_offset(ny, nparts, elemsize, id, block_father->ldy,
+	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__);
@@ -151,7 +151,7 @@ void starpu_block_filter_vertical_block_shadow(void *father_interface, void *chi
 	uint32_t child_ny;
 	size_t offset;
 
-	_starpu_filter_nparts_compute_chunk_size_and_offset(ny, nparts, elemsize, id,
+	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nparts, elemsize, id,
 						     block_father->ldy,
 						     &child_ny, &offset);
 
@@ -189,7 +189,7 @@ void starpu_block_filter_depth_block(void *father_interface, void *child_interfa
 	uint32_t child_nz;
 	size_t offset;
 
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nz, nparts, elemsize, id,
+	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__);
@@ -229,7 +229,7 @@ void starpu_block_filter_depth_block_shadow(void *father_interface, void *child_
 	uint32_t child_nz;
 	size_t offset;
 
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nz, nparts, elemsize, id,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nz, nparts, elemsize, id,
 						     block_father->ldz,
 						     &child_nz, &offset);
 

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

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2008-2011,2013,2014,2016                 Université de Bordeaux
+ * Copyright (C) 2008-2011,2013,2014,2016, 2019                 Université de Bordeaux
  * Copyright (C) 2012                                     Inria
  * Copyright (C) 2010                                     Mehdi Juhoor
  * Copyright (C) 2010,2011,2013,2015,2017                 CNRS
@@ -41,7 +41,7 @@ void starpu_csr_filter_vertical_block(void *father_interface, void *child_interf
 	  STARPU_MIN(chunk_size, nrow - id*chunk_size);
 	/* TODO: the formula for the chunk size is probably wrong: we should
 	 * probably do this instead, and write a test.
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nrow, nparts, elemsize,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nrow, nparts, elemsize,
 						     id, 1, &chunk_size, NULL);
 	 */
 

+ 4 - 4
src/datawizard/interfaces/matrix_filters.c

@@ -38,7 +38,7 @@ void starpu_matrix_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,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
 						     &child_nx, &offset);
 
 	STARPU_ASSERT_MSG(matrix_father->id == STARPU_MATRIX_INTERFACE_ID, "%s can only be applied on a matrix data", __func__);
@@ -82,7 +82,7 @@ void starpu_matrix_filter_block_shadow(void *father_interface, void *child_inter
 	uint32_t child_nx;
 	size_t offset;
 
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
 						     &child_nx, &offset);
 
 	child_nx += 2 * shadow_size;
@@ -122,7 +122,7 @@ void starpu_matrix_filter_vertical_block(void *father_interface, void *child_int
 	uint32_t child_ny;
 	size_t offset;
 
-	_starpu_filter_nparts_compute_chunk_size_and_offset(ny, nchunks, elemsize, id,
+	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nchunks, elemsize, id,
 						     matrix_father->ld,
 						     &child_ny, &offset);
 
@@ -162,7 +162,7 @@ void starpu_matrix_filter_vertical_block_shadow(void *father_interface, void *ch
 	uint32_t child_ny;
 	size_t offset;
 
-	_starpu_filter_nparts_compute_chunk_size_and_offset(ny, nchunks, elemsize, id,
+	starpu_filter_nparts_compute_chunk_size_and_offset(ny, nchunks, elemsize, id,
 						     matrix_father->ld,
 						     &child_ny, &offset);
 	child_ny += 2 * shadow_size;

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

@@ -33,7 +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,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
 						     &child_nx, &offset);
 
 	STARPU_ASSERT_MSG(vector_father->id == STARPU_VECTOR_INTERFACE_ID, "%s can only be applied on a vector data", __func__);
@@ -68,7 +68,7 @@ void starpu_vector_filter_block_shadow(void *father_interface, void *child_inter
 
 	uint32_t child_nx;
 	size_t offset;
-	_starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
+	starpu_filter_nparts_compute_chunk_size_and_offset(nx, nchunks, elemsize, id, 1,
 						     &child_nx, &offset);
 	child_nx += 2*shadow_size;