starpu_task.h 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2011 Télécom-SudParis
  5. * Copyright (C) 2016 Uppsala University
  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. #ifndef __STARPU_TASK_H__
  19. #define __STARPU_TASK_H__
  20. #include <starpu.h>
  21. #include <errno.h>
  22. #include <assert.h>
  23. #if defined STARPU_USE_CUDA && !defined STARPU_DONT_INCLUDE_CUDA_HEADERS
  24. # include <cuda.h>
  25. #endif
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. /**
  31. @defgroup API_Codelet_And_Tasks Codelet And Tasks
  32. @brief This section describes the interface to manipulate codelets
  33. and tasks.
  34. @{
  35. */
  36. /**
  37. To be used when setting the field starpu_codelet::where to specify
  38. that the codelet has no computation part, and thus does not need to
  39. be scheduled, and data does not need to be actually loaded. This is
  40. thus essentially used for synchronization tasks.
  41. */
  42. #define STARPU_NOWHERE ((1ULL)<<0)
  43. /**
  44. Convert from enum starpu_worker_archtype to worker type mask for use in "where" fields
  45. */
  46. #define STARPU_WORKER_TO_MASK(worker_archtype) (1ULL << (worker_archtype + 1))
  47. /**
  48. To be used when setting the field starpu_codelet::where (or
  49. starpu_task::where) to specify the codelet (or the task) may be
  50. executed on a CPU processing unit.
  51. */
  52. #define STARPU_CPU STARPU_WORKER_TO_MASK(STARPU_CPU_WORKER)
  53. /**
  54. To be used when setting the field starpu_codelet::where (or
  55. starpu_task::where) to specify the codelet (or the task) may be
  56. executed on a CUDA processing unit.
  57. */
  58. #define STARPU_CUDA STARPU_WORKER_TO_MASK(STARPU_CUDA_WORKER)
  59. /**
  60. To be used when setting the field starpu_codelet::where (or
  61. starpu_task::where) to specify the codelet (or the task) may be
  62. executed on a OpenCL processing unit.
  63. */
  64. #define STARPU_OPENCL STARPU_WORKER_TO_MASK(STARPU_OPENCL_WORKER)
  65. /**
  66. To be used when setting the field starpu_codelet::where (or
  67. starpu_task::where) to specify the codelet (or the task) may be
  68. executed on a MAX FPGA.
  69. */
  70. #define STARPU_FPGA STARPU_WORKER_TO_MASK(STARPU_FPGA_WORKER)
  71. /**
  72. To be used when setting the field starpu_codelet::where (or
  73. starpu_task::where) to specify the codelet (or the task) may be
  74. executed on a MPI Slave processing unit.
  75. */
  76. #define STARPU_MPI_MS STARPU_WORKER_TO_MASK(STARPU_MPI_MS_WORKER)
  77. /**
  78. Value to be set in starpu_codelet::flags to execute the codelet
  79. functions even in simgrid mode.
  80. */
  81. #define STARPU_CODELET_SIMGRID_EXECUTE (1<<0)
  82. /**
  83. Value to be set in starpu_codelet::flags to execute the codelet
  84. functions even in simgrid mode, and later inject the measured
  85. timing inside the simulation.
  86. */
  87. #define STARPU_CODELET_SIMGRID_EXECUTE_AND_INJECT (1<<1)
  88. /**
  89. Value to be set in starpu_codelet::flags to make starpu_task_submit()
  90. not submit automatic asynchronous partitioning/unpartitioning.
  91. */
  92. #define STARPU_CODELET_NOPLANS (1<<2)
  93. /**
  94. Value to be set in starpu_codelet::cuda_flags to allow asynchronous
  95. CUDA kernel execution.
  96. */
  97. #define STARPU_CUDA_ASYNC (1<<0)
  98. /**
  99. Value to be set in starpu_codelet::opencl_flags to allow
  100. asynchronous OpenCL kernel execution.
  101. */
  102. #define STARPU_OPENCL_ASYNC (1<<0)
  103. /**
  104. To be used when the RAM memory node is specified.
  105. */
  106. #define STARPU_MAIN_RAM 0
  107. /**
  108. Describe the type of parallel task. See \ref ParallelTasks for
  109. details.
  110. */
  111. enum starpu_codelet_type
  112. {
  113. STARPU_SEQ = 0, /**< (default) for classical sequential
  114. tasks.
  115. */
  116. STARPU_SPMD, /**< for a parallel task whose threads are
  117. handled by StarPU, the code has to use
  118. starpu_combined_worker_get_size() and
  119. starpu_combined_worker_get_rank() to
  120. distribute the work.
  121. */
  122. STARPU_FORKJOIN /**< for a parallel task whose threads are
  123. started by the codelet function, which has
  124. to use starpu_combined_worker_get_size() to
  125. determine how many threads should be
  126. started.
  127. */
  128. };
  129. enum starpu_task_status
  130. {
  131. STARPU_TASK_INIT, /**< The task has just been initialized. */
  132. #define STARPU_TASK_INIT 0
  133. #define STARPU_TASK_INVALID STARPU_TASK_INIT /**< old name for STARPU_TASK_INIT */
  134. STARPU_TASK_BLOCKED, /**< The task has just been
  135. submitted, and its dependencies has not been checked yet. */
  136. STARPU_TASK_READY, /**< The task is ready for execution. */
  137. STARPU_TASK_RUNNING, /**< The task is running on some worker. */
  138. STARPU_TASK_FINISHED, /**< The task is finished executing. */
  139. STARPU_TASK_BLOCKED_ON_TAG, /**< The task is waiting for a tag. */
  140. STARPU_TASK_BLOCKED_ON_TASK, /**< The task is waiting for a task. */
  141. STARPU_TASK_BLOCKED_ON_DATA, /**< The task is waiting for some data. */
  142. STARPU_TASK_STOPPED /**< The task is stopped. */
  143. };
  144. /**
  145. CPU implementation of a codelet.
  146. */
  147. typedef void (*starpu_cpu_func_t)(void **, void*);
  148. /**
  149. CUDA implementation of a codelet.
  150. */
  151. typedef void (*starpu_cuda_func_t)(void **, void*);
  152. /**
  153. OpenCL implementation of a codelet.
  154. */
  155. typedef void (*starpu_opencl_func_t)(void **, void*);
  156. /**
  157. FPGA implementation of a codelet.
  158. */
  159. typedef void (*starpu_fpga_func_t)(void **, void*);
  160. /**
  161. MPI Master Slave kernel for a codelet
  162. */
  163. typedef void (*starpu_mpi_ms_kernel_t)(void **, void*);
  164. /**
  165. MPI Master Slave implementation of a codelet.
  166. */
  167. typedef starpu_mpi_ms_kernel_t (*starpu_mpi_ms_func_t)(void);
  168. /**
  169. @deprecated
  170. Setting the field starpu_codelet::cpu_func with this macro
  171. indicates the codelet will have several implementations. The use of
  172. this macro is deprecated. One should always only define the field
  173. starpu_codelet::cpu_funcs.
  174. */
  175. #define STARPU_MULTIPLE_CPU_IMPLEMENTATIONS ((starpu_cpu_func_t) -1)
  176. /**
  177. @deprecated
  178. Setting the field starpu_codelet::cuda_func with this macro
  179. indicates the codelet will have several implementations. The use of
  180. this macro is deprecated. One should always only define the field
  181. starpu_codelet::cuda_funcs.
  182. */
  183. #define STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS ((starpu_cuda_func_t) -1)
  184. /**
  185. @deprecated
  186. Setting the field starpu_codelet::opencl_func with this macro
  187. indicates the codelet will have several implementations. The use of
  188. this macro is deprecated. One should always only define the field
  189. starpu_codelet::opencl_funcs.
  190. */
  191. #define STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS ((starpu_opencl_func_t) -1)
  192. /**
  193. @deprecated
  194. Setting the field starpu_codelet::fpga_func with this macro
  195. indicates the codelet will have several implementations. The use of
  196. this macro is deprecated. One should always only define the field
  197. starpu_codelet::fpga_funcs.
  198. */
  199. #define STARPU_MULTIPLE_FPGA_IMPLEMENTATIONS ((starpu_fpga_func_t) -1)
  200. /**
  201. Value to set in starpu_codelet::nbuffers to specify that the
  202. codelet can accept a variable number of buffers, specified in
  203. starpu_task::nbuffers.
  204. */
  205. #define STARPU_VARIABLE_NBUFFERS (-1)
  206. /**
  207. Value to be set in the starpu_codelet::nodes field to request
  208. StarPU to put the data in local memory of the worker running the task (this
  209. is the default behavior).
  210. */
  211. #define STARPU_SPECIFIC_NODE_LOCAL (-1)
  212. /**
  213. Value to be set in the starpu_codelet::nodes field to request
  214. StarPU to put the data in CPU-accessible memory (and let StarPU
  215. choose the NUMA node).
  216. */
  217. #define STARPU_SPECIFIC_NODE_CPU (-2)
  218. /**
  219. Value to be set in the starpu_codelet::nodes field to request
  220. StarPU to put the data in some slow memory.
  221. */
  222. #define STARPU_SPECIFIC_NODE_SLOW (-3)
  223. /**
  224. Value to be set in the starpu_codelet::nodes field to request
  225. StarPU to put the data in some fast memory.
  226. */
  227. #define STARPU_SPECIFIC_NODE_FAST (-4)
  228. /**
  229. Value to be set in the starpu_codelet::nodes field to let StarPU decide
  230. whether to put the data in the local memory of the worker running the task,
  231. or in CPU-accessible memory (and let StarPU choose the NUMA node).
  232. */
  233. #define STARPU_SPECIFIC_NODE_LOCAL_OR_CPU (-5)
  234. struct starpu_task;
  235. /**
  236. The codelet structure describes a kernel that is possibly
  237. implemented on various targets. For compatibility, make sure to
  238. initialize the whole structure to zero, either by using explicit
  239. memset, or the function starpu_codelet_init(), or by letting the
  240. compiler implicitly do it in e.g. static storage case.
  241. */
  242. struct starpu_codelet
  243. {
  244. /**
  245. Optional field to indicate which types of processing units
  246. are able to execute the codelet. The different values
  247. ::STARPU_CPU, ::STARPU_CUDA, ::STARPU_OPENCL can be
  248. combined to specify on which types of processing units the
  249. codelet can be executed. ::STARPU_CPU|::STARPU_CUDA for
  250. instance indicates that the codelet is implemented for both
  251. CPU cores and CUDA devices while ::STARPU_OPENCL indicates
  252. that it is only available on OpenCL devices. If the field
  253. is unset, its value will be automatically set based on the
  254. availability of the XXX_funcs fields defined below. It can
  255. also be set to ::STARPU_NOWHERE to specify that no
  256. computation has to be actually done.
  257. */
  258. uint32_t where;
  259. /**
  260. Define a function which should return 1 if the worker
  261. designated by \p workerid can execute the \p nimpl -th
  262. implementation of \p task, 0 otherwise.
  263. */
  264. int (*can_execute)(unsigned workerid, struct starpu_task *task, unsigned nimpl);
  265. /**
  266. Optional field to specify the type of the codelet. The
  267. default is ::STARPU_SEQ, i.e. usual sequential
  268. implementation. Other values (::STARPU_SPMD or
  269. ::STARPU_FORKJOIN) declare that a parallel implementation is
  270. also available. See \ref ParallelTasks for details.
  271. */
  272. enum starpu_codelet_type type;
  273. /**
  274. Optional field. If a parallel implementation is available,
  275. this denotes the maximum combined worker size that StarPU
  276. will use to execute parallel tasks for this codelet.
  277. */
  278. int max_parallelism;
  279. /**
  280. @deprecated
  281. Optional field which has been made deprecated. One should
  282. use instead the field starpu_codelet::cpu_funcs.
  283. */
  284. starpu_cpu_func_t cpu_func STARPU_DEPRECATED;
  285. /**
  286. @deprecated
  287. Optional field which has been made deprecated. One should
  288. use instead the starpu_codelet::cuda_funcs field.
  289. */
  290. starpu_cuda_func_t cuda_func STARPU_DEPRECATED;
  291. /**
  292. @deprecated
  293. Optional field which has been made deprecated. One should
  294. use instead the starpu_codelet::opencl_funcs field.
  295. */
  296. starpu_opencl_func_t opencl_func STARPU_DEPRECATED;
  297. /**
  298. @deprecated
  299. Optional field which has been made deprecated. One should
  300. use instead the starpu_codelet::fpga_funcs field.
  301. */
  302. starpu_fpga_func_t fpga_func STARPU_DEPRECATED;
  303. /**
  304. Optional array of function pointers to the CPU
  305. implementations of the codelet. The functions prototype
  306. must be:
  307. \code{.c}
  308. void cpu_func(void *buffers[], void *cl_arg)
  309. \endcode
  310. The first argument being the array of data managed by the
  311. data management library, and the second argument is a
  312. pointer to the argument passed from the field
  313. starpu_task::cl_arg. If the field starpu_codelet::where is
  314. set, then the field tarpu_codelet::cpu_funcs is ignored if
  315. ::STARPU_CPU does not appear in the field
  316. starpu_codelet::where, it must be non-<c>NULL</c> otherwise.
  317. */
  318. starpu_cpu_func_t cpu_funcs[STARPU_MAXIMPLEMENTATIONS];
  319. /**
  320. Optional array of function pointers to the CUDA
  321. implementations of the codelet. The functions must be
  322. host-functions written in the CUDA runtime API. Their
  323. prototype must be:
  324. \code{.c}
  325. void cuda_func(void *buffers[], void *cl_arg)
  326. \endcode
  327. If the field starpu_codelet::where is set, then the field
  328. starpu_codelet::cuda_funcs is ignored if ::STARPU_CUDA does
  329. not appear in the field starpu_codelet::where, it must be
  330. non-<c>NULL</c> otherwise.
  331. */
  332. starpu_cuda_func_t cuda_funcs[STARPU_MAXIMPLEMENTATIONS];
  333. /**
  334. Optional array of flags for CUDA execution. They specify
  335. some semantic details about CUDA kernel execution, such as
  336. asynchronous execution.
  337. */
  338. char cuda_flags[STARPU_MAXIMPLEMENTATIONS];
  339. /**
  340. Optional array of function pointers to the OpenCL
  341. implementations of the codelet. The functions prototype
  342. must be:
  343. \code{.c}
  344. void opencl_func(void *buffers[], void *cl_arg)
  345. \endcode
  346. If the field starpu_codelet::where field is set, then the
  347. field starpu_codelet::opencl_funcs is ignored if
  348. ::STARPU_OPENCL does not appear in the field
  349. starpu_codelet::where, it must be non-<c>NULL</c> otherwise.
  350. */
  351. starpu_opencl_func_t opencl_funcs[STARPU_MAXIMPLEMENTATIONS];
  352. /**
  353. Optional array of flags for OpenCL execution. They specify
  354. some semantic details about OpenCL kernel execution, such
  355. as asynchronous execution.
  356. */
  357. char opencl_flags[STARPU_MAXIMPLEMENTATIONS];
  358. /**
  359. Optional array of function pointers to the FPGA
  360. implementations of the codelet. The functions prototype
  361. must be:
  362. \code{.c}
  363. void fpga_func(void *buffers[], void *cl_arg)
  364. \endcode
  365. The first argument being the array of data managed by the
  366. data management library, and the second argument is a
  367. pointer to the argument passed from the field
  368. starpu_task::cl_arg. If the field starpu_codelet::where is
  369. set, then the field starpu_codelet::fpga_funcs is ignored if
  370. ::STARPU_FPGA does not appear in the field
  371. starpu_codelet::where, it must be non-<c>NULL</c> otherwise.
  372. */
  373. starpu_fpga_func_t fpga_funcs[STARPU_MAXIMPLEMENTATIONS];
  374. /**
  375. Optional array of function pointers to a function which
  376. returns the MPI Master Slave implementation of the codelet.
  377. The functions prototype must be:
  378. \code{.c}
  379. starpu_mpi_ms_kernel_t mpi_ms_func(struct starpu_codelet *cl, unsigned nimpl)
  380. \endcode
  381. If the field starpu_codelet::where is set, then the field
  382. starpu_codelet::mpi_ms_funcs is ignored if ::STARPU_MPI_MS
  383. does not appear in the field starpu_codelet::where. It can
  384. be <c>NULL</c> if starpu_codelet::cpu_funcs_name is
  385. non-<c>NULL</c>, in which case StarPU will simply make a
  386. symbol lookup to get the implementation.
  387. */
  388. starpu_mpi_ms_func_t mpi_ms_funcs[STARPU_MAXIMPLEMENTATIONS];
  389. /**
  390. Optional array of strings which provide the name of the CPU
  391. functions referenced in the array
  392. starpu_codelet::cpu_funcs. This can be used when running on
  393. MPI MS devices for StarPU to simply look
  394. up the MPI MS function implementation through its name.
  395. */
  396. const char *cpu_funcs_name[STARPU_MAXIMPLEMENTATIONS];
  397. /**
  398. Specify the number of arguments taken by the codelet. These
  399. arguments are managed by the DSM and are accessed from the
  400. <c>void *buffers[]</c> array. The constant argument passed
  401. with the field starpu_task::cl_arg is not counted in this
  402. number. This value should not be above \ref
  403. STARPU_NMAXBUFS. It may be set to \ref
  404. STARPU_VARIABLE_NBUFFERS to specify that the number of
  405. buffers and their access modes will be set in
  406. starpu_task::nbuffers and starpu_task::modes or
  407. starpu_task::dyn_modes, which thus permits to define
  408. codelets with a varying number of data.
  409. */
  410. int nbuffers;
  411. /**
  412. Is an array of ::starpu_data_access_mode. It describes the
  413. required access modes to the data neeeded by the codelet
  414. (e.g. ::STARPU_RW). The number of entries in this array
  415. must be specified in the field starpu_codelet::nbuffers,
  416. and should not exceed \ref STARPU_NMAXBUFS. If
  417. unsufficient, this value can be set with the configure
  418. option \ref enable-maxbuffers "--enable-maxbuffers".
  419. */
  420. enum starpu_data_access_mode modes[STARPU_NMAXBUFS];
  421. /**
  422. Is an array of ::starpu_data_access_mode. It describes the
  423. required access modes to the data needed by the codelet
  424. (e.g. ::STARPU_RW). The number of entries in this array
  425. must be specified in the field starpu_codelet::nbuffers.
  426. This field should be used for codelets having a number of
  427. datas greater than \ref STARPU_NMAXBUFS (see \ref
  428. SettingManyDataHandlesForATask). When defining a codelet,
  429. one should either define this field or the field
  430. starpu_codelet::modes defined above.
  431. */
  432. enum starpu_data_access_mode *dyn_modes;
  433. /**
  434. Default value is 0. If this flag is set, StarPU will not
  435. systematically send all data to the memory node where the
  436. task will be executing, it will read the
  437. starpu_codelet::nodes or starpu_codelet::dyn_nodes array to
  438. determine, for each data, whether to send it on the memory
  439. node where the task will be executing (-1), or on a
  440. specific node (!= -1).
  441. */
  442. unsigned specific_nodes;
  443. /**
  444. Optional field. When starpu_codelet::specific_nodes is 1,
  445. this specifies the memory nodes where each data should be
  446. sent to for task execution. The number of entries in this
  447. array is starpu_codelet::nbuffers, and should not exceed
  448. \ref STARPU_NMAXBUFS.
  449. */
  450. int nodes[STARPU_NMAXBUFS];
  451. /**
  452. Optional field. When starpu_codelet::specific_nodes is 1,
  453. this specifies the memory nodes where each data should be
  454. sent to for task execution. The number of entries in this
  455. array is starpu_codelet::nbuffers. This field should be
  456. used for codelets having a number of datas greater than
  457. \ref STARPU_NMAXBUFS (see \ref
  458. SettingManyDataHandlesForATask). When defining a codelet,
  459. one should either define this field or the field
  460. starpu_codelet::nodes defined above.
  461. */
  462. int *dyn_nodes;
  463. /**
  464. Optional pointer to the task duration performance model
  465. associated to this codelet. This optional field is ignored
  466. when set to <c>NULL</c> or when its field
  467. starpu_perfmodel::symbol is not set.
  468. */
  469. struct starpu_perfmodel *model;
  470. /**
  471. Optional pointer to the task energy consumption performance
  472. model associated to this codelet (in J). This optional field is
  473. ignored when set to <c>NULL</c> or when its field
  474. starpu_perfmodel::symbol is not set. In the case of
  475. parallel codelets, this has to account for all processing
  476. units involved in the parallel execution.
  477. */
  478. struct starpu_perfmodel *energy_model;
  479. /**
  480. Optional array for statistics collected at runtime: this is
  481. filled by StarPU and should not be accessed directly, but
  482. for example by calling the function
  483. starpu_codelet_display_stats() (See
  484. starpu_codelet_display_stats() for details).
  485. */
  486. unsigned long per_worker_stats[STARPU_NMAXWORKERS];
  487. /**
  488. Optional name of the codelet. This can be useful for
  489. debugging purposes.
  490. */
  491. const char *name;
  492. /**
  493. Optional color of the codelet. This can be useful for
  494. debugging purposes. Value 0 acts like if this field wasn't specified.
  495. Color representation is hex triplet (for example: 0xff0000 is red,
  496. 0x0000ff is blue, 0xffa500 is orange, ...).
  497. */
  498. unsigned color;
  499. /**
  500. Optional field, the default value is <c>NULL</c>. This is a
  501. function pointer of prototype <c>void (*f)(void *)</c>
  502. which specifies a possible callback. If this pointer is
  503. non-<c>NULL</c>, the callback function is executed on the
  504. host after the execution of the task. If the task defines a
  505. callback, the codelet callback is not called, unless called
  506. within the task callback function.
  507. The callback is passed the value contained in the
  508. starpu_task::callback_arg field. No callback is executed if
  509. the field is set to <c>NULL</c>.
  510. */
  511. void (*callback_func)(void *);
  512. /**
  513. Various flags for the codelet.
  514. */
  515. int flags;
  516. struct starpu_perf_counter_sample *perf_counter_sample;
  517. struct starpu_perf_counter_sample_cl_values *perf_counter_values;
  518. /**
  519. Whether _starpu_codelet_check_deprecated_fields was already done or not.
  520. */
  521. int checked;
  522. };
  523. /**
  524. Describe a data handle along with an access mode.
  525. */
  526. struct starpu_data_descr
  527. {
  528. starpu_data_handle_t handle; /**< data */
  529. enum starpu_data_access_mode mode; /**< access mode */
  530. };
  531. /**
  532. Describe a task that can be offloaded on the various processing
  533. units managed by StarPU. It instantiates a codelet. It can either
  534. be allocated dynamically with the function starpu_task_create(), or
  535. declared statically. In the latter case, the programmer has to zero
  536. the structure starpu_task and to fill the different fields
  537. properly. The indicated default values correspond to the
  538. configuration of a task allocated with starpu_task_create().
  539. */
  540. struct starpu_task
  541. {
  542. /**
  543. Optional name of the task. This can be useful for debugging
  544. purposes.
  545. With starpu_task_insert() and alike this can be specified thanks to
  546. ::STARPU_NAME followed by the const char *.
  547. */
  548. const char *name;
  549. /**
  550. Optional file name where the task was submitted. This can be useful
  551. for debugging purposes.
  552. */
  553. const char *file;
  554. /**
  555. Optional line number where the task was submitted. This can be useful
  556. for debugging purposes.
  557. */
  558. int line;
  559. /**
  560. Pointer to the corresponding structure starpu_codelet. This
  561. describes where the kernel should be executed, and supplies
  562. the appropriate implementations. When set to <c>NULL</c>,
  563. no code is executed during the tasks, such empty tasks can
  564. be useful for synchronization purposes.
  565. */
  566. struct starpu_codelet *cl;
  567. /**
  568. When set, specify where the task is allowed to be executed.
  569. When unset, take the value of starpu_codelet::where.
  570. With starpu_task_insert() and alike this can be specified thanks to
  571. ::STARPU_EXECUTE_WHERE followed by an unsigned long long.
  572. */
  573. int32_t where;
  574. /**
  575. Specify the number of buffers. This is only used when
  576. starpu_codelet::nbuffers is \ref STARPU_VARIABLE_NBUFFERS.
  577. With starpu_task_insert() and alike this is automatically computed
  578. when using ::STARPU_DATA_ARRAY and alike.
  579. */
  580. int nbuffers;
  581. /* Keep dyn_handles, dyn_interfaces and dyn_modes before the
  582. * equivalent static arrays, so we can detect dyn_handles
  583. * being NULL while nbuffers being bigger that STARPU_NMAXBUFS
  584. * (otherwise the overflow would put a non-NULL) */
  585. /**
  586. Array of ::starpu_data_handle_t. Specify the handles to the
  587. different pieces of data accessed by the task. The number
  588. of entries in this array must be specified in the field
  589. starpu_codelet::nbuffers. This field should be used for
  590. tasks having a number of datas greater than \ref
  591. STARPU_NMAXBUFS (see \ref SettingManyDataHandlesForATask).
  592. When defining a task, one should either define this field
  593. or the field starpu_task::handles defined below.
  594. With starpu_task_insert() and alike this is automatically filled
  595. when using ::STARPU_DATA_ARRAY and alike.
  596. */
  597. starpu_data_handle_t *dyn_handles;
  598. /**
  599. Array of data pointers to the memory node where execution
  600. will happen, managed by the DSM. Is used when the field
  601. starpu_task::dyn_handles is defined.
  602. This is filled by StarPU.
  603. */
  604. void **dyn_interfaces;
  605. /**
  606. Used only when starpu_codelet::nbuffers is \ref
  607. STARPU_VARIABLE_NBUFFERS.
  608. Array of ::starpu_data_access_mode which describes the
  609. required access modes to the data needed by the codelet
  610. (e.g. ::STARPU_RW). The number of entries in this array
  611. must be specified in the field starpu_codelet::nbuffers.
  612. This field should be used for codelets having a number of
  613. datas greater than \ref STARPU_NMAXBUFS (see \ref
  614. SettingManyDataHandlesForATask).
  615. When defining a codelet, one should either define this
  616. field or the field starpu_task::modes defined below.
  617. With starpu_task_insert() and alike this is automatically filled
  618. when using ::STARPU_DATA_MODE_ARRAY and alike.
  619. */
  620. enum starpu_data_access_mode *dyn_modes;
  621. /**
  622. Array of ::starpu_data_handle_t. Specify the handles to the
  623. different pieces of data accessed by the task. The number
  624. of entries in this array must be specified in the field
  625. starpu_codelet::nbuffers, and should not exceed
  626. \ref STARPU_NMAXBUFS. If unsufficient, this value can be
  627. set with the configure option \ref enable-maxbuffers
  628. "--enable-maxbuffers".
  629. With starpu_task_insert() and alike this is automatically filled
  630. when using ::STARPU_R and alike.
  631. */
  632. starpu_data_handle_t handles[STARPU_NMAXBUFS];
  633. /**
  634. Array of Data pointers to the memory node where execution
  635. will happen, managed by the DSM.
  636. This is filled by StarPU.
  637. */
  638. void *interfaces[STARPU_NMAXBUFS];
  639. /**
  640. Used only when starpu_codelet::nbuffers is \ref
  641. STARPU_VARIABLE_NBUFFERS.
  642. Array of ::starpu_data_access_mode which describes the
  643. required access modes to the data neeeded by the codelet
  644. (e.g. ::STARPU_RW). The number of entries in this array
  645. must be specified in the field starpu_task::nbuffers, and
  646. should not exceed \ref STARPU_NMAXBUFS. If unsufficient,
  647. this value can be set with the configure option
  648. \ref enable-maxbuffers "--enable-maxbuffers".
  649. With starpu_task_insert() and alike this is automatically filled
  650. when using ::STARPU_DATA_MODE_ARRAY and alike.
  651. */
  652. enum starpu_data_access_mode modes[STARPU_NMAXBUFS];
  653. /**
  654. Optional pointer to an array of characters which allows to
  655. define the sequential consistency for each handle for the
  656. current task.
  657. With starpu_task_insert() and alike this can be specified thanks to
  658. ::STARPU_HANDLES_SEQUENTIAL_CONSISTENCY followed by an unsigned char *
  659. */
  660. unsigned char *handles_sequential_consistency;
  661. /**
  662. Optional pointer which is passed to the codelet through the
  663. second argument of the codelet implementation (e.g.
  664. starpu_codelet::cpu_func or starpu_codelet::cuda_func). The
  665. default value is <c>NULL</c>. starpu_codelet_pack_args()
  666. and starpu_codelet_unpack_args() are helpers that can can
  667. be used to respectively pack and unpack data into and from
  668. it, but the application can manage it any way, the only
  669. requirement is that the size of the data must be set in
  670. starpu_task::cl_arg_size .
  671. With starpu_task_insert() and alike this can be specified thanks to
  672. ::STARPU_CL_ARGS followed by a void* and a size_t.
  673. */
  674. void *cl_arg;
  675. /**
  676. Optional field. For some specific drivers, the pointer
  677. starpu_task::cl_arg cannot not be directly given to the
  678. driver function. A buffer of size starpu_task::cl_arg_size
  679. needs to be allocated on the driver. This buffer is then
  680. filled with the starpu_task::cl_arg_size bytes starting at
  681. address starpu_task::cl_arg. In this case, the argument
  682. given to the codelet is therefore not the
  683. starpu_task::cl_arg pointer, but the address of the buffer
  684. in local store (LS) instead. This field is ignored for CPU,
  685. CUDA and OpenCL codelets, where the starpu_task::cl_arg
  686. pointer is given as such.
  687. With starpu_task_insert() and alike this can be specified thanks to
  688. ::STARPU_CL_ARGS followed by a void* and a size_t.
  689. */
  690. size_t cl_arg_size;
  691. /**
  692. Optional pointer which points to the return value of submitted task.
  693. The default value is <c>NULL</c>. starpu_codelet_pack_arg()
  694. and starpu_codelet_unpack_arg() can be used to respectively
  695. pack and unpack the return value into and form it. starpu_task::cl_ret
  696. can be used for MPI support. The only requirement is that
  697. the size of the return value must be set in starpu_task::cl_ret_size .
  698. */
  699. void *cl_ret;
  700. /**
  701. Optional field. The buffer of starpu_codelet_pack_arg()
  702. and starpu_codelet_unpack_arg() can be allocated with
  703. the starpu_task::cl_ret_size bytes starting at address starpu_task::cl_ret.
  704. starpu_task::cl_ret_size can be used for MPI supoort.
  705. */
  706. size_t cl_ret_size;
  707. /**
  708. Optional field, the default value is <c>NULL</c>. This is a
  709. function pointer of prototype <c>void (*f)(void *)</c> which
  710. specifies a possible callback. If this pointer is non-<c>NULL</c>,
  711. the callback function is executed on the host after the execution of
  712. the task. Contrary to starpu_task::callback_func, it is called
  713. before releasing tasks which depend on this task, so those cannot be
  714. already executing. The callback is passed
  715. the value contained in the starpu_task::epilogue_callback_arg field.
  716. No callback is executed if the field is set to <c>NULL</c>.
  717. With starpu_task_insert() and alike this can be specified thanks to
  718. ::STARPU_EPILOGUE_CALLBACK followed by the function pointer.
  719. */
  720. void (*epilogue_callback_func)(void *);
  721. /**
  722. Optional field, the default value is <c>NULL</c>. This is
  723. the pointer passed to the epilogue callback function. This field is
  724. ignored if the field starpu_task::epilogue_callback_func is set to
  725. <c>NULL</c>.
  726. */
  727. void *epilogue_callback_arg;
  728. /**
  729. Optional field, the default value is <c>NULL</c>. This is a
  730. function pointer of prototype <c>void (*f)(void *)</c>
  731. which specifies a possible callback. If this pointer is
  732. non-<c>NULL</c>, the callback function is executed on the
  733. host after the execution of the task. Contrary to
  734. starpu_task::epilogue_callback, it is called after releasing
  735. tasks which depend on this task, so those
  736. might already be executing. The callback is passed the
  737. value contained in the starpu_task::callback_arg field. No
  738. callback is executed if the field is set to <c>NULL</c>.
  739. With starpu_task_insert() and alike this can be specified thanks to
  740. ::STARPU_CALLBACK followed by the function pointer, or thanks to
  741. ::STARPU_CALLBACK_WITH_ARG (or
  742. ::STARPU_CALLBACK_WITH_ARG_NFREE) followed by the function
  743. pointer and the argument.
  744. */
  745. void (*callback_func)(void *);
  746. /**
  747. Optional field, the default value is <c>NULL</c>. This is
  748. the pointer passed to the callback function. This field is
  749. ignored if the field starpu_task::callback_func is set to
  750. <c>NULL</c>.
  751. With starpu_task_insert() and alike this can be specified thanks to
  752. ::STARPU_CALLBACK_ARG followed by the argument pointer, or thanks to
  753. ::STARPU_CALLBACK_WITH_ARG or
  754. ::STARPU_CALLBACK_WITH_ARG_NFREE followed by the function
  755. pointer and the argument.
  756. */
  757. void *callback_arg;
  758. /**
  759. Optional field, the default value is <c>NULL</c>. This is a
  760. function pointer of prototype <c>void (*f)(void *)</c>
  761. which specifies a possible callback. If this pointer is
  762. non-<c>NULL</c>, the callback function is executed on the
  763. host when the task becomes ready for execution, before
  764. getting scheduled. The callback is passed the value
  765. contained in the starpu_task::prologue_callback_arg field.
  766. No callback is executed if the field is set to <c>NULL</c>.
  767. With starpu_task_insert() and alike this can be specified thanks to
  768. ::STARPU_PROLOGUE_CALLBACK followed by the function pointer.
  769. */
  770. void (*prologue_callback_func)(void *);
  771. /**
  772. Optional field, the default value is <c>NULL</c>. This is
  773. the pointer passed to the prologue callback function. This
  774. field is ignored if the field
  775. starpu_task::prologue_callback_func is set to <c>NULL</c>.
  776. With starpu_task_insert() and alike this can be specified thanks to
  777. ::STARPU_PROLOGUE_CALLBACK_ARG followed by the argument
  778. */
  779. void *prologue_callback_arg;
  780. /**
  781. Optional field, the default value is <c>NULL</c>. This is a
  782. function pointer of prototype <c>void (*f)(void*)</c>
  783. which specifies a possible callback. If this pointer is
  784. non-<c>NULL</c>, the callback function is executed on the host
  785. when the task is pop-ed from the scheduler, just before getting
  786. executed. The callback is passed the value contained in the
  787. starpu_task::prologue_callback_pop_arg field.
  788. No callback is executed if the field is set to <c>NULL</c>.
  789. With starpu_task_insert() and alike this can be specified thanks to
  790. ::STARPU_PROLOGUE_CALLBACK_POP followed by the function pointer.
  791. */
  792. void (*prologue_callback_pop_func)(void *);
  793. /**
  794. Optional field, the default value is <c>NULL</c>. This is
  795. the pointer passed to the prologue_callback_pop function. This
  796. field is ignored if the field
  797. starpu_task::prologue_callback_pop_func is set to <c>NULL</c>.
  798. With starpu_task_insert() and alike this can be specified thanks to
  799. ::STARPU_PROLOGUE_CALLBACK_POP_ARG followed by the argument.
  800. */
  801. void *prologue_callback_pop_arg;
  802. /**
  803. Optional field. Contain the tag associated to the task if
  804. the field starpu_task::use_tag is set, ignored
  805. otherwise.
  806. With starpu_task_insert() and alike this can be specified thanks to
  807. ::STARPU_TAG followed by a starpu_tag_t.
  808. */
  809. starpu_tag_t tag_id;
  810. /**
  811. Optional field. In case starpu_task::cl_arg was allocated
  812. by the application through <c>malloc()</c>, setting
  813. starpu_task::cl_arg_free to 1 makes StarPU automatically
  814. call <c>free(cl_arg)</c> when destroying the task. This
  815. saves the user from defining a callback just for that.
  816. With starpu_task_insert() and alike this is set to 1 when using
  817. ::STARPU_CL_ARGS.
  818. */
  819. unsigned cl_arg_free:1;
  820. /**
  821. Optional field. In case starpu_task::cl_ret was allocated
  822. by the application through <c>malloc()</c>, setting
  823. starpu_task::cl_ret_free to 1 makes StarPU automatically
  824. call <c>free(cl_ret)</c> when destroying the task.
  825. */
  826. unsigned cl_ret_free:1;
  827. /**
  828. Optional field. In case starpu_task::callback_arg was
  829. allocated by the application through <c>malloc()</c>,
  830. setting starpu_task::callback_arg_free to 1 makes StarPU
  831. automatically call <c>free(callback_arg)</c> when
  832. destroying the task.
  833. With starpu_task_insert() and alike, this is set to 1 when using
  834. ::STARPU_CALLBACK_ARG or ::STARPU_CALLBACK_WITH_ARG, or set
  835. to 0 when using ::STARPU_CALLBACK_ARG_NFREE
  836. */
  837. unsigned callback_arg_free:1;
  838. /**
  839. Optional field. In case starpu_task::epilogue_callback_arg was
  840. allocated by the application through <c>malloc()</c>,
  841. setting starpu_task::epilogue_callback_arg_free to 1 makes StarPU
  842. automatically call <c>free(epilogue_callback_arg)</c> when
  843. destroying the task.
  844. */
  845. unsigned epilogue_callback_arg_free:1;
  846. /**
  847. Optional field. In case starpu_task::prologue_callback_arg
  848. was allocated by the application through <c>malloc()</c>,
  849. setting starpu_task::prologue_callback_arg_free to 1 makes
  850. StarPU automatically call
  851. <c>free(prologue_callback_arg)</c> when destroying the task.
  852. With starpu_task_insert() and alike this is set to 1 when using
  853. ::STARPU_PROLOGUE_CALLBACK_ARG, or set to 0 when using
  854. ::STARPU_PROLOGUE_CALLBACK_ARG_NFREE
  855. */
  856. unsigned prologue_callback_arg_free:1;
  857. /**
  858. Optional field. In case starpu_task::prologue_callback_pop_arg
  859. was allocated by the application through <c>malloc()</c>,
  860. setting starpu_task::prologue_callback_pop_arg_free to 1 makes
  861. StarPU automatically call
  862. <c>free(prologue_callback_pop_arg)</c> when destroying the
  863. task.
  864. With starpu_task_insert() and alike this is set to 1 when using
  865. ::STARPU_PROLOGUE_CALLBACK_POP_ARG, or set to 0 when using
  866. ::STARPU_PROLOGUE_CALLBACK_POP_ARG_NFREE
  867. */
  868. unsigned prologue_callback_pop_arg_free:1;
  869. /**
  870. Optional field, the default value is 0. If set, this flag
  871. indicates that the task should be associated with the tag
  872. contained in the starpu_task::tag_id field. Tag allow the
  873. application to synchronize with the task and to express
  874. task dependencies easily.
  875. With starpu_task_insert() and alike this is set to 1 when using
  876. ::STARPU_TAG.
  877. */
  878. unsigned use_tag:1;
  879. /**
  880. If this flag is set (which is the default), sequential
  881. consistency is enforced for the data parameters of this
  882. task for which sequential consistency is enabled. Clearing
  883. this flag permits to disable sequential consistency for
  884. this task, even if data have it enabled.
  885. With starpu_task_insert() and alike this can be specified thanks to
  886. ::STARPU_SEQUENTIAL_CONSISTENCY followed by an unsigned.
  887. */
  888. unsigned sequential_consistency:1;
  889. /**
  890. If this flag is set, the function starpu_task_submit() is
  891. blocking and returns only when the task has been executed
  892. (or if no worker is able to process the task). Otherwise,
  893. starpu_task_submit() returns immediately.
  894. With starpu_task_insert() and alike this can be specified thanks to
  895. ::STARPU_TASK_SYNCHRONOUS followed an int.
  896. */
  897. unsigned synchronous:1;
  898. /**
  899. Default value is 0. If this flag is set, StarPU will bypass
  900. the scheduler and directly affect this task to the worker
  901. specified by the field starpu_task::workerid.
  902. With starpu_task_insert() and alike this is set to 1 when using
  903. ::STARPU_EXECUTE_ON_WORKER.
  904. */
  905. unsigned execute_on_a_specific_worker:1;
  906. /**
  907. Optional field, default value is 1. If this flag is set, it
  908. is not possible to synchronize with the task by the means
  909. of starpu_task_wait() later on. Internal data structures
  910. are only guaranteed to be freed once starpu_task_wait() is
  911. called if the flag is not set.
  912. With starpu_task_insert() and alike this is set to 1.
  913. */
  914. unsigned detach:1;
  915. /**
  916. Optional value. Default value is 0 for starpu_task_init(),
  917. and 1 for starpu_task_create(). If this flag is set, the
  918. task structure will automatically be freed, either after
  919. the execution of the callback if the task is detached, or
  920. during starpu_task_wait() otherwise. If this flag is not
  921. set, dynamically allocated data structures will not be
  922. freed until starpu_task_destroy() is called explicitly.
  923. Setting this flag for a statically allocated task structure
  924. will result in undefined behaviour. The flag is set to 1
  925. when the task is created by calling starpu_task_create().
  926. Note that starpu_task_wait_for_all() will not free any task.
  927. With starpu_task_insert() and alike this is set to 1.
  928. */
  929. unsigned destroy:1;
  930. /**
  931. Optional field. If this flag is set, the task will be
  932. re-submitted to StarPU once it has been executed. This flag
  933. must not be set if the flag starpu_task::destroy is set.
  934. This flag must be set before making another task depend on
  935. this one.
  936. With starpu_task_insert() and alike this is set to 0.
  937. */
  938. unsigned regenerate:1;
  939. /**
  940. @private
  941. This is only used for tasks that use multiformat handle.
  942. This should only be used by StarPU.
  943. */
  944. unsigned mf_skip:1;
  945. /**
  946. do not allocate a submitorder id for this task
  947. With starpu_task_insert() and alike this can be specified
  948. thanks to ::STARPU_TASK_NO_SUBMITORDER followed by
  949. an unsigned.
  950. */
  951. unsigned no_submitorder:1;
  952. /**
  953. Whether this task has failed and will thus have to be retried
  954. Set by StarPU.
  955. */
  956. unsigned failed:1;
  957. /**
  958. Whether the scheduler has pushed the task on some queue
  959. Set by StarPU.
  960. */
  961. unsigned scheduled:1;
  962. unsigned prefetched:1;
  963. /**
  964. Optional field. If the field
  965. starpu_task::execute_on_a_specific_worker is set, this
  966. field indicates the identifier of the worker that should
  967. process this task (as returned by starpu_worker_get_id()).
  968. This field is ignored if the field
  969. starpu_task::execute_on_a_specific_worker is set to 0.
  970. With starpu_task_insert() and alike this can be specified thanks to
  971. ::STARPU_EXECUTE_ON_WORKER followed by an int.
  972. */
  973. unsigned workerid;
  974. /**
  975. Optional field. If the field
  976. starpu_task::execute_on_a_specific_worker is set, this
  977. field indicates the per-worker consecutive order in which
  978. tasks should be executed on the worker. Tasks will be
  979. executed in consecutive starpu_task::workerorder values,
  980. thus ignoring the availability order or task priority. See
  981. \ref StaticScheduling for more details. This field is
  982. ignored if the field
  983. starpu_task::execute_on_a_specific_worker is set to 0.
  984. With starpu_task_insert() and alike this can be specified thanks to
  985. ::STARPU_WORKER_ORDER followed by an unsigned.
  986. */
  987. unsigned workerorder;
  988. /**
  989. Optional field. If the field starpu_task::workerids_len is
  990. different from 0, this field indicates an array of bits
  991. (stored as uint32_t values) which indicate the set of
  992. workers which are allowed to execute the task.
  993. starpu_task::workerid takes precedence over this.
  994. With starpu_task_insert() and alike, this can be specified
  995. along the field workerids_len thanks to ::STARPU_TASK_WORKERIDS
  996. followed by a number of workers and an array of bits which
  997. size is the number of workers.
  998. */
  999. uint32_t *workerids;
  1000. /**
  1001. Optional field. This provides the number of uint32_t values
  1002. in the starpu_task::workerids array.
  1003. With starpu_task_insert() and alike, this can be specified
  1004. along the field workerids thanks to ::STARPU_TASK_WORKERIDS
  1005. followed by a number of workers and an array of bits which
  1006. size is the number of workers.
  1007. */
  1008. unsigned workerids_len;
  1009. /**
  1010. Optional field, the default value is ::STARPU_DEFAULT_PRIO.
  1011. This field indicates a level of priority for the task. This
  1012. is an integer value that must be set between the return
  1013. values of the function starpu_sched_get_min_priority() for
  1014. the least important tasks, and that of the function
  1015. starpu_sched_get_max_priority() for the most important
  1016. tasks (included). The ::STARPU_MIN_PRIO and
  1017. ::STARPU_MAX_PRIO macros are provided for convenience and
  1018. respectively return the value of
  1019. starpu_sched_get_min_priority() and
  1020. starpu_sched_get_max_priority(). Default priority is
  1021. ::STARPU_DEFAULT_PRIO, which is always defined as 0 in
  1022. order to allow static task initialization. Scheduling
  1023. strategies that take priorities into account can use this
  1024. parameter to take better scheduling decisions, but the
  1025. scheduling policy may also ignore it.
  1026. With starpu_task_insert() and alike this can be specified thanks to
  1027. ::STARPU_PRIORITY followed by an unsigned long long.
  1028. */
  1029. int priority;
  1030. /**
  1031. Current state of the task.
  1032. Set by StarPU.
  1033. */
  1034. enum starpu_task_status status;
  1035. /**
  1036. @private
  1037. This field is set when initializing a task. The function
  1038. starpu_task_submit() will fail if the field does not have
  1039. the correct value. This will hence avoid submitting tasks
  1040. which have not been properly initialised.
  1041. */
  1042. int magic;
  1043. /**
  1044. Allow to get the type of task, for filtering out tasks
  1045. in profiling outputs, whether it is really internal to
  1046. StarPU (::STARPU_TASK_TYPE_INTERNAL), a data acquisition
  1047. synchronization task (::STARPU_TASK_TYPE_DATA_ACQUIRE), or
  1048. a normal task (::STARPU_TASK_TYPE_NORMAL)
  1049. Set by StarPU.
  1050. */
  1051. unsigned type;
  1052. /**
  1053. color of the task to be used in dag.dot.
  1054. With starpu_task_insert() and alike this can be specified thanks to
  1055. ::STARPU_TASK_COLOR followed by an int.
  1056. */
  1057. unsigned color;
  1058. /**
  1059. Scheduling context.
  1060. With starpu_task_insert() and alike this can be specified thanks to
  1061. ::STARPU_SCHED_CTX followed by an unsigned.
  1062. */
  1063. unsigned sched_ctx;
  1064. /**
  1065. Help the hypervisor monitor the execution of this task.
  1066. With starpu_task_insert() and alike this can be specified thanks to
  1067. ::STARPU_HYPERVISOR_TAG followed by an int.
  1068. */
  1069. int hypervisor_tag;
  1070. /**
  1071. TODO: related with sched contexts and parallel tasks
  1072. With starpu_task_insert() and alike this can be specified thanks to
  1073. ::STARPU_POSSIBLY_PARALLEL followed by an unsigned.
  1074. */
  1075. unsigned possibly_parallel;
  1076. /**
  1077. Optional field. The bundle that includes this task. If no
  1078. bundle is used, this should be <c>NULL</c>.
  1079. */
  1080. starpu_task_bundle_t bundle;
  1081. /**
  1082. Optional field. Profiling information for the task.
  1083. With starpu_task_insert() and alike this can be specified thanks to
  1084. ::STARPU_TASK_PROFILING_INFO followed by a pointer to the
  1085. appropriate struct.
  1086. */
  1087. struct starpu_profiling_task_info *profiling_info;
  1088. /**
  1089. This can be set to the number of floating points operations
  1090. that the task will have to achieve. This is useful for
  1091. easily getting GFlops curves from the tool
  1092. <c>starpu_perfmodel_plot</c>, and for the hypervisor load
  1093. balancing.
  1094. With starpu_task_insert() and alike this can be specified thanks to
  1095. ::STARPU_FLOPS followed by a double.
  1096. */
  1097. double flops;
  1098. /**
  1099. Output field. Predicted duration of the task. This field is
  1100. only set if the scheduling strategy uses performance
  1101. models.
  1102. Set by StarPU.
  1103. */
  1104. double predicted;
  1105. /**
  1106. Output field. Predicted data transfer duration for the task in
  1107. microseconds. This field is only valid if the scheduling
  1108. strategy uses performance models.
  1109. Set by StarPU.
  1110. */
  1111. double predicted_transfer;
  1112. double predicted_start;
  1113. /**
  1114. @private
  1115. A pointer to the previous task. This should only be used by
  1116. StarPU schedulers.
  1117. */
  1118. struct starpu_task *prev;
  1119. /**
  1120. @private
  1121. A pointer to the next task. This should only be used by
  1122. StarPU schedulers.
  1123. */
  1124. struct starpu_task *next;
  1125. /**
  1126. @private
  1127. This is private to StarPU, do not modify.
  1128. */
  1129. void *starpu_private;
  1130. #ifdef STARPU_OPENMP
  1131. /**
  1132. @private
  1133. This is private to StarPU, do not modify.
  1134. */
  1135. struct starpu_omp_task *omp_task;
  1136. #else
  1137. void *omp_task;
  1138. #endif
  1139. /**
  1140. @private
  1141. This is private to StarPU, do not modify.
  1142. */
  1143. unsigned nb_termination_call_required;
  1144. /**
  1145. This field is managed by the scheduler, is it allowed to do
  1146. whatever with it. Typically, some area would be allocated on push, and released on pop.
  1147. With starpu_task_insert() and alike this is set when using
  1148. ::STARPU_TASK_SCHED_DATA.
  1149. */
  1150. void *sched_data;
  1151. };
  1152. /**
  1153. To be used in the starpu_task::type field, for normal application tasks.
  1154. */
  1155. #define STARPU_TASK_TYPE_NORMAL 0
  1156. /**
  1157. To be used in the starpu_task::type field, for StarPU-internal tasks.
  1158. */
  1159. #define STARPU_TASK_TYPE_INTERNAL (1<<0)
  1160. /**
  1161. To be used in the starpu_task::type field, for StarPU-internal data acquisition tasks.
  1162. */
  1163. #define STARPU_TASK_TYPE_DATA_ACQUIRE (1<<1)
  1164. /**
  1165. Value to be used to initialize statically allocated tasks. This is
  1166. equivalent to initializing a structure starpu_task
  1167. with the function starpu_task_init().
  1168. */
  1169. /* Note: remember to update starpu_task_init and starpu_task_ft_create_retry
  1170. * as well */
  1171. #define STARPU_TASK_INITIALIZER \
  1172. { \
  1173. .cl = NULL, \
  1174. .where = -1, \
  1175. .cl_arg = NULL, \
  1176. .cl_arg_size = 0, \
  1177. .cl_ret = NULL, \
  1178. .cl_ret_size = 0, \
  1179. .callback_func = NULL, \
  1180. .callback_arg = NULL, \
  1181. .epilogue_callback_func = NULL, \
  1182. .epilogue_callback_arg = NULL, \
  1183. .priority = STARPU_DEFAULT_PRIO, \
  1184. .use_tag = 0, \
  1185. .sequential_consistency = 1, \
  1186. .synchronous = 0, \
  1187. .execute_on_a_specific_worker = 0, \
  1188. .workerorder = 0, \
  1189. .bundle = NULL, \
  1190. .detach = 1, \
  1191. .destroy = 0, \
  1192. .regenerate = 0, \
  1193. .status = STARPU_TASK_INIT, \
  1194. .profiling_info = NULL, \
  1195. .predicted = NAN, \
  1196. .predicted_transfer = NAN, \
  1197. .predicted_start = NAN, \
  1198. .starpu_private = NULL, \
  1199. .magic = 42, \
  1200. .type = 0, \
  1201. .color = 0, \
  1202. .sched_ctx = STARPU_NMAX_SCHED_CTXS, \
  1203. .hypervisor_tag = 0, \
  1204. .flops = 0.0, \
  1205. .scheduled = 0, \
  1206. .prefetched = 0, \
  1207. .dyn_handles = NULL, \
  1208. .dyn_interfaces = NULL, \
  1209. .dyn_modes = NULL, \
  1210. .name = NULL, \
  1211. .possibly_parallel = 0 \
  1212. }
  1213. /**
  1214. Return the number of buffers for \p task, i.e.
  1215. starpu_codelet::nbuffers, or starpu_task::nbuffers if the former is
  1216. \ref STARPU_VARIABLE_NBUFFERS.
  1217. */
  1218. #define STARPU_TASK_GET_NBUFFERS(task) ((unsigned)((task)->cl->nbuffers == STARPU_VARIABLE_NBUFFERS ? ((task)->nbuffers) : ((task)->cl->nbuffers)))
  1219. /**
  1220. Return the \p i -th data handle of \p task. If \p task is defined
  1221. with a static or dynamic number of handles, will either return the
  1222. \p i -th element of the field starpu_task::handles or the \p i -th
  1223. element of the field starpu_task::dyn_handles (see \ref
  1224. SettingManyDataHandlesForATask)
  1225. */
  1226. #define STARPU_TASK_GET_HANDLE(task, i) (((task)->dyn_handles) ? (task)->dyn_handles[i] : (task)->handles[i])
  1227. /**
  1228. Return all the data handles of \p task. If \p task is defined
  1229. with a static or dynamic number of handles, will either return all
  1230. the element of the field starpu_task::handles or all the elements
  1231. of the field starpu_task::dyn_handles (see \ref SettingManyDataHandlesForATask)
  1232. */
  1233. #define STARPU_TASK_GET_HANDLES(task) (((task)->dyn_handles) ? (task)->dyn_handles : (task)->handles)
  1234. /**
  1235. Set the \p i -th data handle of \p task with \p handle. If \p task
  1236. is defined with a static or dynamic number of handles, will either
  1237. set the \p i -th element of the field starpu_task::handles or the
  1238. \p i -th element of the field starpu_task::dyn_handles
  1239. (see \ref SettingManyDataHandlesForATask)
  1240. */
  1241. #define STARPU_TASK_SET_HANDLE(task, handle, i) \
  1242. do { if ((task)->dyn_handles) (task)->dyn_handles[i] = handle; else (task)->handles[i] = handle; } while(0)
  1243. /**
  1244. Return the access mode of the \p i -th data handle of \p codelet.
  1245. If \p codelet is defined with a static or dynamic number of
  1246. handles, will either return the \p i -th element of the field
  1247. starpu_codelet::modes or the \p i -th element of the field
  1248. starpu_codelet::dyn_modes (see \ref SettingManyDataHandlesForATask)
  1249. */
  1250. #define STARPU_CODELET_GET_MODE(codelet, i) \
  1251. (((codelet)->dyn_modes) ? (codelet)->dyn_modes[i] : (assert(i < STARPU_NMAXBUFS), (codelet)->modes[i]))
  1252. /**
  1253. Set the access mode of the \p i -th data handle of \p codelet. If
  1254. \p codelet is defined with a static or dynamic number of handles,
  1255. will either set the \p i -th element of the field
  1256. starpu_codelet::modes or the \p i -th element of the field
  1257. starpu_codelet::dyn_modes (see \ref SettingManyDataHandlesForATask)
  1258. */
  1259. #define STARPU_CODELET_SET_MODE(codelet, mode, i) \
  1260. do { if ((codelet)->dyn_modes) (codelet)->dyn_modes[i] = mode; else (codelet)->modes[i] = mode; } while(0)
  1261. /**
  1262. Return the access mode of the \p i -th data handle of \p task. If
  1263. \p task is defined with a static or dynamic number of handles, will
  1264. either return the \p i -th element of the field starpu_task::modes
  1265. or the \p i -th element of the field starpu_task::dyn_modes (see
  1266. \ref SettingManyDataHandlesForATask)
  1267. */
  1268. #define STARPU_TASK_GET_MODE(task, i) \
  1269. ((task)->cl->nbuffers == STARPU_VARIABLE_NBUFFERS || (task)->dyn_modes ? \
  1270. (((task)->dyn_modes) ? (task)->dyn_modes[i] : (task)->modes[i]) : \
  1271. STARPU_CODELET_GET_MODE((task)->cl, i) )
  1272. /**
  1273. Set the access mode of the \p i -th data handle of \p task. If \p
  1274. task is defined with a static or dynamic number of handles, will
  1275. either set the \p i -th element of the field starpu_task::modes or
  1276. the \p i -th element of the field starpu_task::dyn_modes (see \ref
  1277. SettingManyDataHandlesForATask)
  1278. */
  1279. #define STARPU_TASK_SET_MODE(task, mode, i) \
  1280. do { \
  1281. if ((task)->cl->nbuffers == STARPU_VARIABLE_NBUFFERS || (task)->cl->nbuffers > STARPU_NMAXBUFS) \
  1282. if ((task)->dyn_modes) (task)->dyn_modes[i] = mode; else (task)->modes[i] = mode; \
  1283. else \
  1284. { \
  1285. enum starpu_data_access_mode cl_mode = STARPU_CODELET_GET_MODE((task)->cl, i); \
  1286. STARPU_ASSERT_MSG(cl_mode == mode, \
  1287. "Task <%s> can't set its %d-th buffer mode to %d as the codelet it derives from uses %d", \
  1288. (task)->cl->name, i, mode, cl_mode); \
  1289. } \
  1290. } while(0)
  1291. /**
  1292. Return the target node of the \p i -th data handle of \p codelet.
  1293. If \p node is defined with a static or dynamic number of handles,
  1294. will either return the \p i -th element of the field
  1295. starpu_codelet::nodes or the \p i -th element of the field
  1296. starpu_codelet::dyn_nodes (see \ref SettingManyDataHandlesForATask)
  1297. */
  1298. #define STARPU_CODELET_GET_NODE(codelet, i) (((codelet)->dyn_nodes) ? (codelet)->dyn_nodes[i] : (codelet)->nodes[i])
  1299. /**
  1300. Set the target node of the \p i -th data handle of \p codelet. If
  1301. \p codelet is defined with a static or dynamic number of handles,
  1302. will either set the \p i -th element of the field
  1303. starpu_codelet::nodes or the \p i -th element of the field
  1304. starpu_codelet::dyn_nodes (see \ref SettingManyDataHandlesForATask)
  1305. */
  1306. #define STARPU_CODELET_SET_NODE(codelet, __node, i) \
  1307. do { if ((codelet)->dyn_nodes) (codelet)->dyn_nodes[i] = __node; else (codelet)->nodes[i] = __node; } while(0)
  1308. /**
  1309. Initialize \p task with default values. This function is implicitly
  1310. called by starpu_task_create(). By default, tasks initialized with
  1311. starpu_task_init() must be deinitialized explicitly with
  1312. starpu_task_clean(). Tasks can also be initialized statically,
  1313. using ::STARPU_TASK_INITIALIZER.
  1314. */
  1315. void starpu_task_init(struct starpu_task *task);
  1316. /**
  1317. Release all the structures automatically allocated to execute \p
  1318. task, but not the task structure itself and values set by the user
  1319. remain unchanged. It is thus useful for statically allocated tasks
  1320. for instance. It is also useful when users want to execute the same
  1321. operation several times with as least overhead as possible. It is
  1322. called automatically by starpu_task_destroy(). It has to be called
  1323. only after explicitly waiting for the task or after
  1324. starpu_shutdown() (waiting for the callback is not enough, since
  1325. StarPU still manipulates the task after calling the callback).
  1326. */
  1327. void starpu_task_clean(struct starpu_task *task);
  1328. /**
  1329. Allocate a task structure and initialize it with default values.
  1330. Tasks allocated dynamically with starpu_task_create() are
  1331. automatically freed when the task is terminated. This means that
  1332. the task pointer can not be used any more once the task is
  1333. submitted, since it can be executed at any time (unless
  1334. dependencies make it wait) and thus freed at any time. If the field
  1335. starpu_task::destroy is explicitly unset, the resources used by the
  1336. task have to be freed by calling starpu_task_destroy().
  1337. */
  1338. struct starpu_task *starpu_task_create(void) STARPU_ATTRIBUTE_MALLOC;
  1339. /**
  1340. Free the resource allocated during starpu_task_create() and
  1341. associated with \p task. This function is called automatically
  1342. after the execution of a task when the field starpu_task::destroy
  1343. is set, which is the default for tasks created by
  1344. starpu_task_create(). Calling this function on a statically
  1345. allocated task results in an undefined behaviour.
  1346. */
  1347. void starpu_task_destroy(struct starpu_task *task);
  1348. /**
  1349. Submit \p task to StarPU. Calling this function does not mean that
  1350. the task will be executed immediately as there can be data or task
  1351. (tag) dependencies that are not fulfilled yet: StarPU will take
  1352. care of scheduling this task with respect to such dependencies.
  1353. This function returns immediately if the field
  1354. starpu_task::synchronous is set to 0, and block until the
  1355. termination of the task otherwise. It is also possible to
  1356. synchronize the application with asynchronous tasks by the means of
  1357. tags, using the function starpu_tag_wait() function for instance.
  1358. In case of success, this function returns 0, a return value of
  1359. <c>-ENODEV</c> means that there is no worker able to process this
  1360. task (e.g. there is no GPU available and this task is only
  1361. implemented for CUDA devices). starpu_task_submit() can be called
  1362. from anywhere, including codelet functions and callbacks, provided
  1363. that the field starpu_task::synchronous is set to 0.
  1364. */
  1365. int starpu_task_submit(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
  1366. #ifdef STARPU_USE_FXT
  1367. static inline int starpu_task_submit_line(struct starpu_task *task, const char *file, int line)
  1368. {
  1369. task->file = file;
  1370. task->line = line;
  1371. return starpu_task_submit(task);
  1372. }
  1373. #define starpu_task_submit(task) starpu_task_submit_line((task), __FILE__, __LINE__)
  1374. #endif
  1375. /**
  1376. Submit \p task to StarPU with dependency bypass.
  1377. This can only be called on behalf of another task which has already taken the
  1378. proper dependencies, e.g. this task is just an attempt of doing the actual
  1379. computation of that task.
  1380. */
  1381. int starpu_task_submit_nodeps(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
  1382. /**
  1383. Submit \p task to the context \p sched_ctx_id. By default,
  1384. starpu_task_submit() submits the task to a global context that is
  1385. created automatically by StarPU.
  1386. */
  1387. int starpu_task_submit_to_ctx(struct starpu_task *task, unsigned sched_ctx_id);
  1388. /**
  1389. Return 1 if \p task is terminated
  1390. */
  1391. int starpu_task_finished(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
  1392. /**
  1393. Block until \p task has been executed. It is not possible to
  1394. synchronize with a task more than once. It is not possible to wait
  1395. for synchronous or detached tasks. Upon successful completion, this
  1396. function returns 0. Otherwise, <c>-EINVAL</c> indicates that the
  1397. specified task was either synchronous or detached.
  1398. */
  1399. int starpu_task_wait(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
  1400. /**
  1401. Allow to wait for an array of tasks. Upon successful completion,
  1402. this function returns 0. Otherwise, <c>-EINVAL</c> indicates that
  1403. one of the tasks was either synchronous or detached.
  1404. */
  1405. int starpu_task_wait_array(struct starpu_task **tasks, unsigned nb_tasks) STARPU_WARN_UNUSED_RESULT;
  1406. /**
  1407. Block until all the tasks that were submitted (to the current
  1408. context or the global one if there is no current context) are
  1409. terminated. It does not destroy these tasks.
  1410. */
  1411. int starpu_task_wait_for_all(void);
  1412. /**
  1413. Block until there are \p n submitted tasks left (to the current
  1414. context or the global one if there is no current context) to be
  1415. executed. It does not destroy these tasks.
  1416. */
  1417. int starpu_task_wait_for_n_submitted(unsigned n);
  1418. /**
  1419. Wait until all the tasks that were already submitted to the context
  1420. \p sched_ctx_id have been terminated.
  1421. */
  1422. int starpu_task_wait_for_all_in_ctx(unsigned sched_ctx_id);
  1423. /**
  1424. Wait until there are \p n tasks submitted left to be
  1425. executed that were already submitted to the context \p
  1426. sched_ctx_id.
  1427. */
  1428. int starpu_task_wait_for_n_submitted_in_ctx(unsigned sched_ctx_id, unsigned n);
  1429. /**
  1430. Wait until there is no more ready task.
  1431. */
  1432. int starpu_task_wait_for_no_ready(void);
  1433. /**
  1434. Return the number of submitted tasks which are ready for execution
  1435. are already executing. It thus does not include tasks waiting for
  1436. dependencies.
  1437. */
  1438. int starpu_task_nready(void);
  1439. /**
  1440. Return the number of submitted tasks which have not completed yet.
  1441. */
  1442. int starpu_task_nsubmitted(void);
  1443. /**
  1444. Set the iteration number for all the tasks to be submitted after
  1445. this call. This is typically called at the beginning of a task
  1446. submission loop. This number will then show up in tracing tools. A
  1447. corresponding starpu_iteration_pop() call must be made to match the
  1448. call to starpu_iteration_push(), at the end of the same task
  1449. submission loop, typically.
  1450. Nested calls to starpu_iteration_push() and starpu_iteration_pop()
  1451. are allowed, to describe a loop nest for instance, provided that
  1452. they match properly.
  1453. */
  1454. void starpu_iteration_push(unsigned long iteration);
  1455. /**
  1456. Drop the iteration number for submitted tasks. This must match a
  1457. previous call to starpu_iteration_push(), and is typically called
  1458. at the end of a task submission loop.
  1459. */
  1460. void starpu_iteration_pop(void);
  1461. void starpu_do_schedule(void);
  1462. /**
  1463. Initialize \p cl with default values. Codelets should preferably be
  1464. initialized statically as shown in \ref DefiningACodelet. However
  1465. such a initialisation is not always possible, e.g. when using C++.
  1466. */
  1467. void starpu_codelet_init(struct starpu_codelet *cl);
  1468. /**
  1469. Output on \c stderr some statistics on the codelet \p cl.
  1470. */
  1471. void starpu_codelet_display_stats(struct starpu_codelet *cl);
  1472. /**
  1473. Return the task currently executed by the worker, or <c>NULL</c> if
  1474. it is called either from a thread that is not a task or simply
  1475. because there is no task being executed at the moment.
  1476. */
  1477. struct starpu_task *starpu_task_get_current(void);
  1478. /**
  1479. Return the memory node number of parameter \p i of the task
  1480. currently executed, or -1 if it is called either from a thread that
  1481. is not a task or simply because there is no task being executed at
  1482. the moment.
  1483. Usually, the returned memory node number is simply the memory node
  1484. for the current worker. That may however be different when using
  1485. e.g. starpu_codelet::specific_nodes.
  1486. */
  1487. int starpu_task_get_current_data_node(unsigned i);
  1488. /**
  1489. Return the name of the performance model of \p task.
  1490. */
  1491. const char *starpu_task_get_model_name(struct starpu_task *task);
  1492. /**
  1493. Return the name of \p task, i.e. either its starpu_task::name
  1494. field, or the name of the corresponding performance model.
  1495. */
  1496. const char *starpu_task_get_name(struct starpu_task *task);
  1497. /**
  1498. Allocate a task structure which is the exact duplicate of \p task.
  1499. */
  1500. struct starpu_task *starpu_task_dup(struct starpu_task *task);
  1501. /**
  1502. This function should be called by schedulers to specify the
  1503. codelet implementation to be executed when executing \p task.
  1504. */
  1505. void starpu_task_set_implementation(struct starpu_task *task, unsigned impl);
  1506. /**
  1507. Return the codelet implementation to be executed
  1508. when executing \p task.
  1509. */
  1510. unsigned starpu_task_get_implementation(struct starpu_task *task);
  1511. /**
  1512. Create and submit an empty task that unlocks a tag once all its
  1513. dependencies are fulfilled.
  1514. */
  1515. void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps, void (*callback)(void *), void *callback_arg);
  1516. /**
  1517. Create and submit an empty task with the given callback
  1518. */
  1519. void starpu_create_callback_task(void (*callback)(void *), void *callback_arg);
  1520. /**
  1521. Function to be used as a prologue callback to enable fault tolerance for the
  1522. task. This prologue will create a try-task, i.e a duplicate of the task,
  1523. which will to the actual computation.
  1524. The prologue argument can be set to a check_ft function that will be
  1525. called on termination of the duplicate, which can check the result of the
  1526. task, and either confirm success, or resubmit another attempt.
  1527. If it is not set, the default implementation is to just resubmit a new
  1528. try-task.
  1529. */
  1530. void starpu_task_ft_prologue(void *check_ft);
  1531. /**
  1532. Create a try-task for a \p meta_task, given a \p template_task task
  1533. template. The meta task can be passed as template on the first call, but
  1534. since it is mangled by starpu_task_ft_create_retry(), further calls
  1535. (typically made by the check_ft callback) need to be passed the previous
  1536. try-task as template task.
  1537. \p check_ft is similar to the prologue argument of
  1538. starpu_task_ft_prologue(), and is typicall set to the very function calling
  1539. starpu_task_ft_create_retry().
  1540. The try-task is returned, and can be modified (e.g. to change scheduling
  1541. parameters) before being submitted with starpu_task_submit_nodeps().
  1542. */
  1543. struct starpu_task * starpu_task_ft_create_retry(const struct starpu_task *meta_task, const struct starpu_task *template_task, void (*check_ft)(void*));
  1544. /**
  1545. Record that this task failed, and should thus be retried.
  1546. This is usually called from the task codelet function itself, after checking
  1547. the result and noticing that the computation went wrong, and thus the task
  1548. should be retried. The performance of this task execution will not be
  1549. recorded for performance models.
  1550. This can only be called for a task whose data access modes are either
  1551. STARPU_R and STARPU_W.
  1552. */
  1553. void starpu_task_ft_failed(struct starpu_task *task);
  1554. /**
  1555. Notify that the try-task was successful and thus the meta-task was
  1556. successful.
  1557. */
  1558. void starpu_task_ft_success(struct starpu_task *meta_task);
  1559. /**
  1560. Set the function to call when the watchdog detects that StarPU has
  1561. not finished any task for STARPU_WATCHDOG_TIMEOUT seconds
  1562. */
  1563. void starpu_task_watchdog_set_hook(void (*hook)(void *), void *hook_arg);
  1564. /** @} */
  1565. #ifdef __cplusplus
  1566. }
  1567. #endif
  1568. #endif /* __STARPU_TASK_H__ */