openmp_runtime_support.doxy 37 KB

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