insert_task.doxy 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2019 CNRS
  4. * Copyright (C) 2009-2011,2014-2016,2018 Université de Bordeaux
  5. * Copyright (C) 2011,2012 Inria
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. /*! \defgroup API_Insert_Task Task Insert Utility
  19. \fn int starpu_insert_task(struct starpu_codelet *cl, ...)
  20. \ingroup API_Insert_Task
  21. Similar to starpu_task_insert(). Kept to avoid breaking old codes.
  22. \fn int starpu_task_insert(struct starpu_codelet *cl, ...)
  23. \ingroup API_Insert_Task
  24. Create and submit a task corresponding to \p cl with the
  25. following given arguments. The argument list must be zero-terminated.
  26. The arguments following the codelet can be of the following types:
  27. <ul>
  28. <li> ::STARPU_R, ::STARPU_W, ::STARPU_RW, ::STARPU_SCRATCH,
  29. ::STARPU_REDUX an access mode followed by a data handle;
  30. <li> ::STARPU_DATA_ARRAY followed by an array of data handles and its
  31. number of elements;
  32. <li> ::STARPU_DATA_MODE_ARRAY followed by an array of struct
  33. starpu_data_descr, i.e data handles with their associated access
  34. modes, and its number of elements;
  35. <li> ::STARPU_EXECUTE_ON_WORKER, ::STARPU_WORKER_ORDER followed by an integer value
  36. specifying the worker on which to execute the task (as specified by
  37. starpu_task::execute_on_a_specific_worker)
  38. <li> the specific values ::STARPU_VALUE, ::STARPU_CALLBACK,
  39. ::STARPU_CALLBACK_ARG, ::STARPU_CALLBACK_WITH_ARG, ::STARPU_PRIORITY,
  40. ::STARPU_TAG, ::STARPU_TAG_ONLY, ::STARPU_FLOPS, ::STARPU_SCHED_CTX, ::STARPU_CL_ARGS, ::STARPU_CL_ARGS_NFREE,
  41. ::STARPU_TASK_DEPS_ARRAY, ::STARPU_TASK_COLOR,
  42. ::STARPU_HANDLES_SEQUENTIAL_CONSISTENCY, ::STARPU_TASK_SYNCHRONOUS, ::STARPU_TASK_END_DEP
  43. followed by the appropriated objects as defined elsewhere.
  44. </ul>
  45. When using ::STARPU_DATA_ARRAY, the access mode of the data handles is
  46. not defined, it will be taken from the codelet starpu_codelet::modes or starpu_codelet::dyn_modes field. One
  47. should use ::STARPU_DATA_MODE_ARRAY to define the data handles along with the
  48. access modes.
  49. Parameters to be passed to the codelet implementation are defined
  50. through the type ::STARPU_VALUE. The function
  51. starpu_codelet_unpack_args() must be called within the codelet
  52. implementation to retrieve them.
  53. \def STARPU_VALUE
  54. \ingroup API_Insert_Task
  55. Used when calling starpu_task_insert(), must
  56. be followed by a pointer to a constant value and the size of the
  57. constant
  58. \def STARPU_CL_ARGS
  59. \ingroup API_Insert_Task
  60. Used when calling starpu_task_insert(), must
  61. be followed by a memory buffer containing the arguments to be given to
  62. the task, and by the size of the arguments. The memory buffer should
  63. be the result of a previous call to starpu_codelet_pack_args(), and will be
  64. freed (i.e. starpu_task::cl_arg_free will be set to 1)
  65. \def STARPU_CL_ARGS_NFREE
  66. \ingroup API_Insert_Task
  67. Used when calling starpu_task_insert(), similarly to ::STARPU_CL_ARGS, must
  68. be followed by a memory buffer containing the arguments to be given to
  69. the task, and by the size of the arguments. The memory buffer should
  70. be the result of a previous call to starpu_codelet_pack_args(), and will NOT be
  71. freed (i.e. starpu_task::cl_arg_free will be set to 0)
  72. \def STARPU_CALLBACK
  73. \ingroup API_Insert_Task
  74. Used when calling starpu_task_insert(), must
  75. be followed by a pointer to a callback function
  76. \def STARPU_CALLBACK_WITH_ARG
  77. \ingroup API_Insert_Task
  78. Used when calling starpu_task_insert(), must
  79. be followed by two pointers: one to a callback function, and the other
  80. to be given as an argument to the callback function; this is
  81. equivalent to using both ::STARPU_CALLBACK and
  82. ::STARPU_CALLBACK_WITH_ARG.
  83. \def STARPU_CALLBACK_ARG
  84. \ingroup API_Insert_Task
  85. Used when calling starpu_task_insert(), must
  86. be followed by a pointer to be given as an argument to the callback
  87. function
  88. \def STARPU_PRIORITY
  89. \ingroup API_Insert_Task
  90. Used when calling starpu_task_insert(), must
  91. be followed by a integer defining a priority level
  92. \def STARPU_DATA_ARRAY
  93. \ingroup API_Insert_Task
  94. TODO
  95. \def STARPU_DATA_MODE_ARRAY
  96. \ingroup API_Insert_Task
  97. TODO
  98. \def STARPU_EXECUTE_ON_WORKER
  99. \ingroup API_Insert_Task
  100. Used when calling starpu_task_insert(), must be
  101. followed by an integer value specifying the worker on which to execute
  102. the task (as specified by starpu_task::execute_on_a_specific_worker)
  103. \def STARPU_WORKER_ORDER
  104. \ingroup API_Insert_Task
  105. used when calling starpu_task_insert(), must be
  106. followed by an integer value specifying the worker order in which to execute
  107. the tasks (as specified by starpu_task::workerorder)
  108. \def STARPU_TAG
  109. \ingroup API_Insert_Task
  110. Used when calling starpu_task_insert(), must be followed by a tag.
  111. \def STARPU_TAG_ONLY
  112. \ingroup API_Insert_Task
  113. Used when calling starpu_task_insert(), must be followed by a tag
  114. stored in starpu_task::tag_id. Leave starpu_task::use_tag as 0.
  115. \def STARPU_NAME
  116. \ingroup API_Insert_Task
  117. Used when calling starpu_task_insert(), must be followed by a char *
  118. stored in starpu_task::name.
  119. \def STARPU_FLOPS
  120. \ingroup API_Insert_Task
  121. Used when calling starpu_task_insert(), must
  122. be followed by an amount of floating point operations, as a double.
  123. Users <b>MUST</b> explicitly cast into double, otherwise parameter
  124. passing will not work.
  125. \def STARPU_SCHED_CTX
  126. \ingroup API_Insert_Task
  127. Used when calling starpu_task_insert(), must
  128. be followed by the id of the scheduling context to which to submit the
  129. task to.
  130. \def STARPU_TASK_DEPS_ARRAY
  131. \ingroup API_Insert_Task
  132. Used when calling starpu_task_insert(), must
  133. be followed by a number of tasks as int, and an array containing these tasks.
  134. The function starpu_task_declare_deps_array() will be called with the
  135. given values.
  136. \def STARPU_TASK_END_DEPS_ARRAY
  137. \ingroup API_Insert_Task
  138. Used when calling starpu_task_insert(), must
  139. be followed by a number of tasks as int, and an array containing these tasks.
  140. The function starpu_task_declare_end_deps_array() will be called with the
  141. given values.
  142. \def STARPU_TASK_COLOR
  143. \ingroup API_Insert_Task
  144. Used when calling starpu_task_insert(), must be followed by an integer
  145. representing a color
  146. \def STARPU_TASK_SYNCHRONOUS
  147. \ingroup API_Insert_Task
  148. Used when calling starpu_task_insert(), must be followed by an integer
  149. stating if the task is synchronous or not
  150. \def STARPU_HANDLES_SEQUENTIAL_CONSISTENCY
  151. \ingroup API_Insert_Task
  152. Used when calling starpu_task_insert(), must be followed by an array
  153. of characters representing the sequential consistency for each buffer
  154. of the task.
  155. \def STARPU_TASK_END_DEP
  156. \ingroup API_Insert_Task
  157. Used when calling starpu_task_insert(), must be followed by an integer
  158. which will be given to starpu_task_end_dep_add()
  159. \fn void starpu_task_insert_data_make_room(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int current_buffer, int room)
  160. \ingroup API_Insert_Task
  161. Assuming that there are already \p current_buffer data handles passed to
  162. the task, and if *allocated_buffers is not 0, the <c>task->dyn_handles</c>
  163. array has size \p *allocated_buffers, this function makes room for \p room
  164. other data handles, allocating or reallocating <c>task->dyn_handles</c> as
  165. necessary and updating \p *allocated_buffers accordingly. One can thus start
  166. with *allocated_buffers equal to 0 and current_buffer equal to 0, then make room
  167. by calling this function, then store handles with STARPU_TASK_SET_HANDLE(), make
  168. room again with this function, store yet more handles, etc.
  169. \fn void starpu_task_insert_data_process_arg(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int *current_buffer, int arg_type, starpu_data_handle_t handle)
  170. \ingroup API_Insert_Task
  171. Store data handle \p handle into task \p task with mode \p arg_type,
  172. updating \p *allocated_buffers and \p *current_buffer accordingly.
  173. \fn void starpu_task_insert_data_process_array_arg(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int *current_buffer, int nb_handles, starpu_data_handle_t *handles)
  174. \ingroup API_Insert_Task
  175. Store \p nb_handles data handles \p handles into task \p task, updating \p
  176. *allocated_buffers and \p *current_buffer accordingly.
  177. \fn void starpu_task_insert_data_process_mode_array_arg(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int *current_buffer, int nb_descrs, struct starpu_data_descr *descrs);
  178. \ingroup API_Insert_Task
  179. Store \p nb_descrs data handles described by \p descrs into task \p task,
  180. updating \p *allocated_buffers and \p *current_buffer accordingly.
  181. \fn void starpu_codelet_pack_args(void **arg_buffer, size_t *arg_buffer_size, ...)
  182. \ingroup API_Insert_Task
  183. Pack arguments of type ::STARPU_VALUE into a buffer which can be
  184. given to a codelet and later unpacked with the function
  185. starpu_codelet_unpack_args().
  186. Instead of calling starpu_codelet_pack_args(), one can also call
  187. starpu_codelet_pack_arg_init(), then starpu_codelet_pack_arg() for each
  188. data, then starpu_codelet_pack_arg_fini().
  189. \fn void starpu_codelet_pack_arg_init(struct starpu_codelet_pack_arg_data *state)
  190. \ingroup API_Insert_Task
  191. Initialize struct starpu_codelet_pack_arg before calling starpu_codelet_pack_arg() and
  192. starpu_codelet_pack_arg_fini(). This will simply initialize the content of the structure.
  193. \fn void starpu_codelet_pack_arg(struct starpu_codelet_pack_arg_data *state, const void *ptr, size_t ptr_size)
  194. \ingroup API_Insert_Task
  195. Pack one argument into struct starpu_codelet_pack_arg \p state. That structure
  196. has to be initialized before with starpu_codelet_pack_arg_init(), and after all
  197. starpu_codelet_pack_arg() calls performed, starpu_codelet_pack_arg_fini() has to be
  198. used to get the \p cl_arg and \p cl_arg_size to be put in the task.
  199. \fn void starpu_codelet_pack_arg_fini(struct starpu_codelet_pack_arg_data *state, void **cl_arg, size_t *cl_arg_size)
  200. \ingroup API_Insert_Task
  201. Finish packing data, after calling starpu_codelet_pack_arg_init() once and starpu_codelet_pack_arg() several times.
  202. \fn void starpu_codelet_unpack_args(void *cl_arg, ...)
  203. \ingroup API_Insert_Task
  204. Retrieve the arguments of type ::STARPU_VALUE associated to a
  205. task automatically created using the function starpu_task_insert(). If
  206. any parameter's value is 0, unpacking will stop there and ignore the remaining
  207. parameters.
  208. \fn void starpu_codelet_unpack_args_and_copyleft(void *cl_arg, void *buffer, size_t buffer_size, ...)
  209. \ingroup API_Insert_Task
  210. Similar to starpu_codelet_unpack_args(), but if any parameter is
  211. 0, copy the part of \p cl_arg that has not been read in \p buffer which
  212. can then be used in a later call to one of the unpack functions.
  213. \fn struct starpu_task *starpu_task_build(struct starpu_codelet *cl, ...)
  214. \ingroup API_Insert_Task
  215. Create a task corresponding to \p cl with the following arguments.
  216. The argument list must be zero-terminated. The arguments
  217. following the codelet are the same as the ones for the function
  218. starpu_task_insert().
  219. If some arguments of type ::STARPU_VALUE are given, the parameter
  220. starpu_task::cl_arg_free will be set to 1.
  221. \fn int starpu_task_set(struct starpu_task *task, struct starpu_codelet *cl, ...)
  222. \ingroup API_Insert_Task
  223. Set the given \p task corresponding to \p cl with the following arguments.
  224. The argument list must be zero-terminated. The arguments
  225. following the codelet are the same as the ones for the function
  226. starpu_task_insert().
  227. If some arguments of type ::STARPU_VALUE are given, the parameter
  228. starpu_task::cl_arg_free will be set to 1.
  229. */