codelet_and_tasks.doxy 27 KB

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