OpenMP
By:By:
Neel BhadNeel Bhad
Geet BhadGeet Bhad
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
● 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?
● 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
Programming Model
• Shared Memory
• Parallelism by threading
• Fork-Join model
• Explicit Parallelism
• Nested Parallelism
• Dynamic Threads
• Input / Output
• Memory model
5
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)
UMA Vs. NUMA
• Unified Memory Access ( UMA )
7
UMA Vs. NUMA (Cont.)
• Non Unified Memory Access ( NUMA )
8
Fork – Join Model (Cont.)
9
F
J
Master
Thread
Thread
OpenMP Elements
• Compiler Directives
• Runtime Libraries
• Environmental Variables
10
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
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
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;
}
}
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
ThankYou

OpenMp

  • 1.
  • 2.
    What Is OpenMP..?WhatIs 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 isportable: 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 isparallel 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 • SharedMemory • 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)
  • 7.
    UMA Vs. NUMA •Unified Memory Access ( UMA ) 7
  • 8.
    UMA Vs. NUMA(Cont.) • Non Unified Memory Access ( NUMA ) 8
  • 9.
    Fork – JoinModel (Cont.) 9 F J Master Thread Thread
  • 10.
    OpenMP Elements • CompilerDirectives • Runtime Libraries • Environmental Variables 10
  • 11.
    The OpenMP ProgrammingModel • 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 ItWork? • 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 inOpenMP #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 PthreadsHPF OpenMP Performance  ?  Scalability    Incremental Parallelization   Portability     Support for Dusty Deck Codes  ?  High Level User API    Support Data Parallelism    Ease of Debugging     OpenMP Compared
  • 15.

Editor's Notes

  • #6 &amp;lt;number&amp;gt;
  • #7 &amp;lt;number&amp;gt;
  • #8 &amp;lt;number&amp;gt;
  • #9 &amp;lt;number&amp;gt;
  • #10 &amp;lt;number&amp;gt;
  • #11 &amp;lt;number&amp;gt;