data_partition.doxy 12 KB

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