2. What Is OpenMP..?What Is OpenMP..?
● In simple word runs a user program in parallel.
● It utilize to main concepts for parallelism
Multithreading
Shared Memory
● It takes user application, tear it down into group of threads and
runs them on a shared memory foundation
3. ● OpenMP is portable: supported by HP, IBM, Intel, SGI,
SUN, and others
● It is the de facto standard for writing shared memory programs.
To become an ANSI standard?
● OpenMP can be implemented incrementally, one function
or even one loop at a time.
● A nice way to get a parallel program from a sequential program.
Why
OpenMP?
4. ● What is parallel processing ?
It is ability of processing more than one job
simultaneously.
● Why going parallel ?
Great deal of data to be processed
Time needed to calculate an engineering equation
Need jobs to be done faster
5. Programming Model
• Shared Memory
• Parallelism by threading
• Fork-Join model
• Explicit Parallelism
• Nested Parallelism
• Dynamic Threads
• Input / Output
• Memory model
5
6. Shared Memory (Cont.)
• Following system can be used for shared memory
access
• a single core chip (older PC’s, sequential execution)
• a multicore chip (such as your laptop?)
• multiple single core chips in a NUMA system
• multiple multicore chips in a NUMA system (VT SGI
system)
11. The OpenMP Programming Model
• Based on compiler directives
• Nested Parallelism Support
API allows parallel constructs inside other parallel constructs
• DynamicThreads
API allows to dynamically change the number of threads which
may used toexecute different parallel regions
• Input/Output
OpenMP specifies nothing about parallel I/O
The programmer has to insure that I/O is conducted correctly
within the context of a multi-threaded program
• Memory consistency
Threads can "cache" their data and are not required to maintain exact
consistency with real memory all of the time
When it is critical that all threads view a shared variable
identically, the programmer is responsible for insuring that the variable is
FLUSHed by all threads as needed
12. How Does It Work?
• OpenMP is an implementation of multithreading
• A master thread "forks" a specified number of slave threads
Tasks are divided among slaves
• Slaves run concurrently as the runtime environment allocating threads to different
processors
13. Hello World in OpenMP
#include <omp.h>
#include <iostream>
using namespace std;
int main()
{
#pragma omp parallel num_threads(3)
{
cout << "Hello Worldn”;
// what if
// cout << "Hello World" << endl;
}
}
14. X3H5 MPI Pthreads HPF OpenMP
Performance ?
Scalability
Incremental Parallelization
Portability
Support for Dusty Deck Codes ?
High Level User API
Support Data Parallelism
Ease of Debugging
OpenMP Compared