data_partition.doxy 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2009--2011 Universit@'e de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  6. * See the file version.doxy for copying conditions.
  7. */
  8. /*! \defgroup Data_Partition Data Partition
  9. \struct starpu_data_filter
  10. \brief The filter structure describes a data partitioning operation, to be given to the starpu_data_partition() function.
  11. \ingroup Data_Partition
  12. \var starpu_data_filter::filter_func
  13. This function fills the child_interface structure with interface
  14. information for the id-th child of the parent father_interface (among
  15. nparts).
  16. \var starpu_data_filter::nchildren
  17. This is the number of parts to partition the data into.
  18. \var starpu_data_filter::get_nchildren
  19. This returns the number of children. This can be used instead of
  20. nchildren when the number of children depends on the actual data (e.g.
  21. the number of blocks in a sparse matrix).
  22. \var starpu_data_filter::get_child_ops
  23. In case the resulting children use a different data interface, this
  24. function returns which interface is used by child number id.
  25. \var starpu_data_filter::filter_arg
  26. Allow to define an additional parameter for the filter function.
  27. \var starpu_data_filter::filter_arg_ptr
  28. Allow to define an additional pointer parameter for the filter
  29. function, such as the sizes of the different parts.
  30. @name Basic API
  31. \ingroup Data_Partition
  32. \fn void starpu_data_partition(starpu_data_handle_t initial_handle, struct starpu_data_filter *f)
  33. \ingroup Data_Partition
  34. This requests partitioning one StarPU data initial_handle into
  35. several subdata according to the filter \p f.
  36. Here an example of how to use the function.
  37. \code{.c}
  38. struct starpu_data_filter f = {
  39. .filter_func = starpu_matrix_filter_block,
  40. .nchildren = nslicesx,
  41. .get_nchildren = NULL,
  42. .get_child_ops = NULL
  43. };
  44. starpu_data_partition(A_handle, &f);
  45. \endcode
  46. \fn void starpu_data_unpartition(starpu_data_handle_t root_data, unsigned gathering_node)
  47. \ingroup Data_Partition
  48. This unapplies one filter, thus unpartitioning the data. The
  49. pieces of data are collected back into one big piece in the
  50. \p gathering_node (usually 0). Tasks working on the partitioned data must
  51. be already finished when calling starpu_data_unpartition().
  52. Here an example of how to use the function.
  53. \code{.c}
  54. starpu_data_unpartition(A_handle, 0);
  55. \endcode
  56. \fn int starpu_data_get_nb_children(starpu_data_handle_t handle)
  57. \ingroup Data_Partition
  58. This function returns the number of children.
  59. \fn starpu_data_handle_t starpu_data_get_child(starpu_data_handle_t handle, unsigned i)
  60. \ingroup Data_Partition
  61. Return the ith child of the given \p handle, which must have been
  62. partitionned beforehand.
  63. \fn starpu_data_handle_t starpu_data_get_sub_data (starpu_data_handle_t root_data, unsigned depth, ... )
  64. \ingroup Data_Partition
  65. After partitioning a StarPU data by applying a filter,
  66. starpu_data_get_sub_data() can be used to get handles for each of the
  67. data portions. \p root_data is the parent data that was partitioned.
  68. \p depth is the number of filters to traverse (in case several filters
  69. have been applied, to e.g. partition in row blocks, and then in column
  70. blocks), and the subsequent parameters are the indexes. The function
  71. returns a handle to the subdata.
  72. Here an example of how to use the function.
  73. \code{.c}
  74. h = starpu_data_get_sub_data(A_handle, 1, taskx);
  75. \endcode
  76. \fn starpu_data_handle_t starpu_data_vget_sub_data(starpu_data_handle_t root_data, unsigned depth, va_list pa)
  77. \ingroup Data_Partition
  78. This function is similar to starpu_data_get_sub_data() but uses a
  79. va_list for the parameter list.
  80. \fn void starpu_data_map_filters(starpu_data_handle_t root_data, unsigned nfilters, ...)
  81. \ingroup Data_Partition
  82. Applies \p nfilters filters to the handle designated by
  83. \p root_handle recursively. \p nfilters pointers to variables of the type
  84. starpu_data_filter should be given.
  85. \fn void starpu_data_vmap_filters(starpu_data_handle_t root_data, unsigned nfilters, va_list pa)
  86. \ingroup Data_Partition
  87. Applies \p nfilters filters to the handle designated by
  88. \p root_handle recursively. It uses a va_list of pointers to variables of
  89. the type starpu_data_filter.
  90. @name Predefined Vector Filter Functions
  91. \ingroup Data_Partition
  92. This section gives a partial list of the predefined partitioning
  93. functions for vector data. Examples on how to use them are shown in
  94. \ref Partitioning_Data. The complete list can be found in the file
  95. starpu_data_filters.h.
  96. \fn void starpu_vector_filter_block(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  97. \ingroup Data_Partition
  98. Return in \p child_interface the \p id th element of the vector
  99. represented by \p father_interface once partitioned in \p nparts chunks of
  100. equal size.
  101. \fn void starpu_vector_filter_block_shadow(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  102. \ingroup Data_Partition
  103. Return in \p child_interface the \p id th element of the vector
  104. represented by \p father_interface once partitioned in \p nparts chunks of
  105. equal size with a shadow border <c>filter_arg_ptr</c>, thus getting a vector
  106. of size (n-2*shadow)/nparts+2*shadow. The <c>filter_arg_ptr</c> field
  107. of \p f must be the shadow size casted into void*. <b>IMPORTANT</b>:
  108. This can only be used for read-only access, as no coherency is
  109. enforced for the shadowed parts. An usage example is available in
  110. examples/filters/shadow.c
  111. \fn void starpu_vector_filter_list(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  112. \ingroup Data_Partition
  113. Return in \p child_interface the \p id th element of the vector
  114. represented by \p father_interface once partitioned into \p nparts chunks
  115. according to the <c>filter_arg_ptr</c> field of \p f. The
  116. <c>filter_arg_ptr</c> field must point to an array of \p nparts uint32_t
  117. elements, each of which specifies the number of elements in each chunk
  118. of the partition.
  119. \fn void starpu_vector_filter_divide_in_2(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  120. \ingroup Data_Partition
  121. Return in \p child_interface the \p id th element of the vector
  122. represented by \p father_interface once partitioned in <c>2</c> chunks of
  123. equal size, ignoring nparts. Thus, \p id must be <c>0</c> or <c>1</c>.
  124. @name Predefined Matrix Filter Functions
  125. \ingroup Data_Partition
  126. This section gives a partial list of the predefined partitioning
  127. functions for matrix data. Examples on how to use them are shown in
  128. \ref Partitioning_Data. The complete list can be found in the file
  129. starpu_data_filters.h.
  130. \fn void starpu_matrix_filter_block(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  131. \ingroup Data_Partition
  132. This partitions a dense Matrix along the x dimension, thus
  133. getting (x/\p nparts ,y) matrices. If \p nparts does not divide x, the
  134. last submatrix contains the remainder.
  135. \fn void starpu_matrix_filter_block_shadow(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  136. \ingroup Data_Partition
  137. This partitions a dense Matrix along the x dimension, with a
  138. shadow border <c>filter_arg_ptr</c>, thus getting ((x-2*shadow)/\p
  139. nparts +2*shadow,y) matrices. If \p nparts does not divide x-2*shadow,
  140. the last submatrix contains the remainder. <b>IMPORTANT</b>: This can
  141. only be used for read-only access, as no coherency is enforced for the
  142. shadowed parts. A usage example is available in
  143. examples/filters/shadow2d.c
  144. \fn void starpu_matrix_filter_vertical_block(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  145. \ingroup Data_Partition
  146. This partitions a dense Matrix along the y dimension, thus
  147. getting (x,y/\p nparts) matrices. If \p nparts does not divide y, the
  148. last submatrix contains the remainder.
  149. \fn void starpu_matrix_filter_vertical_block_shadow(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  150. \ingroup Data_Partition
  151. This partitions a dense Matrix along the y dimension, with a
  152. shadow border <c>filter_arg_ptr</c>, thus getting
  153. (x,(y-2*shadow)/\p nparts +2*shadow) matrices. If \p nparts does not
  154. divide y-2*shadow, the last submatrix contains the remainder.
  155. <b>IMPORTANT</b>: This can only be used for read-only access, as no
  156. coherency is enforced for the shadowed parts. A usage example is
  157. available in examples/filters/shadow2d.c
  158. @name Predefined Block Filter Functions
  159. \ingroup Data_Partition
  160. This section gives a partial list of the predefined partitioning
  161. functions for block data. Examples on how to use them are shown in
  162. \ref Partitioning_Data. The complete list can be found in the file
  163. starpu_data_filters.h. A usage example is available in
  164. examples/filters/shadow3d.c
  165. \fn void starpu_block_filter_block (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  166. \ingroup Data_Partition
  167. This partitions a block along the X dimension, thus getting
  168. (x/\p nparts ,y,z) 3D matrices. If \p nparts does not divide x, the last
  169. submatrix contains the remainder.
  170. \fn void starpu_block_filter_block_shadow (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  171. \ingroup Data_Partition
  172. This partitions a block along the X dimension, with a
  173. shadow border <p>filter_arg_ptr</p>, thus getting
  174. ((x-2*shadow)/\p nparts +2*shadow,y,z) blocks. If \p nparts does not
  175. divide x, the last submatrix contains the remainder. <b>IMPORTANT</b>:
  176. This can only be used for read-only access, as no coherency is
  177. enforced for the shadowed parts.
  178. \fn void starpu_block_filter_vertical_block (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  179. \ingroup Data_Partition
  180. This partitions a block along the Y dimension, thus getting
  181. (x,y/\p nparts ,z) blocks. If \p nparts does not divide y, the last
  182. submatrix contains the remainder.
  183. \fn void starpu_block_filter_vertical_block_shadow (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  184. \ingroup Data_Partition
  185. This partitions a block along the Y dimension, with a
  186. shadow border <p>filter_arg_ptr</p>, thus getting
  187. (x,(y-2*shadow)/\p nparts +2*shadow,z) 3D matrices. If \p nparts does not
  188. divide y, the last submatrix contains the remainder. <b>IMPORTANT</b>:
  189. This can only be used for read-only access, as no coherency is
  190. enforced for the shadowed parts.
  191. \fn void starpu_block_filter_depth_block (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  192. \ingroup Data_Partition
  193. This partitions a block along the Z dimension, thus getting
  194. (x,y,z/\p nparts) blocks. If \p nparts does not divide z, the last
  195. submatrix contains the remainder.
  196. \fn void starpu_block_filter_depth_block_shadow (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  197. \ingroup Data_Partition
  198. This partitions a block along the Z dimension, with a
  199. shadow border <p>filter_arg_ptr</p>, thus getting
  200. (x,y,(z-2*shadow)/\p nparts +2*shadow) blocks. If \p nparts does not
  201. divide z, the last submatrix contains the remainder. <b>IMPORTANT</b>:
  202. This can only be used for read-only access, as no coherency is
  203. enforced for the shadowed parts.
  204. @name Predefined BCSR Filter Functions
  205. \ingroup Data_Partition
  206. This section gives a partial list of the predefined partitioning
  207. functions for BCSR data. Examples on how to use them are shown in
  208. \ref Partitioning_Data. The complete list can be found in the file
  209. starpu_data_filters.h.
  210. \fn void starpu_bcsr_filter_canonical_block (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  211. \ingroup Data_Partition
  212. This partitions a block-sparse matrix into dense matrices.
  213. \fn void starpu_csr_filter_vertical_block (void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, unsigned nparts)
  214. \ingroup Data_Partition
  215. This partitions a block-sparse matrix into vertical
  216. block-sparse matrices.
  217. */