insert_task.doxy 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2017 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,
  42. followed by the appropriated objects as defined elsewhere.
  43. </ul>
  44. When using ::STARPU_DATA_ARRAY, the access mode of the data handles is
  45. not defined, it will be taken from the codelet starpu_codelet::modes or starpu_codelet::dyn_modes field. One
  46. should use ::STARPU_DATA_MODE_ARRAY to define the data handles along with the
  47. access modes.
  48. Parameters to be passed to the codelet implementation are defined
  49. through the type ::STARPU_VALUE. The function
  50. starpu_codelet_unpack_args() must be called within the codelet
  51. implementation to retrieve them.
  52. \def STARPU_VALUE
  53. \ingroup API_Insert_Task
  54. Used when calling starpu_task_insert(), must
  55. be followed by a pointer to a constant value and the size of the
  56. constant
  57. \def STARPU_CL_ARGS
  58. \ingroup API_Insert_Task
  59. Used when calling starpu_task_insert(), must
  60. be followed by a memory buffer containing the arguments to be given to
  61. the task, and by the size of the arguments. The memory buffer should
  62. be the result of a previous call to starpu_codelet_pack_args(), and will be
  63. freed (i.e. starpu_task::cl_arg_free will be set to 1)
  64. \def STARPU_CL_ARGS_NFREE
  65. \ingroup API_Insert_Task
  66. Used when calling starpu_task_insert(), similarly to ::STARPU_CL_ARGS, must
  67. be followed by a memory buffer containing the arguments to be given to
  68. the task, and by the size of the arguments. The memory buffer should
  69. be the result of a previous call to starpu_codelet_pack_args(), and will NOT be
  70. freed (i.e. starpu_task::cl_arg_free will be set to 0)
  71. \def STARPU_CALLBACK
  72. \ingroup API_Insert_Task
  73. Used when calling starpu_task_insert(), must
  74. be followed by a pointer to a callback function
  75. \def STARPU_CALLBACK_WITH_ARG
  76. \ingroup API_Insert_Task
  77. Used when calling starpu_task_insert(), must
  78. be followed by two pointers: one to a callback function, and the other
  79. to be given as an argument to the callback function; this is
  80. equivalent to using both ::STARPU_CALLBACK and
  81. ::STARPU_CALLBACK_WITH_ARG.
  82. \def STARPU_CALLBACK_ARG
  83. \ingroup API_Insert_Task
  84. Used when calling starpu_task_insert(), must
  85. be followed by a pointer to be given as an argument to the callback
  86. function
  87. \def STARPU_PRIORITY
  88. \ingroup API_Insert_Task
  89. Used when calling starpu_task_insert(), must
  90. be followed by a integer defining a priority level
  91. \def STARPU_DATA_ARRAY
  92. \ingroup API_Insert_Task
  93. TODO
  94. \def STARPU_DATA_MODE_ARRAY
  95. \ingroup API_Insert_Task
  96. TODO
  97. \def STARPU_EXECUTE_ON_WORKER
  98. \ingroup API_Insert_Task
  99. Used when calling starpu_task_insert(), must be
  100. followed by an integer value specifying the worker on which to execute
  101. the task (as specified by starpu_task::execute_on_a_specific_worker)
  102. \def STARPU_WORKER_ORDER
  103. \ingroup API_Insert_Task
  104. used when calling starpu_task_insert(), must be
  105. followed by an integer value specifying the worker order in which to execute
  106. the tasks (as specified by starpu_task::workerorder)
  107. \def STARPU_TAG
  108. \ingroup API_Insert_Task
  109. Used when calling starpu_task_insert(), must be followed by a tag.
  110. \def STARPU_TAG_ONLY
  111. \ingroup API_Insert_Task
  112. Used when calling starpu_task_insert(), must be followed by a tag
  113. stored in starpu_task::tag_id. Leave starpu_task::use_tag as 0.
  114. \def STARPU_NAME
  115. \ingroup API_Insert_Task
  116. Used when calling starpu_task_insert(), must be followed by a char *
  117. stored in starpu_task::name.
  118. \def STARPU_FLOPS
  119. \ingroup API_Insert_Task
  120. Used when calling starpu_task_insert(), must
  121. be followed by an amount of floating point operations, as a double.
  122. Users <b>MUST</b> explicitly cast into double, otherwise parameter
  123. passing will not work.
  124. \def STARPU_SCHED_CTX
  125. \ingroup API_Insert_Task
  126. Used when calling starpu_task_insert(), must
  127. be followed by the id of the scheduling context to which to submit the
  128. task to.
  129. \def STARPU_TASK_DEPS_ARRAY
  130. \ingroup API_Insert_Task
  131. Used when calling starpu_task_insert(), must
  132. be followed by a number of tasks, and an array containing these tasks.
  133. The function starpu_task_declare_deps_array() will be called with the
  134. given values.
  135. \fn void starpu_task_insert_data_make_room(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int current_buffer, int room)
  136. \ingroup API_Insert_Task
  137. Assuming that there are already \p current_buffer data handles passed to
  138. the task, and if *allocated_buffers is not 0, the <c>task->dyn_handles</c>
  139. array has size \p *allocated_buffers, this function makes room for \p room
  140. other data handles, allocating or reallocating <c>task->dyn_handles</c> as
  141. necessary and updating \p *allocated_buffers accordingly. One can thus start
  142. with *allocated_buffers equal to 0 and current_buffer equal to 0, then make room
  143. by calling this function, then store handles with STARPU_TASK_SET_HANDLE(), make
  144. room again with this function, store yet more handles, etc.
  145. \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)
  146. \ingroup API_Insert_Task
  147. This stores data handle \p handle into task \p task with mode \p arg_type,
  148. updating \p *allocated_buffers and \p *current_buffer accordingly.
  149. \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)
  150. \ingroup API_Insert_Task
  151. This stores \p nb_handles data handles \p handles into task \p task, updating \p
  152. *allocated_buffers and \p *current_buffer accordingly.
  153. \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);
  154. \ingroup API_Insert_Task
  155. This stores \p nb_descrs data handles described by \p descrs into task \p task,
  156. updating \p *allocated_buffers and \p *current_buffer accordingly.
  157. \fn void starpu_codelet_pack_args(void **arg_buffer, size_t *arg_buffer_size, ...)
  158. \ingroup API_Insert_Task
  159. Pack arguments of type ::STARPU_VALUE into a buffer which can be
  160. given to a codelet and later unpacked with the function
  161. starpu_codelet_unpack_args().
  162. Instead of calling starpu_codelet_pack_args(), one can also call
  163. starpu_codelet_pack_arg_init(), then starpu_codelet_pack_arg() for each
  164. data, then starpu_codelet_pack_arg_fini().
  165. \fn void starpu_codelet_pack_arg_init(struct starpu_codelet_pack_arg *state)
  166. \ingroup API_Insert_Task
  167. Initiaze struct starpu_codelet_pack_arg before calling starpu_codelet_pack_arg and
  168. starpu_codelet_pack_arg_fini. This will simply initialize the content of the structure.
  169. \fn void starpu_codelet_pack_arg(struct starpu_codelet_pack_arg *state, void *ptr, size_t ptr_size)
  170. Pack one argument into struct starpu_codelet_pack_arg state. That structure
  171. has to be initialized before with starpu_codelet_pack_arg_init, and after all
  172. starpu_codelet_pack_arg calls performed, starpu_codelet_pack_arg_fini has to be
  173. used to get the cl_arg and cl_arg_size to be put in the task.
  174. \fn void starpu_codelet_pack_arg_fini(struct starpu_codelet_pack_arg *state, void **cl_arg, size_t *cl_arg_size)
  175. \ingroup API_Insert_Task
  176. Finish packing data, after calling starpu_codelet_pack_arg_init once and starpu_codelet_pack_arg several times.
  177. \fn void starpu_codelet_unpack_args(void *cl_arg, ...)
  178. \ingroup API_Insert_Task
  179. Retrieve the arguments of type ::STARPU_VALUE associated to a
  180. task automatically created using the function starpu_task_insert(). If
  181. any parameter's value is 0, unpacking will stop there and ignore the remaining
  182. parameters.
  183. \fn void starpu_codelet_unpack_args_and_copyleft(void *cl_arg, void *buffer, size_t buffer_size, ...)
  184. \ingroup API_Insert_Task
  185. Similar to starpu_codelet_unpack_args(), but if any parameter is
  186. 0, copy the part of \p cl_arg that has not been read in \p buffer which
  187. can then be used in a later call to one of the unpack functions.
  188. \fn struct starpu_task *starpu_task_build(struct starpu_codelet *cl, ...)
  189. \ingroup API_Insert_Task
  190. Create a task corresponding to \p cl with the following arguments.
  191. The argument list must be zero-terminated. The arguments
  192. following the codelet are the same as the ones for the function
  193. starpu_task_insert().
  194. If some arguments of type ::STARPU_VALUE are given, the parameter
  195. starpu_task::cl_arg_free will be set to 1.
  196. */