openmp_runtime_support.doxy 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. @name Initialisation
  8. \ingroup API_OpenMP_Runtime_Support
  9. \def STARPU_OPENMP
  10. \ingroup API_OpenMP_Runtime_Support
  11. This macro is defined when StarPU has been installed with OpenMP Runtime
  12. support. It should be used in your code to detect the availability of
  13. the runtime support for OpenMP.
  14. \fn int starpu_omp_init(void)
  15. \ingroup API_OpenMP_Runtime_Support
  16. Initializes StarPU and its OpenMP Runtime support.
  17. \fn int starpu_omp_shutdown(void)
  18. \ingroup API_OpenMP_Runtime_Support
  19. Shutdown StarPU and its OpenMP Runtime support.
  20. @name Parallel
  21. \anchor ORS_Parallel
  22. \ingroup API_OpenMP_Runtime_Support
  23. \fn void starpu_omp_parallel_region(const struct starpu_omp_parallel_region_attr *attr)
  24. \ingroup API_OpenMP_Runtime_Support
  25. Generates and launch an OpenMP parallel region and return after its
  26. completion. \p attr specifies the attributes for the generated parallel region.
  27. If this function is called from inside another, generating, parallel region, the
  28. generated parallel region is nested within the generating parallel region.
  29. This function can be used to implement <c>\#pragma omp parallel</c>.
  30. \fn void starpu_omp_master(void (*f)(void *arg), void *arg)
  31. \ingroup API_OpenMP_Runtime_Support
  32. Executes a function only on the master thread of the OpenMP
  33. parallel region it is called from. When called from a thread that is not the
  34. master of the parallel region it is called from, this function does nothing. \p
  35. f is the function to be called. \p arg is an argument passed to function \p f.
  36. This function can be used to implement <c>\#pragma omp master</c>.
  37. \fn int starpu_omp_master_inline(void)
  38. \ingroup API_OpenMP_Runtime_Support
  39. Determines whether the calling thread is the master of the OpenMP parallel region
  40. it is called from or not.
  41. This function can be used to implement <c>\#pragma omp master</c> without code
  42. outlining.
  43. \return <c>!0</c> if called by the region's master thread.
  44. \return <c>0</c> if not called by the region's master thread.
  45. @name Synchronization
  46. \anchor ORS_Synchronization
  47. \ingroup API_OpenMP_Runtime_Support
  48. \fn void starpu_omp_barrier(void)
  49. \ingroup API_OpenMP_Runtime_Support
  50. Waits until each participating thread of the innermost OpenMP parallel region
  51. has reached the barrier and each explicit OpenMP task bound to this region has
  52. completed its execution.
  53. This function can be used to implement <c>\#pragma omp barrier</c>.
  54. \fn void starpu_omp_critical(void (*f)(void *arg), void *arg, const char *name)
  55. \ingroup API_OpenMP_Runtime_Support
  56. Waits until no other thread is executing within the context of the selected
  57. critical section, then proceeds to the exclusive execution of a function within
  58. the critical section. \p f is the function to be executed in the critical
  59. section. \p arg is an argument passed to function \p f. \p name is the name of
  60. the selected critical section. If <c>name == NULL</c>, the selected critical
  61. section is the unique anonymous critical section.
  62. This function can be used to implement <c>\#pragma omp critical</c>.
  63. \fn void starpu_omp_critical_inline_begin(const char *name)
  64. \ingroup API_OpenMP_Runtime_Support
  65. Waits until execution can proceed exclusively within the context of the
  66. selected critical section. \p name is the name of the selected critical
  67. section. If <c>name == NULL</c>, the selected critical section is the unique
  68. anonymous critical section.
  69. This function together with #starpu_omp_critical_inline_end can be used to
  70. implement <c>\#pragma omp critical</c> without code outlining.
  71. \fn void starpu_omp_critical_inline_end(const char *name)
  72. \ingroup API_OpenMP_Runtime_Support
  73. Ends the exclusive execution within the context of the selected critical
  74. section. \p name is the name of the selected critical section. If
  75. <c>name==NULL</c>, the selected critical section is the unique anonymous
  76. critical section.
  77. This function together with #starpu_omp_critical_inline_begin can be used to
  78. implement <c>\#pragma omp critical</c> without code outlining.
  79. @name Worksharing
  80. \anchor ORS_Worksharing
  81. \ingroup API_OpenMP_Runtime_Support
  82. \fn void starpu_omp_single(void (*f)(void *arg), void *arg, int nowait)
  83. \ingroup API_OpenMP_Runtime_Support
  84. Ensures that a single participating thread of the innermost OpenMP parallel
  85. region executes a function. \p f is the function to be executed by a single
  86. thread. \p arg is an argument passed to function \p f. \p nowait is a flag
  87. indicating whether an implicit barrier is requested after the single section
  88. (<c>nowait==0</c>) or not (<c>nowait==!0</c>).
  89. This function can be used to implement <c>\#pragma omp single</c>.
  90. \fn int starpu_omp_single_inline(void)
  91. \ingroup API_OpenMP_Runtime_Support
  92. Decides whether the current thread is elected to run the following single
  93. section among the participating threads of the innermost OpenMP parallel
  94. region.
  95. This function can be used to implement <c>\#pragma omp single</c> without code
  96. outlining.
  97. \return <c>!0</c> if the calling thread has won the election.
  98. \return <c>0</c> if the calling thread has lost the election.
  99. \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)
  100. \ingroup API_OpenMP_Runtime_Support
  101. Executes a parallel loop together with the other threads participating to the
  102. innermost parallel region. \p f is the function to be executed iteratively. \p
  103. arg is an argument passed to function \p f. \p nb_iterations is the number of
  104. iterations to be performed by the parallel loop. \p chunk is the number of
  105. consecutive iterations that should be affected to the same thread when
  106. scheduling the loop workshares, it follows the semantics of the \c modifier
  107. argument in OpenMP <c>\#pragma omp for</c> specification. \p schedule is the
  108. scheduling mode according to the OpenMP specification. \p ordered is a flag
  109. indicating whether the loop region may contain an ordered section
  110. (<c>ordered==!0</c>) or not (<c>ordered==0</c>). \p nowait is a flag
  111. indicating whether an implicit barrier is requested after the for section
  112. (<c>nowait==0</c>) or not (<c>nowait==!0</c>).
  113. The function \p f will be called with arguments \p _first_i, the first iteration
  114. to perform, \p _nb_i, the number of consecutive iterations to perform before
  115. returning, \p arg, the free \p arg argument.
  116. This function can be used to implement <c>\#pragma omp for</c>.
  117. \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)
  118. \ingroup API_OpenMP_Runtime_Support
  119. Decides whether the current thread should start to execute a parallel loop
  120. section. See #starpu_omp_for for the argument description.
  121. This function together with #starpu_omp_for_inline_next can be used to
  122. implement <c>\#pragma omp for</c> without code outlining.
  123. \return <c>!0</c> if the calling thread participates to the loop region and
  124. should execute a first chunk of iterations. In that case, \p *_first_i will be
  125. set to the first iteration of the chunk to perform and \p *_nb_i will be set to
  126. the number of iterations of the chunk to perform.
  127. \return <c>0</c> if the calling thread does not participate to the loop region
  128. because all the available iterations have been affected to the other threads of
  129. the parallel region.
  130. \sa starpu_omp_for
  131. \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)
  132. \ingroup API_OpenMP_Runtime_Support
  133. Decides whether the current thread should continue to execute a parallel loop
  134. section. See #starpu_omp_for for the argument description.
  135. This function together with #starpu_omp_for_inline_first can be used to
  136. implement <c>\#pragma omp for</c> without code outlining.
  137. \return <c>!0</c> if the calling thread should execute a next chunk of
  138. iterations. In that case, \p *_first_i will be set to the first iteration of the
  139. chunk to perform and \p *_nb_i will be set to the number of iterations of the
  140. chunk to perform.
  141. \return <c>0</c> if the calling thread does not participate anymore to the loop
  142. region because all the available iterations have been affected to the other
  143. threads of the parallel region.
  144. \sa starpu_omp_for
  145. \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)
  146. \ingroup API_OpenMP_Runtime_Support
  147. Alternative implementation of a parallel loop. This function differs from
  148. #starpu_omp_for in the expected arguments of the loop function \c f.
  149. The function \p f will be called with arguments \p _begin_i, the first iteration
  150. to perform, \p _end_i, the first iteration not to perform before
  151. returning, \p arg, the free \p arg argument.
  152. This function can be used to implement <c>\#pragma omp for</c>.
  153. \sa starpu_omp_for
  154. \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)
  155. \ingroup API_OpenMP_Runtime_Support
  156. Inline version of the alternative implementation of a parallel loop.
  157. This function together with #starpu_omp_for_inline_next_alt can be used to
  158. implement <c>\#pragma omp for</c> without code outlining.
  159. \sa starpu_omp_for
  160. \sa starpu_omp_for_alt
  161. \sa starpu_omp_for_inline_first
  162. \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)
  163. \ingroup API_OpenMP_Runtime_Support
  164. Inline version of the alternative implementation of a parallel loop.
  165. This function together with #starpu_omp_for_inline_first_alt can be used to
  166. implement <c>\#pragma omp for</c> without code outlining.
  167. \sa starpu_omp_for
  168. \sa starpu_omp_for_alt
  169. \sa starpu_omp_for_inline_next
  170. \fn void starpu_omp_ordered(void (*f)(void *arg), void *arg)
  171. \ingroup API_OpenMP_Runtime_Support
  172. Ensures that a function is sequentially executed once for each iteration in
  173. order within a parallel loop, by the thread that own the iteration. \p f is the
  174. function to be executed by the thread that own the current iteration. \p arg is
  175. an argument passed to function \p f.
  176. This function can be used to implement <c>\#pragma omp ordered</c>.
  177. \fn void starpu_omp_ordered_inline_begin(void)
  178. \ingroup API_OpenMP_Runtime_Support
  179. Waits until all the iterations of a parallel loop below the iteration owned by
  180. the current thread have been executed.
  181. This function together with #starpu_omp_ordered_inline_end can be used to
  182. implement <c>\#pragma omp ordered</c> without code code outlining.
  183. \fn void starpu_omp_ordered_inline_end(void)
  184. \ingroup API_OpenMP_Runtime_Support
  185. Notifies that the ordered section for the current iteration has been completed.
  186. This function together with #starpu_omp_ordered_inline_begin can be used to
  187. implement <c>\#pragma omp ordered</c> without code code outlining.
  188. \fn void starpu_omp_sections(unsigned long long nb_sections, void (**section_f)(void *arg), void **section_arg, int nowait)
  189. \ingroup API_OpenMP_Runtime_Support
  190. Ensures that each function of a given array of functions is executed by one and
  191. only one thread. \p nb_sections is the number of functions in the array \p
  192. section_f. \p section_f is the array of functions to be executed as sections. \p
  193. section_arg is an array of arguments to be passed to the corresponding function.
  194. \p nowait is a flag indicating whether an implicit barrier is requested after
  195. the execution of all the sections (<c>nowait==0</c>) or not (<c>nowait==!0</c>).
  196. This function can be used to implement <c>\#pragma omp sections</c> and <c>\#pragma omp section</c>.
  197. \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)
  198. \ingroup API_OpenMP_Runtime_Support
  199. Alternative implementation of sections. This function differs from
  200. #starpu_omp_sections in that all the sections are combined within a single
  201. function in this version. \p section_f is the function implementing the combined
  202. sections.
  203. The function \p section_f will be called with arguments \p section_num, the
  204. section number to be executed, \p arg, the entry of \p section_arg corresponding
  205. to this section.
  206. This function can be used to implement <c>\#pragma omp sections</c> and <c>\#pragma omp section</c>.
  207. \sa starpu_omp_sections
  208. @name Task
  209. \anchor ORS_Task
  210. \ingroup API_OpenMP_Runtime_Support
  211. \fn void starpu_omp_task_region(const struct starpu_omp_task_region_attr *attr)
  212. \ingroup API_OpenMP_Runtime_Support
  213. Generates an explicit child task. The execution of the generated task is
  214. asynchronous with respect to the calling code unless specified otherwise.
  215. \p attr specifies the attributes for the generated task region.
  216. This function can be used to implement <c>\#pragma omp task</c>.
  217. \fn void starpu_omp_taskwait(void)
  218. \ingroup API_OpenMP_Runtime_Support
  219. Waits for the completion of the tasks generated by the current task. This
  220. function does not wait for the descendants of the tasks generated by the current
  221. task.
  222. This function can be used to implement <c>\#pragma omp taskwait</c>.
  223. \fn void starpu_omp_taskgroup(void (*f)(void *arg), void *arg)
  224. \ingroup API_OpenMP_Runtime_Support
  225. Launches a function and wait for the completion of every descendant task
  226. generated during the execution of the function.
  227. This function can be used to implement <c>\#pragma omp taskgroup</c>.
  228. @name API
  229. \anchor ORS_API
  230. \ingroup API_OpenMP_Runtime_Support
  231. \fn void starpu_omp_set_num_threads(int threads)
  232. \ingroup API_OpenMP_Runtime_Support
  233. This function .
  234. \fn int starpu_omp_get_num_threads()
  235. \ingroup API_OpenMP_Runtime_Support
  236. This function .
  237. \fn int starpu_omp_get_thread_num()
  238. \ingroup API_OpenMP_Runtime_Support
  239. This function .
  240. \fn int starpu_omp_get_max_threads()
  241. \ingroup API_OpenMP_Runtime_Support
  242. This function .
  243. \fn int starpu_omp_get_num_procs (void)
  244. \ingroup API_OpenMP_Runtime_Support
  245. This function .
  246. \fn int starpu_omp_in_parallel (void)
  247. \ingroup API_OpenMP_Runtime_Support
  248. This function .
  249. \fn void starpu_omp_set_dynamic (int dynamic_threads)
  250. \ingroup API_OpenMP_Runtime_Support
  251. This function .
  252. \fn int starpu_omp_get_dynamic (void)
  253. \ingroup API_OpenMP_Runtime_Support
  254. This function .
  255. \fn void starpu_omp_set_nested (int nested)
  256. \ingroup API_OpenMP_Runtime_Support
  257. This function .
  258. \fn int starpu_omp_get_nested (void)
  259. \ingroup API_OpenMP_Runtime_Support
  260. This function .
  261. \fn int starpu_omp_get_cancellation(void)
  262. \ingroup API_OpenMP_Runtime_Support
  263. This function .
  264. \fn void starpu_omp_set_schedule (enum starpu_omp_sched_value kind, int modifier)
  265. \ingroup API_OpenMP_Runtime_Support
  266. This function .
  267. \fn void starpu_omp_get_schedule (enum starpu_omp_sched_value *kind, int *modifier)
  268. \ingroup API_OpenMP_Runtime_Support
  269. This function .
  270. \fn int starpu_omp_get_thread_limit (void)
  271. \ingroup API_OpenMP_Runtime_Support
  272. This function .
  273. \fn void starpu_omp_set_max_active_levels (int max_levels)
  274. \ingroup API_OpenMP_Runtime_Support
  275. This function .
  276. \fn int starpu_omp_get_max_active_levels (void)
  277. \ingroup API_OpenMP_Runtime_Support
  278. This function .
  279. \fn int starpu_omp_get_level (void)
  280. \ingroup API_OpenMP_Runtime_Support
  281. This function .
  282. \fn int starpu_omp_get_ancestor_thread_num (int level)
  283. \ingroup API_OpenMP_Runtime_Support
  284. This function .
  285. \fn int starpu_omp_get_team_size (int level)
  286. \ingroup API_OpenMP_Runtime_Support
  287. This function .
  288. \fn int starpu_omp_get_active_level (void)
  289. \ingroup API_OpenMP_Runtime_Support
  290. This function .
  291. \fn int starpu_omp_in_final(void)
  292. \ingroup API_OpenMP_Runtime_Support
  293. This function .
  294. \fn enum starpu_omp_proc_bind_value starpu_omp_get_proc_bind(void)
  295. \ingroup API_OpenMP_Runtime_Support
  296. This function .
  297. \fn void starpu_omp_set_default_device(int device_num)
  298. \ingroup API_OpenMP_Runtime_Support
  299. This function .
  300. \fn int starpu_omp_get_default_device(void)
  301. \ingroup API_OpenMP_Runtime_Support
  302. This function .
  303. \fn int starpu_omp_get_num_devices(void)
  304. \ingroup API_OpenMP_Runtime_Support
  305. This function .
  306. \fn int starpu_omp_get_num_teams(void)
  307. \ingroup API_OpenMP_Runtime_Support
  308. This function .
  309. \fn int starpu_omp_get_team_num(void)
  310. \ingroup API_OpenMP_Runtime_Support
  311. This function .
  312. \fn int starpu_omp_is_initial_device(void)
  313. \ingroup API_OpenMP_Runtime_Support
  314. This function .
  315. \fn void starpu_omp_init_lock (starpu_omp_lock_t *lock)
  316. \ingroup API_OpenMP_Runtime_Support
  317. This function .
  318. \fn void starpu_omp_destroy_lock (starpu_omp_lock_t *lock)
  319. \ingroup API_OpenMP_Runtime_Support
  320. This function .
  321. \fn void starpu_omp_set_lock (starpu_omp_lock_t *lock)
  322. \ingroup API_OpenMP_Runtime_Support
  323. This function .
  324. \fn void starpu_omp_unset_lock (starpu_omp_lock_t *lock)
  325. \ingroup API_OpenMP_Runtime_Support
  326. This function .
  327. \fn int starpu_omp_test_lock (starpu_omp_lock_t *lock)
  328. \ingroup API_OpenMP_Runtime_Support
  329. This function .
  330. \fn void starpu_omp_init_nest_lock (starpu_omp_nest_lock_t *lock)
  331. \ingroup API_OpenMP_Runtime_Support
  332. This function .
  333. \fn void starpu_omp_destroy_nest_lock (starpu_omp_nest_lock_t *lock)
  334. \ingroup API_OpenMP_Runtime_Support
  335. This function .
  336. \fn void starpu_omp_set_nest_lock (starpu_omp_nest_lock_t *lock)
  337. \ingroup API_OpenMP_Runtime_Support
  338. This function .
  339. \fn void starpu_omp_unset_nest_lock (starpu_omp_nest_lock_t *lock)
  340. \ingroup API_OpenMP_Runtime_Support
  341. This function .
  342. \fn int starpu_omp_test_nest_lock (starpu_omp_nest_lock_t *lock)
  343. \ingroup API_OpenMP_Runtime_Support
  344. This function .
  345. \fn double starpu_omp_get_wtime (void)
  346. \ingroup API_OpenMP_Runtime_Support
  347. This function .
  348. \fn double starpu_omp_get_wtick (void)
  349. \ingroup API_OpenMP_Runtime_Support
  350. This function .
  351. */