























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
MPI
Library calls
OpenMP
Language extensions to Fortran/C/C++
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
int z = 0;parallel for (i = 0; i < nProcessors; i++) {
z += a[i] * b[i];
} cout << z << endl;
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
OpenMP Concepts
Start new
team
of
work-sharing
threads
Wait until all done (usually barrier)
Can be nested!
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
In same thread, across threads
Behaves like some sequential execution
BUT: seriously
limits parallelism
Must synchronize frequently
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
Executes next chunk of code across allor some number of threads
num_threads(n)
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
Dynamic Threads
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
Heap objects shared
Stack objects private
Includes loop iterators
unless indicated otherwise...
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
Lastprivate Example
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
Threadprivate Example
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
int
z
=
0;
#pragma omp
for
reduction(+:z)
for
(int
i =
0;
i
<
100;
i++)
{
z
+=
a[i]
b1[i];
} cout
<<
z
<<
endl;
OpenMP
pragma
directives
Omit = sequential program
More declarative style
Add more pragmas for more efficiency
NIVERSITY OFNIVERSITY OF
ASSACHUSETTSASSACHUSETTS
MHERST •MHERST
Department of Computer ScienceDepartment of Computer Science
All Together