starpu_task_util.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPU_TASK_UTIL_H__
  17. #define __STARPU_TASK_UTIL_H__
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <assert.h>
  22. #include <starpu.h>
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. /**
  28. @defgroup API_Insert_Task Task Insert Utility
  29. @{
  30. */
  31. /* NOTE: when adding a value here, please make sure to update both
  32. * src/util/starpu_task_insert_utils.c (in two places) and
  33. * mpi/src/starpu_mpi_task_insert.c and mpi/src/starpu_mpi_task_insert_fortran.c */
  34. #define STARPU_MODE_SHIFT 17
  35. /**
  36. Used when calling starpu_task_insert(), must be followed by a
  37. pointer to a constant value and the size of the constant
  38. */
  39. #define STARPU_VALUE (1<<STARPU_MODE_SHIFT)
  40. /**
  41. Used when calling starpu_task_insert(), must be followed by a
  42. pointer to a callback function
  43. */
  44. #define STARPU_CALLBACK (2<<STARPU_MODE_SHIFT)
  45. /**
  46. Used when calling starpu_task_insert(), must be followed by two
  47. pointers: one to a callback function, and the other to be given as
  48. an argument to the callback function; this is equivalent to using
  49. both ::STARPU_CALLBACK and ::STARPU_CALLBACK_ARG.
  50. */
  51. #define STARPU_CALLBACK_WITH_ARG (3<<STARPU_MODE_SHIFT)
  52. /**
  53. Used when calling starpu_task_insert(), must be followed by a
  54. pointer to be given as an argument to the callback function
  55. */
  56. #define STARPU_CALLBACK_ARG (4<<STARPU_MODE_SHIFT)
  57. /**
  58. Used when calling starpu_task_insert(), must
  59. be followed by a integer defining a priority level
  60. */
  61. #define STARPU_PRIORITY (5<<STARPU_MODE_SHIFT)
  62. /**
  63. \ingroup API_MPI_Support
  64. Used when calling starpu_mpi_task_insert(), must be followed by a
  65. integer value which specified the node on which to execute the
  66. codelet.
  67. */
  68. #define STARPU_EXECUTE_ON_NODE (6<<STARPU_MODE_SHIFT)
  69. /**
  70. \ingroup API_MPI_Support
  71. Used when calling starpu_mpi_task_insert(), must be followed by a
  72. data handle to specify that the node owning the given data will
  73. execute the codelet.
  74. */
  75. #define STARPU_EXECUTE_ON_DATA (7<<STARPU_MODE_SHIFT)
  76. /**
  77. Used when calling starpu_task_in_sert(), must be followed by an array of
  78. handles and the number of elements in the array (as int). This is equivalent
  79. to passing the handles as separate parameters with STARPU_R/W/RW.
  80. */
  81. #define STARPU_DATA_ARRAY (8<<STARPU_MODE_SHIFT)
  82. /**
  83. Used when calling starpu_task_in_sert(), must be followed by an array of
  84. struct starpu_data_descr and the number of elements in the array (as int).
  85. This is equivalent to passing the handles with the corresponding modes.
  86. */
  87. #define STARPU_DATA_MODE_ARRAY (9<<STARPU_MODE_SHIFT)
  88. /**
  89. Used when calling starpu_task_insert(), must be followed by a tag.
  90. */
  91. #define STARPU_TAG (10<<STARPU_MODE_SHIFT)
  92. /**
  93. Used when calling starpu_task_insert(), must be followed by a tag.
  94. */
  95. #define STARPU_HYPERVISOR_TAG (11<<STARPU_MODE_SHIFT)
  96. /**
  97. Used when calling starpu_task_insert(), must be followed by an
  98. amount of floating point operations, as a double. Users <b>MUST</b>
  99. explicitly cast into double, otherwise parameter passing will not
  100. work.
  101. */
  102. #define STARPU_FLOPS (12<<STARPU_MODE_SHIFT)
  103. /**
  104. Used when calling starpu_task_insert(), must be followed by the id
  105. of the scheduling context to which to submit the task to.
  106. */
  107. #define STARPU_SCHED_CTX (13<<STARPU_MODE_SHIFT)
  108. /**
  109. Used when calling starpu_task_insert(), must be followed by a
  110. pointer to a prologue callback function
  111. */
  112. #define STARPU_PROLOGUE_CALLBACK (14<<STARPU_MODE_SHIFT)
  113. /**
  114. Used when calling starpu_task_insert(), must be followed by a
  115. pointer to be given as an argument to the prologue callback
  116. function
  117. */
  118. #define STARPU_PROLOGUE_CALLBACK_ARG (15<<STARPU_MODE_SHIFT)
  119. /**
  120. Used when calling starpu_task_insert(), must be followed by a
  121. pointer to a prologue callback pop function
  122. */
  123. #define STARPU_PROLOGUE_CALLBACK_POP (16<<STARPU_MODE_SHIFT)
  124. /**
  125. Used when calling starpu_task_insert(), must be followed by a
  126. pointer to be given as an argument to the prologue callback pop
  127. function
  128. */
  129. #define STARPU_PROLOGUE_CALLBACK_POP_ARG (17<<STARPU_MODE_SHIFT)
  130. /**
  131. Used when calling starpu_task_insert(), must be followed by an
  132. integer value specifying the worker on which to execute the task
  133. (as specified by starpu_task::execute_on_a_specific_worker)
  134. */
  135. #define STARPU_EXECUTE_ON_WORKER (18<<STARPU_MODE_SHIFT)
  136. /**
  137. Used when calling starpu_task_insert(), must be followed by an
  138. unsigned long long value specifying the mask of worker on which to execute
  139. the task (as specified by starpu_task::where)
  140. */
  141. #define STARPU_EXECUTE_WHERE (19<<STARPU_MODE_SHIFT)
  142. /**
  143. Used when calling starpu_task_insert(), must be followed by a tag
  144. stored in starpu_task::tag_id. Leave starpu_task::use_tag as 0.
  145. */
  146. #define STARPU_TAG_ONLY (20<<STARPU_MODE_SHIFT)
  147. /**
  148. Used when calling starpu_task_insert(), must be followed by an unsigned
  149. stored in starpu_task::possibly_parallel.
  150. */
  151. #define STARPU_POSSIBLY_PARALLEL (21<<STARPU_MODE_SHIFT)
  152. /**
  153. used when calling starpu_task_insert(), must be
  154. followed by an integer value specifying the worker order in which
  155. to execute the tasks (as specified by starpu_task::workerorder)
  156. */
  157. #define STARPU_WORKER_ORDER (22<<STARPU_MODE_SHIFT)
  158. /**
  159. \ingroup API_MPI_Support
  160. Used when calling starpu_mpi_task_insert(), must be followed by a
  161. identifier to a node selection policy. This is needed when several
  162. nodes own data in ::STARPU_W mode.
  163. */
  164. #define STARPU_NODE_SELECTION_POLICY (23<<STARPU_MODE_SHIFT)
  165. /**
  166. Used when calling starpu_task_insert(), must be followed by a
  167. char * stored in starpu_task::name.
  168. */
  169. #define STARPU_NAME (24<<STARPU_MODE_SHIFT)
  170. /**
  171. Used when calling starpu_task_insert(), must be followed by a
  172. memory buffer containing the arguments to be given to the task, and
  173. by the size of the arguments. The memory buffer should be the
  174. result of a previous call to starpu_codelet_pack_args(), and will
  175. be freed (i.e. starpu_task::cl_arg_free will be set to 1)
  176. */
  177. #define STARPU_CL_ARGS (25<<STARPU_MODE_SHIFT)
  178. /**
  179. Used when calling starpu_task_insert(), similarly to
  180. ::STARPU_CL_ARGS, must be followed by a memory buffer containing
  181. the arguments to be given to the task, and by the size of the
  182. arguments. The memory buffer should be the result of a previous
  183. call to starpu_codelet_pack_args(), and will NOT be freed (i.e.
  184. starpu_task::cl_arg_free will be set to 0)
  185. */
  186. #define STARPU_CL_ARGS_NFREE (26<<STARPU_MODE_SHIFT)
  187. /**
  188. Used when calling starpu_task_insert(), must be followed by a
  189. number of tasks as int, and an array containing these tasks. The
  190. function starpu_task_declare_deps_array() will be called with the
  191. given values.
  192. */
  193. #define STARPU_TASK_DEPS_ARRAY (27<<STARPU_MODE_SHIFT)
  194. /**
  195. Used when calling starpu_task_insert(), must be followed by an
  196. integer representing a color
  197. */
  198. #define STARPU_TASK_COLOR (28<<STARPU_MODE_SHIFT)
  199. /**
  200. Used when calling starpu_task_insert(), must be followed by an
  201. array of characters representing the sequential consistency for
  202. each buffer of the task.
  203. */
  204. #define STARPU_HANDLES_SEQUENTIAL_CONSISTENCY (29<<STARPU_MODE_SHIFT)
  205. /**
  206. Used when calling starpu_task_insert(), must be followed by an
  207. integer stating if the task is synchronous or not
  208. */
  209. #define STARPU_TASK_SYNCHRONOUS (30<<STARPU_MODE_SHIFT)
  210. /**
  211. Used when calling starpu_task_insert(), must be followed by a
  212. number of tasks as int, and an array containing these tasks. The
  213. function starpu_task_declare_end_deps_array() will be called with
  214. the given values.
  215. */
  216. #define STARPU_TASK_END_DEPS_ARRAY (31<<STARPU_MODE_SHIFT)
  217. /**
  218. Used when calling starpu_task_insert(), must be followed by an
  219. integer which will be given to starpu_task_end_dep_add()
  220. */
  221. #define STARPU_TASK_END_DEP (32<<STARPU_MODE_SHIFT)
  222. /**
  223. Used when calling starpu_task_insert(), must be followed by an
  224. unsigned being a number of workers, and an array of bits which size
  225. is the number of workers, the array indicates the set of workers
  226. which are allowed to execute the task.
  227. */
  228. #define STARPU_TASK_WORKERIDS (33<<STARPU_MODE_SHIFT)
  229. /**
  230. Used when calling starpu_task_insert(), must be followed by an
  231. unsigned which sets the sequential consistency for the data
  232. parameters of the task.
  233. */
  234. #define STARPU_SEQUENTIAL_CONSISTENCY (34<<STARPU_MODE_SHIFT)
  235. /**
  236. Used when calling starpu_task_insert() and alike, must be followed
  237. by a pointer to a struct starpu_profiling_task_info
  238. */
  239. #define STARPU_TASK_PROFILING_INFO (35<<STARPU_MODE_SHIFT)
  240. /**
  241. Used when calling starpu_task_insert() and alike, must be followed
  242. by an unsigned specifying not to allocate a submitorder id for the task
  243. */
  244. #define STARPU_TASK_NO_SUBMITORDER (36<<STARPU_MODE_SHIFT)
  245. /**
  246. Used when calling starpu_task_insert(), similarly to
  247. ::STARPU_CALLBACK_ARG, must be followed by a pointer to be given as
  248. an argument to the callback function, the argument will not be
  249. freed, i.e starpu_task::callback_arg_free will be set to 0
  250. */
  251. #define STARPU_CALLBACK_ARG_NFREE (37<<STARPU_MODE_SHIFT)
  252. /**
  253. Used when calling starpu_task_insert(), similarly to
  254. ::STARPU_CALLBACK_WITH_ARG, must be followed by two pointers: one
  255. to a callback function, and the other to be given as an argument to
  256. the callback function; this is equivalent to using both
  257. ::STARPU_CALLBACK and ::STARPU_CALLBACK_ARG_NFREE.
  258. */
  259. #define STARPU_CALLBACK_WITH_ARG_NFREE (38<<STARPU_MODE_SHIFT)
  260. /**
  261. Used when calling starpu_task_insert(), similarly to
  262. ::STARPU_PROLOGUE_CALLBACK_ARG, must be followed by a
  263. pointer to be given as an argument to the prologue callback
  264. function, the argument will not be
  265. freed, i.e starpu_task::prologue_callback_arg_free will be set to 0
  266. */
  267. #define STARPU_PROLOGUE_CALLBACK_ARG_NFREE (39<<STARPU_MODE_SHIFT)
  268. /**
  269. Used when calling starpu_task_insert(), similarly to
  270. ::STARPU_PROLOGUE_CALLBACK_POP_ARG, must be followed by a pointer
  271. to be given as an argument to the prologue callback pop function,
  272. the argument will not be freed, i.e
  273. starpu_task::prologue_callback_pop_arg_free will be set to 0
  274. */
  275. #define STARPU_PROLOGUE_CALLBACK_POP_ARG_NFREE (40<<STARPU_MODE_SHIFT)
  276. /**
  277. Used when calling starpu_task_insert() and alike, must be followed
  278. by a void* specifying the value to be set in the sched_data field of the
  279. task.
  280. */
  281. #define STARPU_TASK_SCHED_DATA (41<<STARPU_MODE_SHIFT)
  282. /**
  283. Used when calling starpu_task_insert(), must be followed by a
  284. char * stored in starpu_task::file.
  285. This is automatically set when FXT is enabled.
  286. */
  287. #define STARPU_TASK_FILE (42<<STARPU_MODE_SHIFT)
  288. /**
  289. Used when calling starpu_task_insert(), must be followed by an
  290. int stored in starpu_task::line.
  291. This is automatically set when FXT is enabled.
  292. */
  293. #define STARPU_TASK_LINE (43<<STARPU_MODE_SHIFT)
  294. /**
  295. Used when calling starpu_task_insert(), must be followed by a
  296. pointer to a epilogue callback function
  297. */
  298. #define STARPU_EPILOGUE_CALLBACK (44<<STARPU_MODE_SHIFT)
  299. /**
  300. Used when calling starpu_task_insert(), must be followed by a
  301. pointer to be given as an argument to the epilogue callback
  302. function
  303. */
  304. #define STARPU_EPILOGUE_CALLBACK_ARG (45<<STARPU_MODE_SHIFT)
  305. /**
  306. This has to be the last mode value plus 1
  307. */
  308. #define STARPU_SHIFTED_MODE_MAX (46<<STARPU_MODE_SHIFT)
  309. /**
  310. Set the given \p task corresponding to \p cl with the following arguments.
  311. The argument list must be zero-terminated. The arguments
  312. following the codelet are the same as the ones for the function
  313. starpu_task_insert().
  314. If some arguments of type ::STARPU_VALUE are given, the parameter
  315. starpu_task::cl_arg_free will be set to 1.
  316. */
  317. int starpu_task_set(struct starpu_task *task, struct starpu_codelet *cl, ...);
  318. #ifdef STARPU_USE_FXT
  319. #define starpu_task_set(task, cl, ...) \
  320. starpu_task_set((task), (cl), STARPU_TASK_FILE, __FILE__, STARPU_TASK_LINE, __LINE__, ##__VA_ARGS__)
  321. #endif
  322. /**
  323. Create a task corresponding to \p cl with the following arguments.
  324. The argument list must be zero-terminated. The arguments
  325. following the codelet are the same as the ones for the function
  326. starpu_task_insert().
  327. If some arguments of type ::STARPU_VALUE are given, the parameter
  328. starpu_task::cl_arg_free will be set to 1.
  329. */
  330. struct starpu_task *starpu_task_build(struct starpu_codelet *cl, ...);
  331. #ifdef STARPU_USE_FXT
  332. #define starpu_task_build(cl, ...) \
  333. starpu_task_build((cl), STARPU_TASK_FILE, __FILE__, STARPU_TASK_LINE, __LINE__, ##__VA_ARGS__)
  334. #endif
  335. /**
  336. Create and submit a task corresponding to \p cl with the following
  337. given arguments. The argument list must be zero-terminated.
  338. The arguments following the codelet can be of the following types:
  339. <ul>
  340. <li> ::STARPU_R, ::STARPU_W, ::STARPU_RW, ::STARPU_SCRATCH,
  341. ::STARPU_REDUX an access mode followed by a data handle;
  342. <li> ::STARPU_DATA_ARRAY followed by an array of data handles and
  343. its number of elements;
  344. <li> ::STARPU_DATA_MODE_ARRAY followed by an array of struct
  345. starpu_data_descr, i.e data handles with their associated access
  346. modes, and its number of elements;
  347. <li> ::STARPU_EXECUTE_ON_WORKER, ::STARPU_WORKER_ORDER followed by
  348. an integer value specifying the worker on which to execute the task
  349. (as specified by starpu_task::execute_on_a_specific_worker)
  350. <li> the specific values ::STARPU_VALUE, ::STARPU_CALLBACK,
  351. ::STARPU_CALLBACK_ARG, ::STARPU_CALLBACK_WITH_ARG,
  352. ::STARPU_PRIORITY, ::STARPU_TAG, ::STARPU_TAG_ONLY, ::STARPU_FLOPS,
  353. ::STARPU_SCHED_CTX, ::STARPU_CL_ARGS, ::STARPU_CL_ARGS_NFREE,
  354. ::STARPU_TASK_DEPS_ARRAY, ::STARPU_TASK_COLOR,
  355. ::STARPU_HANDLES_SEQUENTIAL_CONSISTENCY, ::STARPU_TASK_SYNCHRONOUS,
  356. ::STARPU_TASK_END_DEP followed by the appropriated objects as
  357. defined elsewhere.
  358. </ul>
  359. When using ::STARPU_DATA_ARRAY, the access mode of the data handles
  360. is not defined, it will be taken from the codelet
  361. starpu_codelet::modes or starpu_codelet::dyn_modes field. One
  362. should use ::STARPU_DATA_MODE_ARRAY to define the data handles
  363. along with the access modes.
  364. Parameters to be passed to the codelet implementation are defined
  365. through the type ::STARPU_VALUE. The function
  366. starpu_codelet_unpack_args() must be called within the codelet implementation to retrieve them.
  367. */
  368. int starpu_task_insert(struct starpu_codelet *cl, ...);
  369. #ifdef STARPU_USE_FXT
  370. #define starpu_task_insert(cl, ...) \
  371. starpu_task_insert((cl), STARPU_TASK_FILE, __FILE__, STARPU_TASK_LINE, __LINE__, ##__VA_ARGS__)
  372. #endif
  373. /**
  374. Similar to starpu_task_insert(). Kept to avoid breaking old codes.
  375. */
  376. int starpu_insert_task(struct starpu_codelet *cl, ...);
  377. #ifdef STARPU_USE_FXT
  378. #define starpu_insert_task(cl, ...) \
  379. starpu_insert_task((cl), STARPU_TASK_FILE, __FILE__, STARPU_TASK_LINE, __LINE__, ##__VA_ARGS__)
  380. #endif
  381. /**
  382. Assuming that there are already \p current_buffer data handles
  383. passed to the task, and if *allocated_buffers is not 0, the
  384. <c>task->dyn_handles</c> array has size \p *allocated_buffers, this
  385. function makes room for \p room other data handles, allocating or
  386. reallocating <c>task->dyn_handles</c> as necessary and updating \p
  387. *allocated_buffers accordingly. One can thus start with
  388. *allocated_buffers equal to 0 and current_buffer equal to 0, then
  389. make room by calling this function, then store handles with
  390. STARPU_TASK_SET_HANDLE(), make room again with this function, store
  391. yet more handles, etc.
  392. */
  393. void starpu_task_insert_data_make_room(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int current_buffer, int room);
  394. /**
  395. Store data handle \p handle into task \p task with mode \p
  396. arg_type, updating \p *allocated_buffers and \p *current_buffer
  397. accordingly.
  398. */
  399. void starpu_task_insert_data_process_arg(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int *current_buffer, int arg_type, starpu_data_handle_t handle);
  400. /**
  401. Store \p nb_handles data handles \p handles into task \p task,
  402. updating \p *allocated_buffers and \p *current_buffer accordingly.
  403. */
  404. void starpu_task_insert_data_process_array_arg(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int *current_buffer, int nb_handles, starpu_data_handle_t *handles);
  405. /**
  406. Store \p nb_descrs data handles described by \p descrs into task \p
  407. task, updating \p *allocated_buffers and \p *current_buffer
  408. accordingly.
  409. */
  410. void starpu_task_insert_data_process_mode_array_arg(struct starpu_codelet *cl, struct starpu_task *task, int *allocated_buffers, int *current_buffer, int nb_descrs, struct starpu_data_descr *descrs);
  411. /**
  412. Pack arguments of type ::STARPU_VALUE into a buffer which can be
  413. given to a codelet and later unpacked with the function
  414. starpu_codelet_unpack_args().
  415. Instead of calling starpu_codelet_pack_args(), one can also call
  416. starpu_codelet_pack_arg_init(), then starpu_codelet_pack_arg() for
  417. each data, then starpu_codelet_pack_arg_fini().
  418. */
  419. void starpu_codelet_pack_args(void **arg_buffer, size_t *arg_buffer_size, ...);
  420. /**
  421. Structure to be used for starpu_codelet_pack_arg_init() & co, and
  422. starpu_codelet_unpack_arg_init() & co. The contents is public,
  423. however users should not directly access it, but only use as a
  424. parameter to the appropriate functions.
  425. */
  426. struct starpu_codelet_pack_arg_data
  427. {
  428. char *arg_buffer;
  429. size_t arg_buffer_size;
  430. size_t current_offset;
  431. int nargs;
  432. };
  433. /**
  434. Initialize struct starpu_codelet_pack_arg before calling
  435. starpu_codelet_pack_arg() and starpu_codelet_pack_arg_fini(). This
  436. will simply initialize the content of the structure.
  437. */
  438. void starpu_codelet_pack_arg_init(struct starpu_codelet_pack_arg_data *state);
  439. /**
  440. Pack one argument into struct starpu_codelet_pack_arg \p state.
  441. That structure has to be initialized before with
  442. starpu_codelet_pack_arg_init(), and after all
  443. starpu_codelet_pack_arg() calls performed,
  444. starpu_codelet_pack_arg_fini() has to be used to get the \p cl_arg
  445. and \p cl_arg_size to be put in the task.
  446. */
  447. void starpu_codelet_pack_arg(struct starpu_codelet_pack_arg_data *state, const void *ptr, size_t ptr_size);
  448. /**
  449. Finish packing data, after calling starpu_codelet_pack_arg_init()
  450. once and starpu_codelet_pack_arg() several times.
  451. */
  452. void starpu_codelet_pack_arg_fini(struct starpu_codelet_pack_arg_data *state, void **cl_arg, size_t *cl_arg_size);
  453. /**
  454. Retrieve the arguments of type ::STARPU_VALUE associated to a
  455. task automatically created using the function starpu_task_insert(). If
  456. any parameter's value is 0, unpacking will stop there and ignore the remaining
  457. parameters.
  458. */
  459. void starpu_codelet_unpack_args(void *cl_arg, ...);
  460. /**
  461. Initialize \p state with \p cl_arg and \p cl_arg_size. This has to
  462. be called before calling starpu_codelet_unpack_arg().
  463. */
  464. void starpu_codelet_unpack_arg_init(struct starpu_codelet_pack_arg_data *state, void *cl_arg, size_t cl_arg_size);
  465. /**
  466. Unpack the next argument of size \p size from \p state into \p ptr with a copy.
  467. \p state has to be initialized before with starpu_codelet_unpack_arg_init().
  468. */
  469. void starpu_codelet_unpack_arg(struct starpu_codelet_pack_arg_data *state, void *ptr, size_t size);
  470. /**
  471. Unpack the next argument of unknown size from \p state into \p ptr
  472. with a copy. \p ptr is allocated before copying in it the value of
  473. the argument.
  474. The size of the argument is returned in \p size.
  475. \p has to be initialized before with starpu_codelet_unpack_arg_init().
  476. */
  477. void starpu_codelet_dup_arg(struct starpu_codelet_pack_arg_data *state, void **ptr, size_t *size);
  478. /**
  479. Unpack the next argument of unknown size from \p state into \p ptr.
  480. \p ptr will be a pointer to the memory of the argument.
  481. The size of the argument is returned in \p size.
  482. \p has to be initialized before with starpu_codelet_unpack_arg_init().
  483. */
  484. void starpu_codelet_pick_arg(struct starpu_codelet_pack_arg_data *state, void **ptr, size_t *size);
  485. /**
  486. Finish unpacking data, after calling starpu_codelet_unpack_arg_init()
  487. once and starpu_codelet_unpack_arg() or starpu_codelet_dup_arg() or
  488. starpu_codelet_pick_arg() several times.
  489. */
  490. void starpu_codelet_unpack_arg_fini(struct starpu_codelet_pack_arg_data *state);
  491. /**
  492. Call this function during unpacking to skip saving the argument in ptr.
  493. */
  494. void starpu_codelet_unpack_discard_arg(struct starpu_codelet_pack_arg_data *state);
  495. /**
  496. Similar to starpu_codelet_unpack_args(), but if any parameter is 0,
  497. copy the part of \p cl_arg that has not been read in \p buffer
  498. which can then be used in a later call to one of the unpack
  499. functions.
  500. */
  501. void starpu_codelet_unpack_args_and_copyleft(void *cl_arg, void *buffer, size_t buffer_size, ...);
  502. /** @} */
  503. #ifdef __cplusplus
  504. }
  505. #endif
  506. #endif /* __STARPU_TASK_UTIL_H__ */