OpenMP: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
<languages />
<translate>
== Description ==
== Description ==
[http://openmp.org/wp/ OpenMP] (Open Multi-Processing) is an application programming interface (API) for shared memory parallel computing. It is supported on numerous platforms, including Linux and Windows, and is available for the C/C++ and Fortran programming languages. The API consists of a set of directives, a software library, and environment variables.
[http://openmp.org/wp/ OpenMP] (Open Multi-Processing) is an application programming interface (API) for shared memory parallel computing. It is supported on numerous platforms, including Linux and Windows, and is available for the C/C++ and Fortran programming languages. The API consists of a set of directives, a software library, and environment variables.
Line 18: Line 20:


OpenMP directives are inserted in Fortran programs using sentinels. A sentinel is a keyword placed immediately after a symbol that marks a comment. For example:
OpenMP directives are inserted in Fortran programs using sentinels. A sentinel is a keyword placed immediately after a symbol that marks a comment. For example:
</translate>
<pre>
<pre>
!$OMP directive  
!$OMP directive  
Line 24: Line 27:
*$OMP directive
*$OMP directive
</pre>
</pre>
 
<translate>
In C, directives are inserted using a pragma construct, as follows:
In C, directives are inserted using a pragma construct, as follows:
</translate>
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
#pragma omp directive
#pragma omp directive
</syntaxhighlight>
</syntaxhighlight>


 
<translate>
===OpenMP directives===
===OpenMP directives===
</translate>
{| class="wikitable" style="font-size: 88%; text-align: left;"
{| class="wikitable" style="font-size: 88%; text-align: left;"
! scope="col" width="260px" | Fortran
! scope="col" width="260px" | Fortran
Line 147: Line 152:
|nowait
|nowait
|}
|}
 
<translate>
== Environment ==
== Environment ==
There are four main environment variables that influence the execution of an OpenMP program:
There are four main environment variables that influence the execution of an OpenMP program:
</translate>
<pre>
<pre>
OMP_SCHEDULE
OMP_SCHEDULE
Line 156: Line 162:
OMP_NESTED
OMP_NESTED
</pre>
</pre>
<translate>
They can be set and modified using the UNIX command  
They can be set and modified using the UNIX command  
{{command|export OMP_NUM_THREADS{{=}}12}}
{{command|export OMP_NUM_THREADS{{=}}12}}
Line 173: Line 180:
== Example ==
== Example ==
Here is a ''hello world'' example that shows the use of openMP.
Here is a ''hello world'' example that shows the use of openMP.
 
</translate>
{| border="0" cellpadding="5" cellspacing="0" align="center"
{| border="0" cellpadding="5" cellspacing="0" align="center"
! style="background:#8AA8E5;" | '''C CODE''': <tt>ompHello.c</tt>
! style="background:#8AA8E5;" | '''C CODE''': <tt>ompHello.c</tt>
Line 204: Line 211:
</source>
</source>
|}
|}
<translate>
Compiling and running the C code goes as follows:
Compiling and running the C code goes as follows:
  litai10:~$ gcc -O3 -fopenmp ompHello.c -o ompHello  
  litai10:~$ gcc -O3 -fopenmp ompHello.c -o ompHello  
Line 227: Line 235:
[http://www.openmp.org/ OpenMP.org] publishes the formal [http://www.openmp.org/specifications/ specifications],
[http://www.openmp.org/ OpenMP.org] publishes the formal [http://www.openmp.org/specifications/ specifications],
handy reference cards for the [http://www.openmp.org/wp-content/uploads/OpenMP-4.0-C.pdf C/C++] and [http://www.openmp.org/wp-content/uploads/OpenMP-4.0-Fortran.pdf Fortran] interfaces, and [http://www.openmp.org/wp-content/uploads/openmp-examples-4.0.2.pdf examples].
handy reference cards for the [http://www.openmp.org/wp-content/uploads/OpenMP-4.0-C.pdf C/C++] and [http://www.openmp.org/wp-content/uploads/OpenMP-4.0-Fortran.pdf Fortran] interfaces, and [http://www.openmp.org/wp-content/uploads/openmp-examples-4.0.2.pdf examples].
</translate>
Bureaucrats, cc_docs_admin, cc_staff
2,306

edits

Navigation menu