Math 6395 -- Introduction to Parallel Scientific ComputingOpenMP Application Program Interface |
|
[adapted from the OpenMP Specifications (linked below)] The OpenMP API specifies a collection of compiler directives, library routines, and environment variables that can be used to specify shared-memory parallelism in C, C++ and Fortran programs. This specification provides a model for parallel programming that is portable across shared memory architectures from different vendors. Compilers from numerous vendors support the OpenMP API. The directives, library routines, and environment variables defined in the OpenMP API allow users to create and manage parallel programs while permitting portability. The directives extend the C, C++ and Fortran base languages with single program multiple data (SPMD) constructs, tasking constructs, worksharing constructs, and synchronization constructs, and they provide support for sharing and privatizing data. The functionality to control the runtime environment is provided by library routines and environment variables. Compilers that support the OpenMP API often include a command line option to the compiler that activates and allows interpretation of all OpenMP directives. The OpenMP API uses the fork-join model of parallel execution. Multiple threads of execution perform tasks defined implicitly or explicitly by OpenMP directives. OpenMP is intended to support programs that will execute correctly both as parallel programs (multiple threads of execution and a full OpenMP support library) and as sequential programs (directives ignored and a simple OpenMP stubs library). However, it is possible and permitted to develop a program that executes correctly as a parallel program but not as a sequential program, or that produces different results when executed as a parallel program compared to when it is executed as a sequential program. Furthermore, using different numbers of threads may result in different numeric results because of changes in the association of numeric operations. For example, a serial addition reduction may have a different pattern of addition associations than a parallel reduction. These different associations may change the results of floating-point addition. OpenMP provides a relaxed-consistency, shared-memory model of parallelism. All OpenMP threads have access to a place to store and to retrieve variables, called the memory. In addition, each thread is allowed to have its own temporary view of the memory. The temporary view of memory for each thread is not a required part of the OpenMP memory model, but can represent any kind of intervening structure, such as machine registers, cache, or other local storage, between the thread and the memory. The temporary view of memory allows the thread to cache variables and thereby to avoid going to memory for every reference to a variable. Each thread also has access to another type of memory that must not be accessed by other threads, called threadprivate memory. |
|
As mentioned in the syllabus, I recommend the book Using OpenMP, Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas, MIT Press, 2007. For those students who prefer electronic reference materials (or do not wish to spend money on books), I provide the following links. OpenMP Links: |
Using OpenMP on our Computing Systems for Class:Blackbeard:To use OpenMP in Fortran on blackbeard, you must use either the ifort or gfortran compiler. For the ifort compiler, use the flags ifort -openmp -i-static file1.f90 ...For the gfortran compiler, use the flags gfortran -fopenmp file1.f90 ...when compiling. Ranger:To use OpenMP in Fortran on Ranger, unless you change your modules, you must use the pgf95 compiler, which requires the flags pgf95 -mp file1.f90 ...when compiling. |