⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 29.html

📁 国外MPI教材
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />	<style type="text/css">	body { font-family: Verdana, Arial, Helvetica, sans-serif;}	a.at-term {	font-style: italic; }	</style>	<title>Parallel for/DO</title>	<meta name="Generator" content="ATutor">	<meta name="Keywords" content=""></head><body> <p>The parallel for/DO construct splits the iterations of the immediately following loop among the threads in the team. </p>

<p>Example: </p>
<pre><code>#pragma omp parallel shared(a,b) private(j)
{
   #pragma omp for
     for (j = 0; j < N; j++)
        a[j] = a[j] + b[j];
}</code></pre>


<p>By default, there is a barrier at the end of the loop: the threads wait until all are finished and then proceed. You can use the <em>nowait</em> clause to allow 
threads to continue without waiting. This is recommended if it is known that subsequent work does not depend on all loop iterations having been completed. </p>

<p>Detailed  syntax for the parallel for/DO is as follows: </p>

<p class="codelang">C/C++</p>

<pre><code>#pragma omp for [clause [clause]...]
     for loop</code></pre>

<p>where <em>clause</em> is one of </p>

<ul>
  <li><code>private(<em>list</em>)</code> </li>
  <li><code>firstprivate(<em>list</em>)</code> </li>
  <li><code>lastprivate(<em>list</em>)</code> </li>
  <li><code>reduction(<em>operator:list</em>)</code> </li>
  <li><code>ordered</code> </li>
  <li><code>schedule(<em>kind [, chunk_size]</em>)</code> </li>
  <li><code>nowait</code> </li>
</ul>
<p class="codelang">Detailed Syntax (Fortran):</p>

<pre><code>c$omp do [clause [clause]...]
     do loop
[c$omp end do [nowait]]</code></pre>
    
<p>where <b>clause</b> is one of </p>
<ul>
  <li><code>private(<em>list</em>)</code> </li>
  <li><code>firstprivate(<em>list</em>)</code> </li>
  <li><code>lastprivate(<em>list</em>)</code> </li>
  <li><code>reduction(<em>operator:list</em>)</code> </li>
  <li><code>ordered</code> </li>
  <li><code>schedule(<em>kind [, chunk_size]</em>)</code> </li>
</ul>

<p>For Fortran 90, use !$OMP and F90-style line continuation. </p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -