|
OpenMP Program Development Tool
Intel C++ Compiler for Linux, installed in /opt/intel_cc_80
on access0 to access13.
The Intel C++ Compiler Usage
Invoking the Compiler from the Command Line
-
set the environment
-
invoke the compiler using icc or icpc. The icpc invocation
assumes any preprocessed source files are C++ while the icc
command assumes they are C.
Set the Environment Variables
[user@access0]$ source /opt/intel_cc_80/bin/ccvars.sh
or
[user@access0]$ source /opt/intel_cc_80/bin/ccvars.csh
If you want the script to run automatically when you login,
add the same command to the end of your startup file.
Sample .bash_profile entry for iccvars.sh:
#set environment vars for Intel C++ compiler
source /opt/intel_cc_80/bin/iccvars.sh
Invoking the Compiler with icc or icpc
Each invocation includes the C++ run-time libraries and
header files. Use the -no_cpprt option if you do not want
the C++ run-time libraries and headers.
Parallel Processing with OpenMP
To compile with OpenMP, you need to prepare your program
by annotating the code with OpenMP directives. The Intel
C++ Compiler first processes the application and
produces a multithreaded version of the code which is
then compiled. The output is a executable program with
the parallelism implemented by threads that execute
parallel regions or constructs.
Compiling with OpenMP
/home/rstaff/wangxb/test.c is an example program. First,
copy the program into your home directory. Then, follow
the steps below.
[user@access0]$ icc
-openmp -c test.c
[user@access0]$ icc -openmp -o test test.o
-openmp Option
The -openmp option enables the parallelizer to generate
multithreaded code based on the OpenMP directives. -openmp
option works with both -O0 (no optimization) and any
optimization level of -O1, -O2 (default) and -O3.
Specifying -O0 with -openmp helps to debug OpenMP
applications.
OpenMP Directive Format and Syntax
An OpenMP directive has the form:
#pragma omp directive-name [clause, ...] newline
where:
-
#pragma omp -- Required for all OpenMP directives.
-
directive-name -- A valid OpenMP directive. Must appear
after the pragma and before any clauses.
-
clause -- Optional. Clauses can be in any order, and
repeated as necessary unless otherwise restricted.
-
newline -- Required. Proceeds the structured block which
is enclosed by this directive.
OpenMP Diagnostics
The -openmp_report{0|1|2} option controls the OpenMP
parallelizer's diagnostic levels 0, 1, or 2 as follows:
-
-openmp_report0 = no diagnostic information is
displayed.
-
-openmp_report1 = display diagnostics indicating loops,
regions, and sections successfully parallelized.
-
-openmp_report2 = same as -openmp_report1 plus
diagnostics indicating MASTER constructs, SINGLE
constructs, CRITICAL constructs, ORDERED constructs,
ATOMIC directives, etc. are successfully handled.
The default is -openmp_report1
More Information
The official OpenMP website is www.OpenMP.org.
|