PDC Lecture 15 OpenMP
PDC Lecture 15 OpenMP
Lecture – 15
INSTRUCTOR: MUHAMMAD ARSALAN RAZA
2
Memory Models
OpenMP
OpenMP Essentials
Goals of OpenMP
Programming
OpenMP is an Application Program Interface (API), jointly defined by a group of major computer hardware
and software vendors.
OpenMP provides a portable, scalable model for developers of shared memory parallel applications.
OpenMP Essentials
The API supports C/C++ and Fortran on a wide variety of architectures.
This lecture covers most of the major features of OpenMP 3.1, including its various constructs and
directives for specifying parallel regions, work sharing, synchronization, and data environment.
Runtime library functions and environment variables are also covered.
An Application Program Interface (API) that may be used to explicitly direct multi-threaded, shared
memory parallelism.
Environment Variables
Required to check for data dependencies, data conflicts, race conditions, deadlocks, or code sequences
Designed to handle parallel I/O. The programmer is responsible for synchronizing input and output.
Standardization:
Provide a standard among a variety of shared memory architectures/platforms
Jointly defined and endorsed by a group of major computer hardware and software vendors
Lean and Mean:
Establish a simple and limited set of directives for programming shared memory machines.
Significant parallelism can be implemented by using just 3 or 4 directives.
This goal is becoming less meaningful with each new release, apparently.
Ease of Use:
Provide capability to incrementally parallelize a serial program, unlike message-passing libraries which typically require an all or nothing
approach
Provide the capability to implement both coarse-grain and fine-grain parallelism
Portability:
The API is specified for C/C++ and Fortran
Public forum for API and membership
Most major platforms have been implemented including Unix/Linux platforms and Windows
www.openmp.org
12
OpenMP: Description-based SM
Parallelization
OpenMP is a standard shared memory programming interface (1997)
Directives for Fortran 77 and C/C++
Fork-join model resulting in a global program
It includes:
Parallel loops
Parallel sections
Parallel regions
Shared and private data
Synchronization primitives
barrier
critical region
Lahore Garrison University
13
OpenMP
Example
Enabled: specifies the maximum number of threads that can be used for any parallel region by the dynamic
thread's mechanism.
Disabled: specifies exact number of threads to use until next call to this routine.
OpenMP
OpenMP Essentials
Goals of OpenMP
MPI using C#
To cover this topic, different reference material has been used for consultation.
Textbook:
Distributed Systems: Principles and Paradigms, A. S. Tanenbaum and M. V. Steen, Prentice Hall, 2 nd Edition, 2007.
Distributed and Cloud Computing: Clusters, Grids, Clouds, and the Future Internet, K. Hwang, J. Dongarra and GC. C.
Fox, Elsevier, 1st Ed.
*https://docs.microsoft.com/en-us/cpp/parallel/openmp/reference/openmp-directives?view=msvc-170
**https://www.cita.utoronto.ca/~merz/intel_f10b/main_for/mergedProjects/optaps_for/common/optaps_par_libr.htm
Lahore Garrison University