OpenMP.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: OpenMP</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: OpenMP">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: OpenMP">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Statements.html#Statements" rel="up" title="Statements">
  30. <link href="OpenACC.html#OpenACC" rel="next" title="OpenACC">
  31. <link href="Cleanups.html#Cleanups" rel="prev" title="Cleanups">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="OpenMP"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="OpenACC.html#OpenACC" accesskey="n" rel="next">OpenACC</a>, Previous: <a href="Cleanups.html#Cleanups" accesskey="p" rel="prev">Cleanups</a>, Up: <a href="Statements.html#Statements" accesskey="u" rel="up">Statements</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="OpenMP-1"></a>
  69. <h4 class="subsection">10.7.7 OpenMP</h4>
  70. <a name="index-OMP_005fPARALLEL"></a>
  71. <a name="index-OMP_005fFOR"></a>
  72. <a name="index-OMP_005fSECTIONS"></a>
  73. <a name="index-OMP_005fSINGLE"></a>
  74. <a name="index-OMP_005fSECTION"></a>
  75. <a name="index-OMP_005fMASTER"></a>
  76. <a name="index-OMP_005fORDERED"></a>
  77. <a name="index-OMP_005fCRITICAL"></a>
  78. <a name="index-OMP_005fRETURN"></a>
  79. <a name="index-OMP_005fCONTINUE"></a>
  80. <a name="index-OMP_005fATOMIC"></a>
  81. <a name="index-OMP_005fCLAUSE"></a>
  82. <p>All the statements starting with <code>OMP_</code> represent directives and
  83. clauses used by the OpenMP API <a href="http://www.openmp.org/">http://www.openmp.org/</a><!-- /@w -->.
  84. </p>
  85. <dl compact="compact">
  86. <dt><code>OMP_PARALLEL</code></dt>
  87. <dd>
  88. <p>Represents <code>#pragma omp parallel [clause1 &hellip; clauseN]</code>. It
  89. has four operands:
  90. </p>
  91. <p>Operand <code>OMP_PARALLEL_BODY</code> is valid while in GENERIC and
  92. High GIMPLE forms. It contains the body of code to be executed
  93. by all the threads. During GIMPLE lowering, this operand becomes
  94. <code>NULL</code> and the body is emitted linearly after
  95. <code>OMP_PARALLEL</code>.
  96. </p>
  97. <p>Operand <code>OMP_PARALLEL_CLAUSES</code> is the list of clauses
  98. associated with the directive.
  99. </p>
  100. <p>Operand <code>OMP_PARALLEL_FN</code> is created by
  101. <code>pass_lower_omp</code>, it contains the <code>FUNCTION_DECL</code>
  102. for the function that will contain the body of the parallel
  103. region.
  104. </p>
  105. <p>Operand <code>OMP_PARALLEL_DATA_ARG</code> is also created by
  106. <code>pass_lower_omp</code>. If there are shared variables to be
  107. communicated to the children threads, this operand will contain
  108. the <code>VAR_DECL</code> that contains all the shared values and
  109. variables.
  110. </p>
  111. </dd>
  112. <dt><code>OMP_FOR</code></dt>
  113. <dd>
  114. <p>Represents <code>#pragma omp for [clause1 &hellip; clauseN]</code>. It has
  115. six operands:
  116. </p>
  117. <p>Operand <code>OMP_FOR_BODY</code> contains the loop body.
  118. </p>
  119. <p>Operand <code>OMP_FOR_CLAUSES</code> is the list of clauses
  120. associated with the directive.
  121. </p>
  122. <p>Operand <code>OMP_FOR_INIT</code> is the loop initialization code of
  123. the form <code>VAR = N1</code>.
  124. </p>
  125. <p>Operand <code>OMP_FOR_COND</code> is the loop conditional expression
  126. of the form <code>VAR {&lt;,&gt;,&lt;=,&gt;=} N2</code>.
  127. </p>
  128. <p>Operand <code>OMP_FOR_INCR</code> is the loop index increment of the
  129. form <code>VAR {+=,-=} INCR</code>.
  130. </p>
  131. <p>Operand <code>OMP_FOR_PRE_BODY</code> contains side-effect code from
  132. operands <code>OMP_FOR_INIT</code>, <code>OMP_FOR_COND</code> and
  133. <code>OMP_FOR_INC</code>. These side-effects are part of the
  134. <code>OMP_FOR</code> block but must be evaluated before the start of
  135. loop body.
  136. </p>
  137. <p>The loop index variable <code>VAR</code> must be a signed integer variable,
  138. which is implicitly private to each thread. Bounds
  139. <code>N1</code> and <code>N2</code> and the increment expression
  140. <code>INCR</code> are required to be loop invariant integer
  141. expressions that are evaluated without any synchronization. The
  142. evaluation order, frequency of evaluation and side-effects are
  143. unspecified by the standard.
  144. </p>
  145. </dd>
  146. <dt><code>OMP_SECTIONS</code></dt>
  147. <dd>
  148. <p>Represents <code>#pragma omp sections [clause1 &hellip; clauseN]</code>.
  149. </p>
  150. <p>Operand <code>OMP_SECTIONS_BODY</code> contains the sections body,
  151. which in turn contains a set of <code>OMP_SECTION</code> nodes for
  152. each of the concurrent sections delimited by <code>#pragma omp
  153. section</code>.
  154. </p>
  155. <p>Operand <code>OMP_SECTIONS_CLAUSES</code> is the list of clauses
  156. associated with the directive.
  157. </p>
  158. </dd>
  159. <dt><code>OMP_SECTION</code></dt>
  160. <dd>
  161. <p>Section delimiter for <code>OMP_SECTIONS</code>.
  162. </p>
  163. </dd>
  164. <dt><code>OMP_SINGLE</code></dt>
  165. <dd>
  166. <p>Represents <code>#pragma omp single</code>.
  167. </p>
  168. <p>Operand <code>OMP_SINGLE_BODY</code> contains the body of code to be
  169. executed by a single thread.
  170. </p>
  171. <p>Operand <code>OMP_SINGLE_CLAUSES</code> is the list of clauses
  172. associated with the directive.
  173. </p>
  174. </dd>
  175. <dt><code>OMP_MASTER</code></dt>
  176. <dd>
  177. <p>Represents <code>#pragma omp master</code>.
  178. </p>
  179. <p>Operand <code>OMP_MASTER_BODY</code> contains the body of code to be
  180. executed by the master thread.
  181. </p>
  182. </dd>
  183. <dt><code>OMP_ORDERED</code></dt>
  184. <dd>
  185. <p>Represents <code>#pragma omp ordered</code>.
  186. </p>
  187. <p>Operand <code>OMP_ORDERED_BODY</code> contains the body of code to be
  188. executed in the sequential order dictated by the loop index
  189. variable.
  190. </p>
  191. </dd>
  192. <dt><code>OMP_CRITICAL</code></dt>
  193. <dd>
  194. <p>Represents <code>#pragma omp critical [name]</code>.
  195. </p>
  196. <p>Operand <code>OMP_CRITICAL_BODY</code> is the critical section.
  197. </p>
  198. <p>Operand <code>OMP_CRITICAL_NAME</code> is an optional identifier to
  199. label the critical section.
  200. </p>
  201. </dd>
  202. <dt><code>OMP_RETURN</code></dt>
  203. <dd>
  204. <p>This does not represent any OpenMP directive, it is an artificial
  205. marker to indicate the end of the body of an OpenMP. It is used
  206. by the flow graph (<code>tree-cfg.c</code>) and OpenMP region
  207. building code (<code>omp-low.c</code>).
  208. </p>
  209. </dd>
  210. <dt><code>OMP_CONTINUE</code></dt>
  211. <dd>
  212. <p>Similarly, this instruction does not represent an OpenMP
  213. directive, it is used by <code>OMP_FOR</code> (and similar codes) as well as
  214. <code>OMP_SECTIONS</code> to mark the place where the code needs to
  215. loop to the next iteration, or the next section, respectively.
  216. </p>
  217. <p>In some cases, <code>OMP_CONTINUE</code> is placed right before
  218. <code>OMP_RETURN</code>. But if there are cleanups that need to
  219. occur right after the looping body, it will be emitted between
  220. <code>OMP_CONTINUE</code> and <code>OMP_RETURN</code>.
  221. </p>
  222. </dd>
  223. <dt><code>OMP_ATOMIC</code></dt>
  224. <dd>
  225. <p>Represents <code>#pragma omp atomic</code>.
  226. </p>
  227. <p>Operand 0 is the address at which the atomic operation is to be
  228. performed.
  229. </p>
  230. <p>Operand 1 is the expression to evaluate. The gimplifier tries
  231. three alternative code generation strategies. Whenever possible,
  232. an atomic update built-in is used. If that fails, a
  233. compare-and-swap loop is attempted. If that also fails, a
  234. regular critical section around the expression is used.
  235. </p>
  236. </dd>
  237. <dt><code>OMP_CLAUSE</code></dt>
  238. <dd>
  239. <p>Represents clauses associated with one of the <code>OMP_</code> directives.
  240. Clauses are represented by separate subcodes defined in
  241. <samp>tree.h</samp>. Clauses codes can be one of:
  242. <code>OMP_CLAUSE_PRIVATE</code>, <code>OMP_CLAUSE_SHARED</code>,
  243. <code>OMP_CLAUSE_FIRSTPRIVATE</code>,
  244. <code>OMP_CLAUSE_LASTPRIVATE</code>, <code>OMP_CLAUSE_COPYIN</code>,
  245. <code>OMP_CLAUSE_COPYPRIVATE</code>, <code>OMP_CLAUSE_IF</code>,
  246. <code>OMP_CLAUSE_NUM_THREADS</code>, <code>OMP_CLAUSE_SCHEDULE</code>,
  247. <code>OMP_CLAUSE_NOWAIT</code>, <code>OMP_CLAUSE_ORDERED</code>,
  248. <code>OMP_CLAUSE_DEFAULT</code>, <code>OMP_CLAUSE_REDUCTION</code>,
  249. <code>OMP_CLAUSE_COLLAPSE</code>, <code>OMP_CLAUSE_UNTIED</code>,
  250. <code>OMP_CLAUSE_FINAL</code>, and <code>OMP_CLAUSE_MERGEABLE</code>. Each code
  251. represents the corresponding OpenMP clause.
  252. </p>
  253. <p>Clauses associated with the same directive are chained together
  254. via <code>OMP_CLAUSE_CHAIN</code>. Those clauses that accept a list
  255. of variables are restricted to exactly one, accessed with
  256. <code>OMP_CLAUSE_VAR</code>. Therefore, multiple variables under the
  257. same clause <code>C</code> need to be represented as multiple <code>C</code> clauses
  258. chained together. This facilitates adding new clauses during
  259. compilation.
  260. </p>
  261. </dd>
  262. </dl>
  263. <hr>
  264. <div class="header">
  265. <p>
  266. Next: <a href="OpenACC.html#OpenACC" accesskey="n" rel="next">OpenACC</a>, Previous: <a href="Cleanups.html#Cleanups" accesskey="p" rel="prev">Cleanups</a>, Up: <a href="Statements.html#Statements" accesskey="u" rel="up">Statements</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  267. </div>
  268. </body>
  269. </html>