codelet_and_tasks.doxy 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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_Codelet_And_Tasks Codelet And Tasks
  9. \brief This section describes the interface to manipulate codelets and tasks.
  10. \enum starpu_codelet_type
  11. \ingroup API_Codelet_And_Tasks
  12. Describes the type of parallel task. See \ref ParallelTasks for details.
  13. \var starpu_codelet_type::STARPU_SEQ
  14. \ingroup API_Codelet_And_Tasks
  15. (default) for classical sequential tasks.
  16. \var starpu_codelet_type::STARPU_SPMD
  17. \ingroup API_Codelet_And_Tasks
  18. for a parallel task whose threads are handled by StarPU, the code has
  19. to use starpu_combined_worker_get_size() and
  20. starpu_combined_worker_get_rank() to distribute the work.
  21. \var starpu_codelet_type::STARPU_FORKJOIN
  22. \ingroup API_Codelet_And_Tasks
  23. for a parallel task whose threads are started by the codelet function,
  24. which has to use starpu_combined_worker_get_size() to determine how
  25. many threads should be started.
  26. \enum starpu_task_status
  27. \ingroup API_Codelet_And_Tasks
  28. Task status
  29. \var starpu_task_status::STARPU_TASK_INVALID
  30. \ingroup API_Codelet_And_Tasks
  31. The task has just been initialized.
  32. \var starpu_task_status::STARPU_TASK_BLOCKED
  33. \ingroup API_Codelet_And_Tasks
  34. The task has just been submitted, and its dependencies has not been
  35. checked yet.
  36. \var starpu_task_status::STARPU_TASK_READY
  37. \ingroup API_Codelet_And_Tasks
  38. The task is ready for execution.
  39. \var starpu_task_status::STARPU_TASK_RUNNING
  40. \ingroup API_Codelet_And_Tasks
  41. The task is running on some worker.
  42. \var starpu_task_status::STARPU_TASK_FINISHED
  43. \ingroup API_Codelet_And_Tasks
  44. The task is finished executing.
  45. \var starpu_task_status::STARPU_TASK_BLOCKED_ON_TAG
  46. \ingroup API_Codelet_And_Tasks
  47. The task is waiting for a tag.
  48. \var starpu_task_status::STARPU_TASK_BLOCKED_ON_TASK
  49. \ingroup API_Codelet_And_Tasks
  50. The task is waiting for a task.
  51. \var starpu_task_status::STARPU_TASK_BLOCKED_ON_DATA
  52. \ingroup API_Codelet_And_Tasks
  53. The task is waiting for some data.
  54. \def STARPU_CPU
  55. \ingroup API_Codelet_And_Tasks
  56. This macro is used when setting the field starpu_codelet::where
  57. to specify the codelet may be executed on a CPU processing unit.
  58. \def STARPU_CUDA
  59. \ingroup API_Codelet_And_Tasks
  60. This macro is used when setting the field starpu_codelet::where
  61. to specify the codelet may be executed on a CUDA processing unit.
  62. \def STARPU_OPENCL
  63. \ingroup API_Codelet_And_Tasks
  64. This macro is used when setting the field starpu_codelet::where to
  65. specify the codelet may be executed on a OpenCL processing unit.
  66. \def STARPU_MIC
  67. \ingroup API_Codelet_And_Tasks
  68. This macro is used when setting the field starpu_codelet::where to
  69. specify the codelet may be executed on a MIC processing unit.
  70. \def STARPU_SCC
  71. \ingroup API_Codelet_And_Tasks
  72. This macro is used when setting the field starpu_codelet::where to
  73. specify the codelet may be executed on an SCC processing unit.
  74. \def STARPU_MAIN_RAM
  75. \ingroup API_Codelet_And_Tasks
  76. This macro is used when the RAM memory node is specified.
  77. \def STARPU_MULTIPLE_CPU_IMPLEMENTATIONS
  78. \deprecated
  79. \ingroup API_Codelet_And_Tasks
  80. Setting the field starpu_codelet::cpu_func with this macro
  81. indicates the codelet will have several implementations. The use of
  82. this macro is deprecated. One should always only define the field
  83. starpu_codelet::cpu_funcs.
  84. \def STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS
  85. \deprecated
  86. \ingroup API_Codelet_And_Tasks
  87. Setting the field starpu_codelet::cuda_func with this macro
  88. indicates the codelet will have several implementations. The use of
  89. this macro is deprecated. One should always only define the field
  90. starpu_codelet::cuda_funcs.
  91. \def STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS
  92. \deprecated
  93. \ingroup API_Codelet_And_Tasks
  94. Setting the field starpu_codelet::opencl_func with
  95. this macro indicates the codelet will have several implementations.
  96. The use of this macro is deprecated. One should always only define the
  97. field starpu_codelet::opencl_funcs.
  98. \def STARPU_NMAXBUFS
  99. \ingroup API_Codelet_And_Tasks
  100. Defines the maximum number of buffers that tasks will be able to take
  101. as parameters. The default value is 8, it can be changed by using the
  102. configure option \ref enable-maxbuffers "--enable-maxbuffers".
  103. \typedef starpu_cpu_func_t
  104. \ingroup API_Codelet_And_Tasks
  105. CPU implementation of a codelet.
  106. \typedef starpu_cuda_func_t
  107. \ingroup API_Codelet_And_Tasks
  108. CUDA implementation of a codelet.
  109. \typedef starpu_opencl_func_t
  110. \ingroup API_Codelet_And_Tasks
  111. OpenCL implementation of a codelet.
  112. \typedef starpu_mic_func_t
  113. \ingroup API_Codelet_And_Tasks
  114. MIC implementation of a codelet.
  115. \typedef starpu_scc_func_t
  116. \ingroup API_Codelet_And_Tasks
  117. SCC implementation of a codelet.
  118. \typedef starpu_mic_kernel_t
  119. \ingroup API_Codelet_And_Tasks
  120. MIC kernel for a codelet
  121. \typedef *starpu_scc_kernel_t
  122. \ingroup API_Codelet_And_Tasks
  123. SCC kernel for a codelet
  124. \struct starpu_codelet
  125. The codelet structure describes a kernel that is possibly
  126. implemented on various targets. For compatibility, make sure to
  127. initialize the whole structure to zero, either by using explicit
  128. memset, or the function starpu_codelet_init(), or by letting the
  129. compiler implicitly do it in e.g. static storage case.
  130. \ingroup API_Codelet_And_Tasks
  131. \var starpu_codelet::where
  132. Optional field to indicate which types of processing units are able to
  133. execute the codelet. The different values ::STARPU_CPU, ::STARPU_CUDA,
  134. ::STARPU_OPENCL can be combined to specify on which types of processing
  135. units the codelet can be executed. ::STARPU_CPU|::STARPU_CUDA for instance
  136. indicates that the codelet is implemented for both CPU cores and CUDA
  137. devices while ::STARPU_OPENCL indicates that it is only available on
  138. OpenCL devices. If the field is unset, its value will be automatically
  139. set based on the availability of the XXX_funcs fields defined below.
  140. \var starpu_codelet::can_execute
  141. Define a function which should return 1 if the worker designated by
  142. workerid can execute the <c>nimpl</c>th implementation of the given
  143. task, 0 otherwise.
  144. \var starpu_codelet::type
  145. Optional field to specify the type of the codelet. The default is
  146. ::STARPU_SEQ, i.e. usual sequential implementation. Other values
  147. (::STARPU_SPMD or ::STARPU_FORKJOIN declare that a parallel implementation
  148. is also available. See \ref ParallelTasks for details.
  149. \var starpu_codelet::max_parallelism
  150. Optional field. If a parallel implementation is available, this
  151. denotes the maximum combined worker size that StarPU will use to
  152. execute parallel tasks for this codelet.
  153. \var starpu_codelet::cpu_func
  154. \deprecated
  155. Optional field which has been made deprecated. One should use instead
  156. the field starpu_codelet::cpu_funcs.
  157. \var starpu_codelet::cuda_func
  158. \deprecated
  159. Optional field which has been made deprecated. One should use instead
  160. the starpu_codelet::cuda_funcs field.
  161. \var starpu_codelet::opencl_func
  162. \deprecated
  163. Optional field which has been made deprecated. One should use instead
  164. the starpu_codelet::opencl_funcs field.
  165. \var starpu_codelet::cpu_funcs
  166. Optional array of function pointers to the CPU implementations of the
  167. codelet. It must be terminated by a NULL value. The functions
  168. prototype must be:
  169. \code{.c}
  170. void cpu_func(void *buffers[], void *cl_arg)
  171. \endcode
  172. The first argument being the array of data managed by the data
  173. management library, and the second argument is a pointer to the
  174. argument passed from the field starpu_task::cl_arg. If the field
  175. starpu_codelet::where is set, then the field starpu_codelet::cpu_funcs
  176. is ignored if ::STARPU_CPU does not appear in the field
  177. starpu_codelet::where, it must be non-null otherwise.
  178. \var starpu_codelet::cpu_funcs_name
  179. Optional array of strings which provide the name of the CPU functions
  180. referenced in the array starpu_codelet::cpu_funcs. This can be used
  181. when running on MIC devices or the SCC platform, for StarPU to simply
  182. look up the MIC function implementation through its name.
  183. \var starpu_codelet::cuda_funcs
  184. Optional array of function pointers to the CUDA implementations of the
  185. codelet. It must be terminated by a NULL value. The functions must be
  186. host-functions written in the CUDA runtime API. Their prototype must
  187. be:
  188. \code{.c}
  189. void cuda_func(void *buffers[], void *cl_arg)
  190. \endcode
  191. If the field starpu_codelet::where is set, then the field
  192. starpu_codelet::cuda_funcs is ignored if ::STARPU_CUDA does not appear
  193. in the field starpu_codelet::where, it must be non-null otherwise.
  194. \var starpu_codelet::opencl_funcs
  195. Optional array of function pointers to the OpenCL implementations of
  196. the codelet. It must be terminated by a NULL value. The functions
  197. prototype must be:
  198. \code{.c}
  199. void opencl_func(void *buffers[], void *cl_arg)
  200. \endcode
  201. If the field starpu_codelet::where field is set, then the field
  202. starpu_codelet::opencl_funcs is ignored if ::STARPU_OPENCL does not
  203. appear in the field starpu_codelet::where, it must be non-null
  204. otherwise.
  205. \var starpu_codelet::mic_funcs
  206. Optional array of function pointers to a function which returns the
  207. MIC implementation of the codelet. It must be terminated by a NULL
  208. value. The functions prototype must be:
  209. \code{.c}
  210. starpu_mic_kernel_t mic_func(struct starpu_codelet *cl, unsigned nimpl)
  211. \endcode
  212. If the field starpu_codelet::where is set, then the field
  213. starpu_codelet::mic_funcs is ignored if ::STARPU_MIC does not appear
  214. in the field starpu_codelet::where. It can be null if
  215. starpu_codelet::cpu_funcs_name is non-NULL, in which case StarPU will
  216. simply make a symbol lookup to get the implementation.
  217. \var starpu_codelet::scc_funcs
  218. Optional array of function pointers to a function which returns the
  219. SCC implementation of the codelet. It must be terminated by a NULL value.
  220. The functions prototype must be:
  221. \code{.c}
  222. starpu_scc_kernel_t scc_func(struct starpu_codelet *cl, unsigned nimpl)
  223. \endcode
  224. If the field starpu_codelet::where is set, then the field
  225. starpu_codelet::scc_funcs is ignored if ::STARPU_SCC does not appear
  226. in the field starpu_codelet::where. It can be null if
  227. starpu_codelet::cpu_funcs_name is non-NULL, in which case StarPU will
  228. simply make a symbol lookup to get the implementation.
  229. \var starpu_codelet::nbuffers
  230. Specify the number of arguments taken by the codelet. These arguments
  231. are managed by the DSM and are accessed from the <c>void *buffers[]</c>
  232. array. The constant argument passed with the field starpu_task::cl_arg
  233. is not counted in this number. This value should not be above
  234. \ref STARPU_NMAXBUFS.
  235. \var starpu_codelet::modes
  236. Is an array of ::starpu_data_access_mode. It describes the required
  237. access modes to the data neeeded by the codelet (e.g. ::STARPU_RW). The
  238. number of entries in this array must be specified in the field
  239. starpu_codelet::nbuffers, and should not exceed \ref STARPU_NMAXBUFS. If
  240. unsufficient, this value can be set with the configure option
  241. \ref enable-maxbuffers "--enable-maxbuffers".
  242. \var starpu_codelet::dyn_modes
  243. Is an array of ::starpu_data_access_mode. It describes the required
  244. access modes to the data neeeded by the codelet (e.g. ::STARPU_RW).
  245. The number of entries in this array must be specified in the field
  246. starpu_codelet::nbuffers. This field should be used for codelets having a
  247. number of datas greater than \ref STARPU_NMAXBUFS (see \ref
  248. SettingTheDataHandlesForATask). When defining a codelet, one
  249. should either define this field or the field starpu_codelet::modes defined above.
  250. \var starpu_codelet::model
  251. Optional pointer to the task duration performance model associated to
  252. this codelet. This optional field is ignored when set to <c>NULL</c> or when
  253. its field starpu_perfmodel::symbol is not set.
  254. \var starpu_codelet::power_model
  255. Optional pointer to the task power consumption performance model
  256. associated to this codelet. This optional field is ignored when set to
  257. <c>NULL</c> or when its field starpu_perfmodel::field is not set. In
  258. the case of parallel codelets, this has to account for all processing
  259. units involved in the parallel execution.
  260. \var starpu_codelet::per_worker_stats
  261. Optional array for statistics collected at runtime: this is filled by
  262. StarPU and should not be accessed directly, but for example by calling
  263. the function starpu_codelet_display_stats() (See
  264. starpu_codelet_display_stats() for details).
  265. \var starpu_codelet::name
  266. Optional name of the codelet. This can be useful for debugging
  267. purposes.
  268. \fn void starpu_codelet_init(struct starpu_codelet *cl)
  269. \ingroup API_Codelet_And_Tasks
  270. Initialize \p cl with default values. Codelets should
  271. preferably be initialized statically as shown in \ref
  272. DefiningACodelet. However such a initialisation is not always
  273. possible, e.g. when using C++.
  274. \struct starpu_data_descr
  275. \ingroup API_Codelet_And_Tasks
  276. This type is used to describe a data handle along with an access mode.
  277. \var starpu_data_descr::handle
  278. describes a data
  279. \var starpu_data_descr::mode
  280. describes its access mode
  281. \struct starpu_task
  282. \ingroup API_Codelet_And_Tasks
  283. The structure describes a task that can be offloaded on the
  284. various processing units managed by StarPU. It instantiates a codelet.
  285. It can either be allocated dynamically with the function
  286. starpu_task_create(), or declared statically. In the latter case, the
  287. programmer has to zero the structure starpu_task and to fill the
  288. different fields properly. The indicated default values correspond to
  289. the configuration of a task allocated with starpu_task_create().
  290. \var starpu_task::cl
  291. Is a pointer to the corresponding structure starpu_codelet. This
  292. describes where the kernel should be executed, and supplies the
  293. appropriate implementations. When set to NULL, no code is executed
  294. during the tasks, such empty tasks can be useful for synchronization
  295. purposes.
  296. \var starpu_task::buffers
  297. \deprecated
  298. This field has been made deprecated. One should use instead the
  299. field starpu_task::handles to specify the data handles accessed
  300. by the task. The access modes are now defined in the field
  301. starpu_codelet::modes.
  302. \var starpu_task::handles
  303. Is an array of ::starpu_data_handle_t. It specifies the handles to the
  304. different pieces of data accessed by the task. The number of entries
  305. in this array must be specified in the field starpu_codelet::nbuffers,
  306. and should not exceed \ref STARPU_NMAXBUFS. If unsufficient, this value can
  307. be set with the configure option \ref enable-maxbuffers "--enable-maxbuffers".
  308. \var starpu_task::dyn_handles
  309. Is an array of ::starpu_data_handle_t. It specifies the handles to the
  310. different pieces of data accessed by the task. The number of entries
  311. in this array must be specified in the field starpu_codelet::nbuffers.
  312. This field should be used for tasks having a number of datas greater
  313. than \ref STARPU_NMAXBUFS (see \ref SettingTheDataHandlesForATask).
  314. When defining a task, one should either define this field or the field
  315. starpu_task::handles defined above.
  316. \var starpu_task::interfaces
  317. The actual data pointers to the memory node where execution will
  318. happen, managed by the DSM.
  319. \var starpu_task::dyn_interfaces
  320. The actual data pointers to the memory node where execution will
  321. happen, managed by the DSM. Is used when the field
  322. starpu_task::dyn_handles is defined.
  323. \var starpu_task::cl_arg
  324. Optional pointer which is passed to the codelet through the second
  325. argument of the codelet implementation (e.g. starpu_codelet::cpu_func
  326. or starpu_codelet::cuda_func). The default value is <c>NULL</c>.
  327. \var starpu_task::cl_arg_size
  328. Optional field. For some specific drivers, the pointer
  329. starpu_task::cl_arg cannot not be directly given to the driver
  330. function. A buffer of size starpu_task::cl_arg_size needs to be
  331. allocated on the driver. This buffer is then filled with the
  332. starpu_task::cl_arg_size bytes starting at address
  333. starpu_task::cl_arg. In this case, the argument given to the codelet
  334. is therefore not the starpu_task::cl_arg pointer, but the address of
  335. the buffer in local store (LS) instead. This field is ignored for CPU,
  336. CUDA and OpenCL codelets, where the starpu_task::cl_arg pointer is
  337. given as such.
  338. \var starpu_task::cl_arg_free
  339. Optional field. In case starpu_task::cl_arg was allocated by the
  340. application through <c>malloc()</c>, setting starpu_task::cl_arg_free
  341. to 1 makes StarPU automatically call <c>free(cl_arg)</c> when
  342. destroying the task. This saves the user from defining a callback just
  343. for that. This is mostly useful when targetting MIC or SCC, where the
  344. codelet does not execute in the same memory space as the main thread.
  345. \var starpu_task::callback_func
  346. Optional field, the default value is <c>NULL</c>. This is a function
  347. pointer of prototype <c>void (*f)(void *)</c> which specifies a
  348. possible callback. If this pointer is non-null, the callback function
  349. is executed on the host after the execution of the task. Tasks which
  350. depend on it might already be executing. The callback is passed the
  351. value contained in the starpu_task::callback_arg field. No callback is
  352. executed if the field is set to NULL.
  353. \var starpu_task::callback_arg (optional) (default: NULL)
  354. Optional field, the default value is <c>NULL</c>. This is the pointer
  355. passed to the callback function. This field is ignored if the field
  356. starpu_task::callback_func is set to <c>NULL</c>.
  357. \var starpu_task::use_tag
  358. Optional field, the default value is 0. If set, this flag indicates
  359. that the task should be associated with the tag contained in the
  360. starpu_task::tag_id field. Tag allow the application to synchronize
  361. with the task and to express task dependencies easily.
  362. \var starpu_task::tag_id
  363. This optional field contains the tag associated to the task if the
  364. field starpu_task::use_tag is set, it is ignored otherwise.
  365. \var starpu_task::sequential_consistency
  366. If this flag is set (which is the default), sequential consistency is
  367. enforced for the data parameters of this task for which sequential
  368. consistency is enabled. Clearing this flag permits to disable
  369. sequential consistency for this task, even if data have it enabled.
  370. \var starpu_task::synchronous
  371. If this flag is set, the function starpu_task_submit() is blocking and
  372. returns only when the task has been executed (or if no worker is able
  373. to process the task). Otherwise, starpu_task_submit() returns
  374. immediately.
  375. \var starpu_task::priority
  376. Optional field, the default value is ::STARPU_DEFAULT_PRIO. This field
  377. indicates a level of priority for the task. This is an integer value
  378. that must be set between the return values of the function
  379. starpu_sched_get_min_priority() for the least important tasks, and
  380. that of the function starpu_sched_get_max_priority() for the most
  381. important tasks (included). The ::STARPU_MIN_PRIO and ::STARPU_MAX_PRIO
  382. macros are provided for convenience and respectively returns the value
  383. of starpu_sched_get_min_priority() and
  384. starpu_sched_get_max_priority(). Default priority is
  385. ::STARPU_DEFAULT_PRIO, which is always defined as 0 in order to allow
  386. static task initialization. Scheduling strategies that take priorities
  387. into account can use this parameter to take better scheduling
  388. decisions, but the scheduling policy may also ignore it.
  389. \var starpu_task::execute_on_a_specific_worker
  390. Default value is 0. If this flag is set, StarPU will bypass the
  391. scheduler and directly affect this task to the worker specified by the
  392. field starpu_task::workerid.
  393. \var starpu_task::workerid
  394. Optional field. If the field starpu_task::execute_on_a_specific_worker
  395. is set, this field indicates the identifier of the worker that should
  396. process this task (as returned by starpu_worker_get_id()). This field
  397. is ignored if the field starpu_task::execute_on_a_specific_worker is
  398. set to 0.
  399. \var starpu_task::bundle
  400. Optional field. The bundle that includes this task. If no bundle is
  401. used, this should be NULL.
  402. \var starpu_task::detach
  403. Optional field, default value is 1. If this flag is set, it is not
  404. possible to synchronize with the task by the means of starpu_task_wait()
  405. later on. Internal data structures are only guaranteed to be freed
  406. once starpu_task_wait() is called if the flag is not set.
  407. \var starpu_task::destroy
  408. Optional value. Default value is 0 for starpu_task_init(), and 1 for
  409. starpu_task_create(). If this flag is set, the task structure will
  410. automatically be freed, either after the execution of the callback if
  411. the task is detached, or during starpu_task_wait() otherwise. If this
  412. flag is not set, dynamically allocated data structures will not be
  413. freed until starpu_task_destroy() is called explicitly. Setting this
  414. flag for a statically allocated task structure will result in
  415. undefined behaviour. The flag is set to 1 when the task is created by
  416. calling starpu_task_create(). Note that starpu_task_wait_for_all()
  417. will not free any task.
  418. \var starpu_task::regenerate
  419. Optional field. If this flag is set, the task will be re-submitted to
  420. StarPU once it has been executed. This flag must not be set if the
  421. flag starpu_task::destroy is set.
  422. \var starpu_task::status
  423. Optional field. Current state of the task.
  424. \var starpu_task::profiling_info
  425. Optional field. Profiling information for the task.
  426. \var starpu_task::predicted
  427. Output field. Predicted duration of the task. This field is only set
  428. if the scheduling strategy uses performance models.
  429. \var starpu_task::predicted_transfer
  430. Optional field. Predicted data transfer duration for the task in
  431. microseconds. This field is only valid if the scheduling strategy uses
  432. performance models.
  433. \var starpu_task::prev
  434. \private
  435. A pointer to the previous task. This should only be used by StarPU.
  436. \var starpu_task::next
  437. \private
  438. A pointer to the next task. This should only be used by StarPU.
  439. \var starpu_task::mf_skip
  440. \private
  441. This is only used for tasks that use multiformat handle. This should
  442. only be used by StarPU.
  443. \var starpu_task::flops
  444. This can be set to the number of floating points operations that the
  445. task will have to achieve. This is useful for easily getting GFlops
  446. curves from the tool <c>starpu_perfmodel_plot</c>, and for the
  447. hypervisor load balancing.
  448. \var starpu_task::starpu_private
  449. \private
  450. This is private to StarPU, do not modify. If the task is allocated by
  451. hand (without starpu_task_create()), this field should be set to NULL.
  452. \var starpu_task::magic
  453. \private
  454. This field is set when initializing a task. The function
  455. starpu_task_submit() will fail if the field does not have the right
  456. value. This will hence avoid submitting tasks which have not been
  457. properly initialised.
  458. \var starpu_task::sched_ctx
  459. Scheduling context.
  460. \var starpu_task::hypervisor_tag
  461. Helps the hypervisor monitor the execution of this task.
  462. \var starpu_task::scheduled
  463. Whether the scheduler has pushed the task on some queue
  464. \fn void starpu_task_init(struct starpu_task *task)
  465. \ingroup API_Codelet_And_Tasks
  466. Initialize task with default values. This function is
  467. implicitly called by starpu_task_create(). By default, tasks initialized
  468. with starpu_task_init() must be deinitialized explicitly with
  469. starpu_task_clean(). Tasks can also be initialized statically, using
  470. ::STARPU_TASK_INITIALIZER.
  471. \def STARPU_TASK_INITIALIZER
  472. \ingroup API_Codelet_And_Tasks
  473. It is possible to initialize statically allocated tasks with
  474. this value. This is equivalent to initializing a structure starpu_task
  475. with the function starpu_task_init() function.
  476. \def STARPU_TASK_GET_HANDLE(task, i)
  477. \ingroup API_Codelet_And_Tasks
  478. Return the \p i th data handle of the given task. If the task
  479. is defined with a static or dynamic number of handles, will either
  480. return the \p i th element of the field starpu_task::handles or the \p
  481. i th element of the field starpu_task::dyn_handles (see \ref
  482. SettingTheDataHandlesForATask)
  483. \def STARPU_TASK_SET_HANDLE(task, handle, i)
  484. \ingroup API_Codelet_And_Tasks
  485. Set the \p i th data handle of the given task with the given
  486. dat handle. If the task is defined with a static or dynamic number of
  487. handles, will either set the \p i th element of the field
  488. starpu_task::handles or the \p i th element of the field
  489. starpu_task::dyn_handles (see \ref
  490. SettingTheDataHandlesForATask)
  491. \def STARPU_CODELET_GET_MODE(codelet, i)
  492. \ingroup API_Codelet_And_Tasks
  493. Return the access mode of the \p i th data handle of the given
  494. codelet. If the codelet is defined with a static or dynamic number of
  495. handles, will either return the \p i th element of the field
  496. starpu_codelet::modes or the \p i th element of the field
  497. starpu_codelet::dyn_modes (see \ref
  498. SettingTheDataHandlesForATask)
  499. \def STARPU_CODELET_SET_MODE(codelet, mode, i)
  500. \ingroup API_Codelet_And_Tasks
  501. Set the access mode of the \p i th data handle of the given
  502. codelet. If the codelet is defined with a static or dynamic number of
  503. handles, will either set the \p i th element of the field
  504. starpu_codelet::modes or the \p i th element of the field
  505. starpu_codelet::dyn_modes (see \ref
  506. SettingTheDataHandlesForATask)
  507. \fn struct starpu_task *starpu_task_create(void)
  508. \ingroup API_Codelet_And_Tasks
  509. Allocate a task structure and initialize it with default
  510. values. Tasks allocated dynamically with starpu_task_create() are
  511. automatically freed when the task is terminated. This means that the
  512. task pointer can not be used any more once the task is submitted,
  513. since it can be executed at any time (unless dependencies make it
  514. wait) and thus freed at any time. If the field starpu_task::destroy is
  515. explicitly unset, the resources used by the task have to be freed by
  516. calling starpu_task_destroy().
  517. \fn struct starpu_task *starpu_task_dup(struct starpu_task *task)
  518. \ingroup API_Codelet_And_Tasks
  519. Allocate a task structure which is the exact duplicate of the
  520. given task.
  521. \fn void starpu_task_clean(struct starpu_task *task)
  522. \ingroup API_Codelet_And_Tasks
  523. Release all the structures automatically allocated to execute
  524. task, but not the task structure itself and values set by the user
  525. remain unchanged. It is thus useful for statically allocated tasks for
  526. instance. It is also useful when users want to execute the same
  527. operation several times with as least overhead as possible. It is
  528. called automatically by starpu_task_destroy(). It has to be called
  529. only after explicitly waiting for the task or after starpu_shutdown()
  530. (waiting for the callback is not enough, since StarPU still
  531. manipulates the task after calling the callback).
  532. \fn void starpu_task_destroy(struct starpu_task *task)
  533. \ingroup API_Codelet_And_Tasks
  534. Free the resource allocated during starpu_task_create() and
  535. associated with task. This function is already called automatically
  536. after the execution of a task when the field starpu_task::destroy is
  537. set, which is the default for tasks created by starpu_task_create().
  538. Calling this function on a statically allocated task results in an
  539. undefined behaviour.
  540. \fn int starpu_task_wait(struct starpu_task *task)
  541. \ingroup API_Codelet_And_Tasks
  542. This function blocks until \p task has been executed. It is not
  543. possible to synchronize with a task more than once. It is not possible
  544. to wait for synchronous or detached tasks. Upon successful completion,
  545. this function returns 0. Otherwise, <c>-EINVAL</c> indicates that the
  546. specified task was either synchronous or detached.
  547. \fn int starpu_task_submit(struct starpu_task *task)
  548. \ingroup API_Codelet_And_Tasks
  549. This function submits task to StarPU. Calling this function
  550. does not mean that the task will be executed immediately as there can
  551. be data or task (tag) dependencies that are not fulfilled yet: StarPU
  552. will take care of scheduling this task with respect to such
  553. dependencies. This function returns immediately if the field
  554. starpu_task::synchronous is set to 0, and block until the
  555. termination of the task otherwise. It is also possible to synchronize
  556. the application with asynchronous tasks by the means of tags, using
  557. the function starpu_tag_wait() function for instance. In case of
  558. success, this function returns 0, a return value of <c>-ENODEV</c>
  559. means that there is no worker able to process this task (e.g. there is
  560. no GPU available and this task is only implemented for CUDA devices).
  561. starpu_task_submit() can be called from anywhere, including codelet
  562. functions and callbacks, provided that the field
  563. starpu_task::synchronous is set to 0.
  564. \fn int starpu_task_submit_to_ctx(struct starpu_task *task, unsigned sched_ctx_id)
  565. \ingroup API_Codelet_And_Tasks
  566. This function submits a task to StarPU to the context <c> sched_ctx_id </c>.
  567. By default starpu_task_submit submits the task to a global context that is
  568. created automatically by StarPU.
  569. \fn int starpu_task_wait_for_all(void)
  570. \ingroup API_Codelet_And_Tasks
  571. This function blocks until all the tasks that were submitted
  572. (to the current context or the global one if there aren't any) are
  573. terminated. It does not destroy these tasks.
  574. \fn int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx_id)
  575. \ingroup API_Codelet_And_Tasks
  576. This function waits until all the tasks that were already
  577. submitted to the context \p sched_ctx_id have been executed
  578. \fn int starpu_task_nready(void)
  579. \ingroup API_Codelet_And_Tasks
  580. TODO
  581. \fn int starpu_task_nsubmitted(void)
  582. \ingroup API_Codelet_And_Tasks
  583. Return the number of submitted tasks which have not completed yet.
  584. \fn int starpu_task_nready(void)
  585. \ingroup API_Codelet_And_Tasks
  586. Return the number of submitted tasks which are ready for
  587. execution are already executing. It thus does not include tasks
  588. waiting for dependencies.
  589. \fn struct starpu_task *starpu_task_get_current(void)
  590. \ingroup API_Codelet_And_Tasks
  591. This function returns the task currently executed by the
  592. worker, or <c>NULL</c> if it is called either from a thread that is not a
  593. task or simply because there is no task being executed at the moment.
  594. \fn void starpu_codelet_display_stats(struct starpu_codelet *cl)
  595. \ingroup API_Codelet_And_Tasks
  596. Output on stderr some statistics on the codelet \p cl.
  597. \fn int starpu_task_wait_for_no_ready(void)
  598. \ingroup API_Codelet_And_Tasks
  599. This function waits until there is no more ready task.
  600. \fn void starpu_task_set_implementation(struct starpu_task *task, unsigned impl)
  601. \ingroup API_Codelet_And_Tasks
  602. This function should be called by schedulers to specify the
  603. codelet implementation to be executed when executing the task.
  604. \fn unsigned starpu_task_get_implementation(struct starpu_task *task)
  605. \ingroup API_Codelet_And_Tasks
  606. This function return the codelet implementation to be executed
  607. when executing the task.
  608. \fn void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps, void (*callback)(void *), void *callback_arg)
  609. \ingroup API_Codelet_And_Tasks
  610. This creates (and submits) an empty task that unlocks a tag once all
  611. its dependencies are fulfilled.
  612. */