Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

283 lines
11KB

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