openmp-tutorial
82 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
82 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

IWOMP 20051An Introduction In to OpenMPRuud van der PasSenior Staff EngineerScalable Systems GroupSun MicrosystemsIWOMP 2005University of OregonEugene, Oregon, USAJune 1-4, 2005An Introduction Into OpenMP Copyright©2005 Sun MicrosystemsRvdP/V1.1IWOMP 2005Outline2❑The OpenMP Programming Model❑OpenMP Guided Tour❑OpenMP Overview● C lauses● Worksharing constructs● Synchronization constructs● Environment variables● Global Data● Runtime functions❑Wrap-upAn Introduction Into OpenMP Copyright©2005 Sun MicrosystemsRvdP/V1.1IWOMP 20053The OpenMP Programming ModelAn Introduction Into OpenMP Copyright©2005 Sun MicrosystemsRvdP/V1.1IWOMP 20054Memory0 1 PAn Introduction Into OpenMP Copyright©2005 Sun MicrosystemsRvdP/V1.1IWOMP 2005Shared Memory Model5Programming ModelTT✔All threads have access to the privatesame, globally shared, privatememory✔Data can be shared or privateShared ✔Shared data is accessible by Memory all threadsT✔Private data can be accessed private only by the threads that owns private itT T ✔Data transfer is transparent to the programmerprivate✔Synchronization takes place, but it is mostly implicitAn Introduction Into OpenMP Copyright©2005 Sun MicrosystemsRvdP/V1.1IWOMP 2005About Data6In a shared memory parallel program variables have a "label" attached to them:☞L abelled "Private" ⇨ Visible to one thread only✔C hange made in local data, is not seen by others✔Example - L ocal variables in a function that is ...

Informations

Publié par
Nombre de lectures 19
Langue English

Extrait

IWOMP 2005
1
RvdP/V1.1
An Introduction Into OpenMP
Ruud van der Pas
Senior Staff Engineer Scalable Systems Group Sun Microsystems
IWOMP 2005 University of Oregon Eugene, Oregon, USA June 1-4, 2005
An Introduction Into OpenMP
Copyright©2005 Sun Microsystems
IWOMP 2005 2
RvdP/V1.1
Outline
The OpenMP Programming Model
OpenMP Guided Tour
OpenMP Overview
Clauses
Worksharing constructs
Synchronization constructs
Environment variables
Global Data
Runtime functions
Wrap-up
An Introduction Into OpenMP
Copyright©2005 Sun Microsystems
IWOMP 2005
3
RvdP/V1.1
The OpenMP Programming Model
An Introduction Into OpenMP
Copyright©2005 Sun Microsystems
IWOMP 2005
4
RvdP/V1.1
0
Memory
1
An Introduction Into OpenMP
P
Copyright©2005 Sun Microsystems
gnM maimorrgPelodah sdaerht llAystemsIWn MicrosMO P0250p ir droSahavetdatared acce is b elbissht lla yPrsadredae ativeva ccse sott eh same, globally rahs ,deomemDyra atn ca sberehammargorp eht ot ntrepansra tisr ec ,p alkasenot zatironiyncherSt ybt eho de ylnace ssce cta bant arsnefi taDathat ownshreads tmp icili
T private
Shared Memory Model
t
private
private
T
An Introduction Into OpenMP
 tubi tiom sylts
T
T
RvdP/V1.1
Shared Memory
T
private
T
private
©2005 SuopyrightC5
IWOMP2 0056
RvdP/V1.1
About Data
In a shared memory parallel program variables have a "label" attached to them:
Labelled "Private"Visible to one thread only
Change made in local data, is not seen by others Example -Local variables in a function that is executed in parallel Labelled "Shared"Visible to all threads
Change made in global data, is seen by all others Example -Global data 
An Introduction Into OpenMP
Copyirhgt©0205S un Mircsoystems
The OpenMP execution model
RvdP/V1.1
Fork and Join Model
An Introduction Into OpenMP
Parallel region
Worker Threads
Synchronization
Parallel region
Master Thread
"threads"
7oCiryp©thgIsOWtsme005PM2  Sun2005rosy Mic
8oCt©ghripyun S0520ysorciM OWIsmets005MP 2
=
RvdP/V1.1
... etc ... An Introduction Into OpenMP
TID = 0 for (i=0,1,2,3,4) i = 0 sum =b[i=0][j]*c[j] a[0] = sum i = 1 sum =b[i=1][j]*c[j] a[1] = sum
#pragma omp parallel for default(none) \  private(i,j,sum) shared(m,n,a,b,c) f{or (i=0; i<m; i++)j  sum = 0.0;  for (j=0; j<n; j++)  sum += b[i][j]*c[j];  a[i] = sum;  }
Example - Matrix times vector
TID 1 = for (i=5,6,7,8,9) i = 5 sum =b[i=5][j]*c[j] a[5] = sum i = 6 sum =b[i=6][j]*c[j] a[6] = sum
*
i
IWOMP 2005
9
RvdP/V1.1
OpenMP Guided Tour
An Introduction Into OpenMP
Copyright©2005 Sun Microsystems
IWOMP 2005
10
RvdP/V1.1
http://www.openmp.org
http://www.compunity.org
An Introduction Into OpenMP
Copyright©2005 Sun Microsystems
WIMOP2 00151
RvdP/V1.1
When to consider using OpenMP?
The compiler may not be able to do the parallelization in  the way you like to see it:
A loop is not parallelized data dependency analysis is not able toThe determine whether it is safe to parallelize or not The granularity is not high enough The compiler lacks information to parallelize at the highest possible level This is when explicit parallelization through OpenMP directives and functions comes into the picture
An Introduction Into OpenMP
Copyirhgt©2005 Sun Mircosytsems
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents