openmp_runtime_support.doxy 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. /*
  2. * This file is part of the StarPU Handbook.
  3. * Copyright (C) 2014 INRIA
  4. * See the file version.doxy for copying conditions.
  5. */
  6. /*! \defgroup API_OpenMP_Runtime_Support OpenMP Runtime Support
  7. \brief This section describes the interface provided for implementing OpenMP runtimes on top of StarPU.
  8. \struct starpu_omp_lock_t
  9. \ingroup API_OpenMP_Runtime_Support
  10. Opaque Simple Lock object (\ref SimpleLock) for inter-task synchronization operations.
  11. \sa starpu_omp_init_lock()
  12. \sa starpu_omp_destroy_lock()
  13. \sa starpu_omp_set_lock()
  14. \sa starpu_omp_unset_lock()
  15. \sa starpu_omp_test_lock()
  16. \var starpu_omp_lock_t::internal
  17. Is an opaque pointer for internal use.
  18. \struct starpu_omp_nest_lock_t
  19. \ingroup API_OpenMP_Runtime_Support
  20. Opaque Nestable Lock object (\ref NestableLock) for inter-task synchronization operations.
  21. \sa starpu_omp_init_nest_lock()
  22. \sa starpu_omp_destroy_nest_lock()
  23. \sa starpu_omp_set_nest_lock()
  24. \sa starpu_omp_unset_nest_lock()
  25. \sa starpu_omp_test_nest_lock()
  26. \var starpu_omp_nest_lock_t::internal
  27. Is an opaque pointer for internal use.
  28. \enum starpu_omp_sched_value
  29. \ingroup API_OpenMP_Runtime_Support
  30. Set of constants for selecting the for loop iteration scheduling algorithm
  31. (\ref OMPFor) as defined by the OpenMP specification.
  32. \var starpu_omp_sched_value::starpu_omp_sched_undefined
  33. \ingroup API_OpenMP_Runtime_Support
  34. Undefined iteration scheduling algorithm.
  35. \var starpu_omp_sched_value::starpu_omp_sched_static
  36. \ingroup API_OpenMP_Runtime_Support
  37. \b Static iteration scheduling algorithm.
  38. \var starpu_omp_sched_value::starpu_omp_sched_dynamic
  39. \ingroup API_OpenMP_Runtime_Support
  40. \b Dynamic iteration scheduling algorithm.
  41. \var starpu_omp_sched_value::starpu_omp_sched_guided
  42. \ingroup API_OpenMP_Runtime_Support
  43. \b Guided iteration scheduling algorithm.
  44. \var starpu_omp_sched_value::starpu_omp_sched_auto
  45. \ingroup API_OpenMP_Runtime_Support
  46. \b Automatically choosen iteration scheduling algorithm.
  47. \var starpu_omp_sched_value::starpu_omp_sched_runtime
  48. \ingroup API_OpenMP_Runtime_Support
  49. Choice of iteration scheduling algorithm deferred at \b runtime.
  50. \sa starpu_omp_for()
  51. \sa starpu_omp_for_inline_first()
  52. \sa starpu_omp_for_inline_next()
  53. \sa starpu_omp_for_alt()
  54. \sa starpu_omp_for_inline_first_alt()
  55. \sa starpu_omp_for_inline_next_alt()
  56. \enum starpu_omp_proc_bind_value
  57. \ingroup API_OpenMP_Runtime_Support
  58. Set of constants for selecting the processor binding method, as defined in the
  59. OpenMP specification.
  60. \var starpu_omp_proc_bind_value::starpu_omp_proc_bind_undefined
  61. \ingroup API_OpenMP_Runtime_Support
  62. Undefined processor binding method.
  63. \var starpu_omp_proc_bind_value::starpu_omp_proc_bind_false
  64. \ingroup API_OpenMP_Runtime_Support
  65. Team threads may be moved between places at any time.
  66. \var starpu_omp_proc_bind_value::starpu_omp_proc_bind_true
  67. \ingroup API_OpenMP_Runtime_Support
  68. Team threads may not be moved between places.
  69. \var starpu_omp_proc_bind_value::starpu_omp_proc_bind_master
  70. \ingroup API_OpenMP_Runtime_Support
  71. Assign every thread in the team to the same place as the \b master thread.
  72. \var starpu_omp_proc_bind_value::starpu_omp_proc_bind_close
  73. \ingroup API_OpenMP_Runtime_Support
  74. Assign every thread in the team to a place \b close to the parent thread.
  75. \var starpu_omp_proc_bind_value::starpu_omp_proc_bind_spread
  76. \ingroup API_OpenMP_Runtime_Support
  77. Assign team threads as a sparse distribution over the selected places.
  78. \sa starpu_omp_get_proc_bind()
  79. \struct starpu_omp_parallel_region_attr
  80. \ingroup API_OpenMP_Runtime_Support
  81. Set of attributes used for creating a new parallel region.
  82. \sa starpu_omp_parallel_region()
  83. \var struct starpu_codelet starpu_omp_parallel_region_attr::cl
  84. Is a ::starpu_codelet (\ref API_Codelet_And_Tasks) to use for the parallel region
  85. implicit tasks. The codelet must provide a CPU implementation function.
  86. \var starpu_data_handle_t *starpu_omp_parallel_region_attr::handles
  87. Is an array of zero or more ::starpu_data_handle_t data handle to be passed to
  88. the parallel region implicit tasks.
  89. \var void *starpu_omp_parallel_region_attr::cl_arg
  90. Is an optional pointer to an inline argument to be passed to the region implicit tasks.
  91. \var size_t starpu_omp_parallel_region_attr::cl_arg_size
  92. Is the size of the optional inline argument to be passed to the region implicit tasks, or 0 if unused.
  93. \var unsigned starpu_omp_parallel_region_attr::cl_arg_free
  94. Is a boolean indicating whether the optional inline argument should be automatically freed (true), or not (false).
  95. \var int starpu_omp_parallel_region_attr::if_clause
  96. Is a boolean indicating whether the \b if clause of the corresponding <c>pragma
  97. omp parallel</c> is true or false.
  98. \var int starpu_omp_parallel_region_attr::num_threads
  99. Is an integer indicating the requested number of threads in the team of the
  100. newly created parallel region, or 0 to let the runtime choose the number of
  101. threads alone. This attribute may be ignored by the runtime system if the
  102. requested number of threads is higher than the number of threads that the
  103. runtime can create.
  104. \struct starpu_omp_task_region_attr
  105. \ingroup API_OpenMP_Runtime_Support
  106. Set of attributes used for creating a new task region.
  107. \sa starpu_omp_task_region()
  108. \var struct starpu_codelet starpu_omp_task_region_attr::cl
  109. Is a ::starpu_codelet (\ref API_Codelet_And_Tasks) to use for the task region
  110. explicit task. The codelet must provide a CPU implementation function or an
  111. accelerator implementation for offloaded target regions.
  112. \var starpu_data_handle_t *starpu_omp_task_region_attr::handles
  113. Is an array of zero or more ::starpu_data_handle_t data handle to be passed to
  114. the task region explicit tasks.
  115. \var void *starpu_omp_task_region_attr::cl_arg
  116. Is an optional pointer to an inline argument to be passed to the region implicit tasks.
  117. \var size_t starpu_omp_task_region_attr::cl_arg_size
  118. Is the size of the optional inline argument to be passed to the region implicit
  119. tasks, or 0 if unused.
  120. \var unsigned starpu_omp_task_region_attr::cl_arg_free
  121. Is a boolean indicating whether the optional inline argument should be
  122. automatically freed (true), or not (false).
  123. \var int starpu_omp_task_region_attr::if_clause
  124. Is a boolean indicating whether the \b if clause of the corresponding <c>pragma
  125. omp task</c> is true or false.
  126. \var int starpu_omp_task_region_attr::final_clause
  127. Is a boolean indicating whether the \b final clause of the corresponding <c>pragma
  128. omp task</c> is true or false.
  129. \var int starpu_omp_task_region_attr::untied_clause
  130. Is a boolean indicating whether the \b untied clause of the corresponding <c>pragma
  131. omp task</c> is true or false.
  132. \var int starpu_omp_task_region_attr::mergeable_clause
  133. Is a boolean indicating whether the \b mergeable clause of the corresponding <c>pragma
  134. omp task</c> is true or false.
  135. @name Initialisation
  136. \ingroup API_OpenMP_Runtime_Support
  137. \def STARPU_OPENMP
  138. \ingroup API_OpenMP_Runtime_Support
  139. This macro is defined when StarPU has been installed with OpenMP Runtime
  140. support. It should be used in your code to detect the availability of
  141. the runtime support for OpenMP.
  142. \fn int starpu_omp_init(void)
  143. \ingroup API_OpenMP_Runtime_Support
  144. Initializes StarPU and its OpenMP Runtime support.
  145. \fn void starpu_omp_shutdown(void)
  146. \ingroup API_OpenMP_Runtime_Support
  147. Shutdown StarPU and its OpenMP Runtime support.
  148. @name Parallel
  149. \anchor ORS_Parallel
  150. \ingroup API_OpenMP_Runtime_Support
  151. \fn void starpu_omp_parallel_region(const struct starpu_omp_parallel_region_attr *attr)
  152. \ingroup API_OpenMP_Runtime_Support
  153. Generates and launch an OpenMP parallel region and return after its
  154. completion. \p attr specifies the attributes for the generated parallel region.
  155. If this function is called from inside another, generating, parallel region, the
  156. generated parallel region is nested within the generating parallel region.
  157. This function can be used to implement <c>\#pragma omp parallel</c>.
  158. \fn void starpu_omp_master(void (*f)(void *arg), void *arg)
  159. \ingroup API_OpenMP_Runtime_Support
  160. Executes a function only on the master thread of the OpenMP
  161. parallel region it is called from. When called from a thread that is not the
  162. master of the parallel region it is called from, this function does nothing. \p
  163. f is the function to be called. \p arg is an argument passed to function \p f.
  164. This function can be used to implement <c>\#pragma omp master</c>.
  165. \fn int starpu_omp_master_inline(void)
  166. \ingroup API_OpenMP_Runtime_Support
  167. Determines whether the calling thread is the master of the OpenMP parallel region
  168. it is called from or not.
  169. This function can be used to implement <c>\#pragma omp master</c> without code
  170. outlining.
  171. \return <c>!0</c> if called by the region's master thread.
  172. \return <c>0</c> if not called by the region's master thread.
  173. @name Synchronization
  174. \anchor ORS_Synchronization
  175. \ingroup API_OpenMP_Runtime_Support
  176. \fn void starpu_omp_barrier(void)
  177. \ingroup API_OpenMP_Runtime_Support
  178. Waits until each participating thread of the innermost OpenMP parallel region
  179. has reached the barrier and each explicit OpenMP task bound to this region has
  180. completed its execution.
  181. This function can be used to implement <c>\#pragma omp barrier</c>.
  182. \fn void starpu_omp_critical(void (*f)(void *arg), void *arg, const char *name)
  183. \ingroup API_OpenMP_Runtime_Support
  184. Waits until no other thread is executing within the context of the selected
  185. critical section, then proceeds to the exclusive execution of a function within
  186. the critical section. \p f is the function to be executed in the critical
  187. section. \p arg is an argument passed to function \p f. \p name is the name of
  188. the selected critical section. If <c>name == NULL</c>, the selected critical
  189. section is the unique anonymous critical section.
  190. This function can be used to implement <c>\#pragma omp critical</c>.
  191. \fn void starpu_omp_critical_inline_begin(const char *name)
  192. \ingroup API_OpenMP_Runtime_Support
  193. Waits until execution can proceed exclusively within the context of the
  194. selected critical section. \p name is the name of the selected critical
  195. section. If <c>name == NULL</c>, the selected critical section is the unique
  196. anonymous critical section.
  197. This function together with #starpu_omp_critical_inline_end can be used to
  198. implement <c>\#pragma omp critical</c> without code outlining.
  199. \fn void starpu_omp_critical_inline_end(const char *name)
  200. \ingroup API_OpenMP_Runtime_Support
  201. Ends the exclusive execution within the context of the selected critical
  202. section. \p name is the name of the selected critical section. If
  203. <c>name==NULL</c>, the selected critical section is the unique anonymous
  204. critical section.
  205. This function together with #starpu_omp_critical_inline_begin can be used to
  206. implement <c>\#pragma omp critical</c> without code outlining.
  207. @name Worksharing
  208. \anchor ORS_Worksharing
  209. \ingroup API_OpenMP_Runtime_Support
  210. \fn void starpu_omp_single(void (*f)(void *arg), void *arg, int nowait)
  211. \ingroup API_OpenMP_Runtime_Support
  212. Ensures that a single participating thread of the innermost OpenMP parallel
  213. region executes a function. \p f is the function to be executed by a single
  214. thread. \p arg is an argument passed to function \p f. \p nowait is a flag
  215. indicating whether an implicit barrier is requested after the single section
  216. (<c>nowait==0</c>) or not (<c>nowait==!0</c>).
  217. This function can be used to implement <c>\#pragma omp single</c>.
  218. \fn int starpu_omp_single_inline(void)
  219. \ingroup API_OpenMP_Runtime_Support
  220. Decides whether the current thread is elected to run the following single
  221. section among the participating threads of the innermost OpenMP parallel
  222. region.
  223. This function can be used to implement <c>\#pragma omp single</c> without code
  224. outlining.
  225. \return <c>!0</c> if the calling thread has won the election.
  226. \return <c>0</c> if the calling thread has lost the election.
  227. \fn void starpu_omp_single_copyprivate(void (*f)(void *arg, void *data, unsigned long long data_size), void *arg, void *data, unsigned long long data_size)
  228. \ingroup API_OpenMP_Runtime_Support
  229. This function executes \p f on a single task of the current parallel region
  230. task, and then broadcast the contents of the memory block pointed by the
  231. copyprivate pointer \p data and of size \p data_size to the corresponding \p
  232. data pointed memory blocks of all the other participating region tasks. This
  233. function can be used to implement <c>\#pragma omp single</c> with a copyprivate
  234. clause.
  235. \sa starpu_omp_single_copyprivate_inline
  236. \sa starpu_omp_single_copyprivate_inline_begin
  237. \sa starpu_omp_single_copyprivate_inline_end
  238. \fn void *starpu_omp_single_copyprivate_inline_begin(void *data)
  239. \ingroup API_OpenMP_Runtime_Support
  240. This function elects one task among the tasks of the current parallel region
  241. task to execute the following single section, and then broadcast the
  242. copyprivate pointer \p data to all the other participating region tasks. This
  243. function can be used to implement <c>\#pragma omp single</c> with a copyprivate
  244. clause without code outlining.
  245. \sa starpu_omp_single_copyprivate_inline
  246. \sa starpu_omp_single_copyprivate_inline_end
  247. \fn void starpu_omp_single_copyprivate_inline_end(void)
  248. \ingroup API_OpenMP_Runtime_Support
  249. This function completes the execution of a single section and returns the
  250. broadcasted copyprivate pointer for tasks that lost the election and <c>NULL</c> for
  251. the task that won the election. This function can be used to implement
  252. <c>\#pragma omp single</c> with a copyprivate clause without code outlining.
  253. \return the copyprivate pointer for tasks that lost the election and therefore did not execute the code of the single section.
  254. \return <c>NULL</c> for the task that won the election and executed the code of the single section.
  255. \sa starpu_omp_single_copyprivate_inline
  256. \sa starpu_omp_single_copyprivate_inline_begin
  257. \fn void starpu_omp_for(void (*f)(unsigned long long _first_i, unsigned long long _nb_i, void *arg), void *arg, unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, int nowait)
  258. \ingroup API_OpenMP_Runtime_Support
  259. Executes a parallel loop together with the other threads participating to the
  260. innermost parallel region. \p f is the function to be executed iteratively. \p
  261. arg is an argument passed to function \p f. \p nb_iterations is the number of
  262. iterations to be performed by the parallel loop. \p chunk is the number of
  263. consecutive iterations that should be affected to the same thread when
  264. scheduling the loop workshares, it follows the semantics of the \c modifier
  265. argument in OpenMP <c>\#pragma omp for</c> specification. \p schedule is the
  266. scheduling mode according to the OpenMP specification. \p ordered is a flag
  267. indicating whether the loop region may contain an ordered section
  268. (<c>ordered==!0</c>) or not (<c>ordered==0</c>). \p nowait is a flag
  269. indicating whether an implicit barrier is requested after the for section
  270. (<c>nowait==0</c>) or not (<c>nowait==!0</c>).
  271. The function \p f will be called with arguments \p _first_i, the first iteration
  272. to perform, \p _nb_i, the number of consecutive iterations to perform before
  273. returning, \p arg, the free \p arg argument.
  274. This function can be used to implement <c>\#pragma omp for</c>.
  275. \fn int starpu_omp_for_inline_first(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_first_i, unsigned long long *_nb_i)
  276. \ingroup API_OpenMP_Runtime_Support
  277. Decides whether the current thread should start to execute a parallel loop
  278. section. See #starpu_omp_for for the argument description.
  279. This function together with #starpu_omp_for_inline_next can be used to
  280. implement <c>\#pragma omp for</c> without code outlining.
  281. \return <c>!0</c> if the calling thread participates to the loop region and
  282. should execute a first chunk of iterations. In that case, \p *_first_i will be
  283. set to the first iteration of the chunk to perform and \p *_nb_i will be set to
  284. the number of iterations of the chunk to perform.
  285. \return <c>0</c> if the calling thread does not participate to the loop region
  286. because all the available iterations have been affected to the other threads of
  287. the parallel region.
  288. \sa starpu_omp_for
  289. \fn int starpu_omp_for_inline_next(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_first_i, unsigned long long *_nb_i)
  290. \ingroup API_OpenMP_Runtime_Support
  291. Decides whether the current thread should continue to execute a parallel loop
  292. section. See #starpu_omp_for for the argument description.
  293. This function together with #starpu_omp_for_inline_first can be used to
  294. implement <c>\#pragma omp for</c> without code outlining.
  295. \return <c>!0</c> if the calling thread should execute a next chunk of
  296. iterations. In that case, \p *_first_i will be set to the first iteration of the
  297. chunk to perform and \p *_nb_i will be set to the number of iterations of the
  298. chunk to perform.
  299. \return <c>0</c> if the calling thread does not participate anymore to the loop
  300. region because all the available iterations have been affected to the other
  301. threads of the parallel region.
  302. \sa starpu_omp_for
  303. \fn void starpu_omp_for_alt(void (*f)(unsigned long long _begin_i, unsigned long long _end_i, void *arg), void *arg, unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, int nowait)
  304. \ingroup API_OpenMP_Runtime_Support
  305. Alternative implementation of a parallel loop. This function differs from
  306. #starpu_omp_for in the expected arguments of the loop function \c f.
  307. The function \p f will be called with arguments \p _begin_i, the first iteration
  308. to perform, \p _end_i, the first iteration not to perform before
  309. returning, \p arg, the free \p arg argument.
  310. This function can be used to implement <c>\#pragma omp for</c>.
  311. \sa starpu_omp_for
  312. \fn int starpu_omp_for_inline_first_alt(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_begin_i, unsigned long long *_end_i)
  313. \ingroup API_OpenMP_Runtime_Support
  314. Inline version of the alternative implementation of a parallel loop.
  315. This function together with #starpu_omp_for_inline_next_alt can be used to
  316. implement <c>\#pragma omp for</c> without code outlining.
  317. \sa starpu_omp_for
  318. \sa starpu_omp_for_alt
  319. \sa starpu_omp_for_inline_first
  320. \fn int starpu_omp_for_inline_next_alt(unsigned long long nb_iterations, unsigned long long chunk, int schedule, int ordered, unsigned long long *_begin_i, unsigned long long *_end_i)
  321. \ingroup API_OpenMP_Runtime_Support
  322. Inline version of the alternative implementation of a parallel loop.
  323. This function together with #starpu_omp_for_inline_first_alt can be used to
  324. implement <c>\#pragma omp for</c> without code outlining.
  325. \sa starpu_omp_for
  326. \sa starpu_omp_for_alt
  327. \sa starpu_omp_for_inline_next
  328. \fn void starpu_omp_ordered(void (*f)(void *arg), void *arg)
  329. \ingroup API_OpenMP_Runtime_Support
  330. Ensures that a function is sequentially executed once for each iteration in
  331. order within a parallel loop, by the thread that own the iteration. \p f is the
  332. function to be executed by the thread that own the current iteration. \p arg is
  333. an argument passed to function \p f.
  334. This function can be used to implement <c>\#pragma omp ordered</c>.
  335. \fn void starpu_omp_ordered_inline_begin(void)
  336. \ingroup API_OpenMP_Runtime_Support
  337. Waits until all the iterations of a parallel loop below the iteration owned by
  338. the current thread have been executed.
  339. This function together with #starpu_omp_ordered_inline_end can be used to
  340. implement <c>\#pragma omp ordered</c> without code code outlining.
  341. \fn void starpu_omp_ordered_inline_end(void)
  342. \ingroup API_OpenMP_Runtime_Support
  343. Notifies that the ordered section for the current iteration has been completed.
  344. This function together with #starpu_omp_ordered_inline_begin can be used to
  345. implement <c>\#pragma omp ordered</c> without code code outlining.
  346. \fn void starpu_omp_sections(unsigned long long nb_sections, void (**section_f)(void *arg), void **section_arg, int nowait)
  347. \ingroup API_OpenMP_Runtime_Support
  348. Ensures that each function of a given array of functions is executed by one and
  349. only one thread. \p nb_sections is the number of functions in the array \p
  350. section_f. \p section_f is the array of functions to be executed as sections. \p
  351. section_arg is an array of arguments to be passed to the corresponding function.
  352. \p nowait is a flag indicating whether an implicit barrier is requested after
  353. the execution of all the sections (<c>nowait==0</c>) or not (<c>nowait==!0</c>).
  354. This function can be used to implement <c>\#pragma omp sections</c> and <c>\#pragma omp section</c>.
  355. \fn void starpu_omp_sections_combined(unsigned long long nb_sections, void (*section_f)(unsigned long long section_num, void *arg), void *section_arg, int nowait)
  356. \ingroup API_OpenMP_Runtime_Support
  357. Alternative implementation of sections. This function differs from
  358. #starpu_omp_sections in that all the sections are combined within a single
  359. function in this version. \p section_f is the function implementing the combined
  360. sections.
  361. The function \p section_f will be called with arguments \p section_num, the
  362. section number to be executed, \p arg, the entry of \p section_arg corresponding
  363. to this section.
  364. This function can be used to implement <c>\#pragma omp sections</c> and <c>\#pragma omp section</c>.
  365. \sa starpu_omp_sections
  366. @name Task
  367. \anchor ORS_Task
  368. \ingroup API_OpenMP_Runtime_Support
  369. \fn void starpu_omp_task_region(const struct starpu_omp_task_region_attr *attr)
  370. \ingroup API_OpenMP_Runtime_Support
  371. Generates an explicit child task. The execution of the generated task is
  372. asynchronous with respect to the calling code unless specified otherwise.
  373. \p attr specifies the attributes for the generated task region.
  374. This function can be used to implement <c>\#pragma omp task</c>.
  375. \fn void starpu_omp_taskwait(void)
  376. \ingroup API_OpenMP_Runtime_Support
  377. Waits for the completion of the tasks generated by the current task. This
  378. function does not wait for the descendants of the tasks generated by the current
  379. task.
  380. This function can be used to implement <c>\#pragma omp taskwait</c>.
  381. \fn void starpu_omp_taskgroup(void (*f)(void *arg), void *arg)
  382. \ingroup API_OpenMP_Runtime_Support
  383. Launches a function and wait for the completion of every descendant task
  384. generated during the execution of the function.
  385. This function can be used to implement <c>\#pragma omp taskgroup</c>.
  386. \sa starpu_omp_taskgroup_inline_begin
  387. \sa starpu_omp_taskgroup_inline_end
  388. \fn void starpu_omp_taskgroup_inline_begin(void)
  389. \ingroup API_OpenMP_Runtime_Support
  390. Launches a function and gets ready to wait for the completion of every descendant task
  391. generated during the dynamic scope of the taskgroup.
  392. This function can be used to implement <c>\#pragma omp taskgroup</c> without code outlining.
  393. \sa starpu_omp_taskgroup
  394. \sa starpu_omp_taskgroup_inline_end
  395. \fn void starpu_omp_taskgroup_inline_end(void)
  396. \ingroup API_OpenMP_Runtime_Support
  397. Waits for the completion of every descendant task
  398. generated during the dynamic scope of the taskgroup.
  399. This function can be used to implement <c>\#pragma omp taskgroup</c> without code outlining.
  400. \sa starpu_omp_taskgroup
  401. \sa starpu_omp_taskgroup_inline_begin
  402. @name API
  403. \anchor ORS_API
  404. \ingroup API_OpenMP_Runtime_Support
  405. \fn void starpu_omp_set_num_threads(int threads)
  406. \ingroup API_OpenMP_Runtime_Support
  407. This function sets ICVS nthreads_var for the parallel regions to be created
  408. with the current region.
  409. Note: The StarPU OpenMP runtime support currently ignores
  410. this setting for nested parallel regions.
  411. \sa starpu_omp_get_num_threads
  412. \sa starpu_omp_get_thread_num
  413. \sa starpu_omp_get_max_threads
  414. \sa starpu_omp_get_num_procs
  415. \fn int starpu_omp_get_num_threads()
  416. \ingroup API_OpenMP_Runtime_Support
  417. This function returns the number of threads of the current region.
  418. \return the number of threads of the current region.
  419. \sa starpu_omp_set_num_threads
  420. \sa starpu_omp_get_thread_num
  421. \sa starpu_omp_get_max_threads
  422. \sa starpu_omp_get_num_procs
  423. \fn int starpu_omp_get_thread_num()
  424. \ingroup API_OpenMP_Runtime_Support
  425. This function returns the rank of the current thread among the threads
  426. of the current region.
  427. \return the rank of the current thread in the current region.
  428. \sa starpu_omp_set_num_threads
  429. \sa starpu_omp_get_num_threads
  430. \sa starpu_omp_get_max_threads
  431. \sa starpu_omp_get_num_procs
  432. \fn int starpu_omp_get_max_threads()
  433. \ingroup API_OpenMP_Runtime_Support
  434. This function returns the maximum number of threads that can be used to
  435. create a region from the current region.
  436. \return the maximum number of threads that can be used to create a region from the current region.
  437. \sa starpu_omp_set_num_threads
  438. \sa starpu_omp_get_num_threads
  439. \sa starpu_omp_get_thread_num
  440. \sa starpu_omp_get_num_procs
  441. \fn int starpu_omp_get_num_procs(void)
  442. \ingroup API_OpenMP_Runtime_Support
  443. This function returns the number of StarPU CPU workers.
  444. \return the number of StarPU CPU workers.
  445. \sa starpu_omp_set_num_threads
  446. \sa starpu_omp_get_num_threads
  447. \sa starpu_omp_get_thread_num
  448. \sa starpu_omp_get_max_threads
  449. \fn int starpu_omp_in_parallel(void)
  450. \ingroup API_OpenMP_Runtime_Support
  451. This function returns whether it is called from the scope of a parallel region or not.
  452. \return <c>!0</c> if called from a parallel region scope.
  453. \return <c>0</c> otherwise.
  454. \fn void starpu_omp_set_dynamic(int dynamic_threads)
  455. \ingroup API_OpenMP_Runtime_Support
  456. This function enables (1) or disables (0) dynamically adjusting the number of parallel threads.
  457. Note: The StarPU OpenMP runtime support currently ignores the argument of this function.
  458. \sa starpu_omp_get_dynamic
  459. \fn int starpu_omp_get_dynamic(void)
  460. \ingroup API_OpenMP_Runtime_Support
  461. This function returns the state of dynamic thread number adjustment.
  462. \return <c>!0</c> if dynamic thread number adjustment is enabled.
  463. \return <c>0</c> otherwise.
  464. \sa starpu_omp_set_dynamic
  465. \fn void starpu_omp_set_nested(int nested)
  466. \ingroup API_OpenMP_Runtime_Support
  467. This function enables (1) or disables (0) nested parallel regions.
  468. Note: The StarPU OpenMP runtime support currently ignores the argument of this function.
  469. \sa starpu_omp_get_nested
  470. \sa starpu_omp_get_max_active_levels
  471. \sa starpu_omp_set_max_active_levels
  472. \sa starpu_omp_get_level
  473. \sa starpu_omp_get_active_level
  474. \fn int starpu_omp_get_nested(void)
  475. \ingroup API_OpenMP_Runtime_Support
  476. This function returns whether nested parallel sections are enabled or not.
  477. \return <c>!0</c> if nested parallel sections are enabled.
  478. \return <c>0</c> otherwise.
  479. \sa starpu_omp_set_nested
  480. \sa starpu_omp_get_max_active_levels
  481. \sa starpu_omp_set_max_active_levels
  482. \sa starpu_omp_get_level
  483. \sa starpu_omp_get_active_level
  484. \fn int starpu_omp_get_cancellation(void)
  485. \ingroup API_OpenMP_Runtime_Support
  486. This function returns the state of the cancel ICVS var.
  487. \fn void starpu_omp_set_schedule(enum starpu_omp_sched_value kind, int modifier)
  488. \ingroup API_OpenMP_Runtime_Support
  489. This function sets the default scheduling kind for upcoming loops within the
  490. current parallel section. \p kind is the scheduler kind, \p modifier
  491. complements the scheduler kind with informations such as the chunk size,
  492. in accordance with the OpenMP specification.
  493. \sa starpu_omp_get_schedule
  494. \fn void starpu_omp_get_schedule(enum starpu_omp_sched_value *kind, int *modifier)
  495. \ingroup API_OpenMP_Runtime_Support
  496. This function returns the current selected default loop scheduler.
  497. \return the kind and the modifier of the current default loop scheduler.
  498. \sa starpu_omp_set_schedule
  499. \fn int starpu_omp_get_thread_limit(void)
  500. \ingroup API_OpenMP_Runtime_Support
  501. This function returns the number of StarPU CPU workers.
  502. \return the number of StarPU CPU workers.
  503. \fn void starpu_omp_set_max_active_levels(int max_levels)
  504. \ingroup API_OpenMP_Runtime_Support
  505. This function sets the maximum number of allowed active parallel section levels.
  506. Note: The StarPU OpenMP runtime support currently ignores the argument of this function and assume \p max_levels equals <c>1</c> instead.
  507. \sa starpu_omp_set_nested
  508. \sa starpu_omp_get_nested
  509. \sa starpu_omp_get_max_active_levels
  510. \sa starpu_omp_get_level
  511. \sa starpu_omp_get_active_level
  512. \fn int starpu_omp_get_max_active_levels(void)
  513. \ingroup API_OpenMP_Runtime_Support
  514. This function returns the current maximum number of allowed active parallel section levels
  515. \return the current maximum number of allowed active parallel section levels.
  516. \sa starpu_omp_set_nested
  517. \sa starpu_omp_get_nested
  518. \sa starpu_omp_set_max_active_levels
  519. \sa starpu_omp_get_level
  520. \sa starpu_omp_get_active_level
  521. \fn int starpu_omp_get_level(void)
  522. \ingroup API_OpenMP_Runtime_Support
  523. This function returns the nesting level of the current parallel section.
  524. \return the nesting level of the current parallel section.
  525. \sa starpu_omp_set_nested
  526. \sa starpu_omp_get_nested
  527. \sa starpu_omp_get_max_active_levels
  528. \sa starpu_omp_set_max_active_levels
  529. \sa starpu_omp_get_active_level
  530. \fn int starpu_omp_get_ancestor_thread_num(int level)
  531. \ingroup API_OpenMP_Runtime_Support
  532. This function returns the number of the ancestor of the current parallel section.
  533. \return the number of the ancestor of the current parallel section.
  534. \fn int starpu_omp_get_team_size(int level)
  535. \ingroup API_OpenMP_Runtime_Support
  536. This function returns the size of the team of the current parallel section.
  537. \return the size of the team of the current parallel section.
  538. \fn int starpu_omp_get_active_level(void)
  539. \ingroup API_OpenMP_Runtime_Support
  540. This function returns the nestinglevel of the current innermost active parallel section.
  541. \return the nestinglevel of the current innermost active parallel section.
  542. \sa starpu_omp_set_nested
  543. \sa starpu_omp_get_nested
  544. \sa starpu_omp_get_max_active_levels
  545. \sa starpu_omp_set_max_active_levels
  546. \sa starpu_omp_get_level
  547. \fn int starpu_omp_in_final(void)
  548. \ingroup API_OpenMP_Runtime_Support
  549. This function checks whether the current task is final or not.
  550. \return <c>!0</c> if called from a final task.
  551. \return <c>0</c> otherwise.
  552. \fn enum starpu_omp_proc_bind_value starpu_omp_get_proc_bind(void)
  553. \ingroup API_OpenMP_Runtime_Support
  554. This function returns the proc_bind setting of the current parallel region.
  555. \return the proc_bind setting of the current parallel region.
  556. \fn void starpu_omp_set_default_device(int device_num)
  557. \ingroup API_OpenMP_Runtime_Support
  558. This function sets the number of the device to use as default.
  559. Note: The StarPU OpenMP runtime support currently ignores the argument of this function.
  560. \sa starpu_omp_get_default_device
  561. \sa starpu_omp_is_initial_device
  562. \fn int starpu_omp_get_default_device(void)
  563. \ingroup API_OpenMP_Runtime_Support
  564. This function returns the number of the device used as default.
  565. \return the number of the device used as default.
  566. \sa starpu_omp_set_default_device
  567. \sa starpu_omp_is_initial_device
  568. \fn int starpu_omp_get_num_devices(void)
  569. \ingroup API_OpenMP_Runtime_Support
  570. This function returns the number of the devices.
  571. \return the number of the devices.
  572. \fn int starpu_omp_get_num_teams(void)
  573. \ingroup API_OpenMP_Runtime_Support
  574. This function returns the number of teams in the current teams region.
  575. \return the number of teams in the current teams region.
  576. \sa starpu_omp_get_num_teams
  577. \fn int starpu_omp_get_team_num(void)
  578. \ingroup API_OpenMP_Runtime_Support
  579. This function returns the team number of the calling thread.
  580. \return the team number of the calling thread.
  581. \sa starpu_omp_get_num_teams
  582. \fn int starpu_omp_is_initial_device(void)
  583. \ingroup API_OpenMP_Runtime_Support
  584. This function checks whether the current device is the initial device or not.
  585. \fn int starpu_omp_get_max_task_priority
  586. \ingroup API_OpenMP_Runtime_Support
  587. The omp_get_max_task_priority routine returns the maximum value that can be
  588. specified in the priority clause.
  589. \return <c>!0</c> if called from the host device.
  590. \return <c>0</c> otherwise.
  591. \sa starpu_omp_set_default_device
  592. \sa starpu_omp_get_default_device
  593. \fn void starpu_omp_init_lock(starpu_omp_lock_t *lock)
  594. \ingroup API_OpenMP_Runtime_Support
  595. This function initializes an opaque lock object.
  596. \sa starpu_omp_destroy_lock
  597. \sa starpu_omp_set_lock
  598. \sa starpu_omp_unset_lock
  599. \sa starpu_omp_test_lock
  600. \fn void starpu_omp_destroy_lock(starpu_omp_lock_t *lock)
  601. \ingroup API_OpenMP_Runtime_Support
  602. This function destroys an opaque lock object.
  603. \sa starpu_omp_init_lock
  604. \sa starpu_omp_set_lock
  605. \sa starpu_omp_unset_lock
  606. \sa starpu_omp_test_lock
  607. \fn void starpu_omp_set_lock(starpu_omp_lock_t *lock)
  608. \ingroup API_OpenMP_Runtime_Support
  609. This function locks an opaque lock object. If the lock is already locked, the
  610. function will block until it succeeds in exclusively acquiring the lock.
  611. \sa starpu_omp_init_lock
  612. \sa starpu_omp_destroy_lock
  613. \sa starpu_omp_unset_lock
  614. \sa starpu_omp_test_lock
  615. \fn void starpu_omp_unset_lock(starpu_omp_lock_t *lock)
  616. \ingroup API_OpenMP_Runtime_Support
  617. This function unlocks a previously locked lock object. The behaviour of this
  618. function is unspecified if it is called on an unlocked lock object.
  619. \sa starpu_omp_init_lock
  620. \sa starpu_omp_destroy_lock
  621. \sa starpu_omp_set_lock
  622. \sa starpu_omp_test_lock
  623. \fn int starpu_omp_test_lock(starpu_omp_lock_t *lock)
  624. \ingroup API_OpenMP_Runtime_Support
  625. This function unblockingly attempts to lock a lock object and returns whether
  626. it succeeded or not.
  627. \return <c>!0</c> if the function succeeded in acquiring the lock.
  628. \return <c>0</c> if the lock was already locked.
  629. \sa starpu_omp_init_lock
  630. \sa starpu_omp_destroy_lock
  631. \sa starpu_omp_set_lock
  632. \sa starpu_omp_unset_lock
  633. \fn void starpu_omp_init_nest_lock(starpu_omp_nest_lock_t *lock)
  634. \ingroup API_OpenMP_Runtime_Support
  635. This function initializes an opaque lock object supporting nested locking operations.
  636. \sa starpu_omp_destroy_nest_lock
  637. \sa starpu_omp_set_nest_lock
  638. \sa starpu_omp_unset_nest_lock
  639. \sa starpu_omp_test_nest_lock
  640. \fn void starpu_omp_destroy_nest_lock(starpu_omp_nest_lock_t *lock)
  641. \ingroup API_OpenMP_Runtime_Support
  642. This function destroys an opaque lock object supporting nested locking operations.
  643. \sa starpu_omp_init_nest_lock
  644. \sa starpu_omp_set_nest_lock
  645. \sa starpu_omp_unset_nest_lock
  646. \sa starpu_omp_test_nest_lock
  647. \fn void starpu_omp_set_nest_lock(starpu_omp_nest_lock_t *lock)
  648. \ingroup API_OpenMP_Runtime_Support
  649. This function locks an opaque lock object supporting nested locking operations.
  650. If the lock is already locked by another task, the function will block until
  651. it succeeds in exclusively acquiring the lock. If the lock is already taken by
  652. the current task, the function will increase the nested locking level of the
  653. lock object.
  654. \sa starpu_omp_init_nest_lock
  655. \sa starpu_omp_destroy_nest_lock
  656. \sa starpu_omp_unset_nest_lock
  657. \sa starpu_omp_test_nest_lock
  658. \fn void starpu_omp_unset_nest_lock(starpu_omp_nest_lock_t *lock)
  659. \ingroup API_OpenMP_Runtime_Support
  660. This function unlocks a previously locked lock object supporting nested locking
  661. operations. If the lock has been locked multiple times in nested fashion, the
  662. nested locking level is decreased and the lock remains locked. Otherwise, if
  663. the lock has only been locked once, it becomes unlocked. The behaviour of this
  664. function is unspecified if it is called on an unlocked lock object. The
  665. behaviour of this function is unspecified if it is called from a different task
  666. than the one that locked the lock object.
  667. \sa starpu_omp_init_nest_lock
  668. \sa starpu_omp_destroy_nest_lock
  669. \sa starpu_omp_set_nest_lock
  670. \sa starpu_omp_test_nest_lock
  671. \fn int starpu_omp_test_nest_lock(starpu_omp_nest_lock_t *lock)
  672. \ingroup API_OpenMP_Runtime_Support
  673. This function unblocking attempts to lock an opaque lock object supporting
  674. nested locking operations and returns whether it succeeded or not. If the lock
  675. is already locked by another task, the function will return without having
  676. acquired the lock. If the lock is already taken by the current task, the
  677. function will increase the nested locking level of the lock object.
  678. \return <c>!0</c> if the function succeeded in acquiring the lock.
  679. \return <c>0</c> if the lock was already locked.
  680. \sa starpu_omp_init_nest_lock
  681. \sa starpu_omp_destroy_nest_lock
  682. \sa starpu_omp_set_nest_lock
  683. \sa starpu_omp_unset_nest_lock
  684. \fn void starpu_omp_atomic_fallback_inline_begin(void)
  685. \ingroup API_OpenMP_Runtime_Support
  686. This function implements the entry point of a fallback global atomic region. It
  687. blocks until it succeeds in acquiring exclusive access to the global atomic
  688. region.
  689. \sa starpu_omp_atomic_fallback_inline_end
  690. \fn void starpu_omp_atomic_fallback_inline_end(void)
  691. \ingroup API_OpenMP_Runtime_Support
  692. This function implements the exit point of a fallback global atomic region. It
  693. release the exclusive access to the global atomic region.
  694. \sa starpu_omp_atomic_fallback_inline_begin
  695. \fn double starpu_omp_get_wtime(void)
  696. \ingroup API_OpenMP_Runtime_Support
  697. This function returns the elapsed wallclock time in seconds.
  698. \return the elapsed wallclock time in seconds.
  699. \sa starpu_omp_get_wtick
  700. \fn double starpu_omp_get_wtick(void)
  701. \ingroup API_OpenMP_Runtime_Support
  702. This function returns the precision of the time used by \p starpu_omp_get_wtime.
  703. \return the precision of the time used by \p starpu_omp_get_wtime.
  704. \sa starpu_omp_get_wtime
  705. \fn void starpu_omp_vector_annotate(starpu_data_handle_t handle, uint32_t slice_base)
  706. \ingroup API_OpenMP_Runtime_Support
  707. This function enables setting additional vector metadata needed by the OpenMP Runtime Support.
  708. \p handle is vector data handle.
  709. \p slice_base is the base of an array slice, expressed in number of vector elements from the array base.
  710. \sa STARPU_VECTOR_GET_SLICE_BASE
  711. */