Documente Academic
Documente Profesional
Documente Cultură
Computing
Fabian Frie
Numerical Methods in Quantum Physics
February 6th 2014
,
Page 2 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Syllabus
1 Introduction
What is Parallel Computing?
Scalability
2 Parallel Programming Models
Memory Models
Exploring MPI
Exploring OpenMP
Comparison
3 Examples with OpenMP
Matrix Matrix Multiplication
Approximation of
4 Conclusion
,
Page 3 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
1 Introduction
What is Parallel Computing?
Scalability
2 Parallel Programming Models
Memory Models
Exploring MPI
Exploring OpenMP
Comparison
3 Examples with OpenMP
Matrix Matrix Multiplication
Approximation of
4 Conclusion
,
Page 4 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
What is Parallel Computing?
Introduction
Widely available
Redesign of application
More resources
required: Typically more
memory
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 14 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Comparison
Parallel Programming Models
MPI
No data scoping
(shared, private,...)
easier model
requires runtime
enviroment
OpenMP
easy to learn
preserve sequential
code
requires compiler
support
performance issues
implicit
no runtime enviroment
required
,
Page 15 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
1 Introduction
What is Parallel Computing?
Scalability
2 Parallel Programming Models
Memory Models
Exploring MPI
Exploring OpenMP
Comparison
3 Examples with OpenMP
Matrix Matrix Multiplication
Approximation of
4 Conclusion
,
Page 16 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Simple Tasks with OpenMP
Examples
Matrix Matrix
Multiplication
C = AB (1)
C
i,j
=
k
A
i,k
B
k,j
(2)
Approximation of
1
0
dx
4
1 +x
2
= (3)
[arctan(x)]
1
0
= (4)
N
i=0
4
1 +x
2
i
x (5)
How efciently can these problems be
parallelized?
,
Page 16 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Simple Tasks with OpenMP
Examples
Matrix Matrix
Multiplication
C = AB (1)
C
i,j
=
k
A
i,k
B
k,j
(2)
Approximation of
1
0
dx
4
1 +x
2
= (3)
[arctan(x)]
1
0
= (4)
N
i=0
4
1 +x
2
i
x (5)
How efciently can these problems be
parallelized?
,
Page 16 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Simple Tasks with OpenMP
Examples
Matrix Matrix
Multiplication
C = AB (1)
C
i,j
=
k
A
i,k
B
k,j
(2)
Approximation of
1
0
dx
4
1 +x
2
= (3)
[arctan(x)]
1
0
= (4)
N
i=0
4
1 +x
2
i
x (5)
How efciently can these problems be
parallelized?
,
Page 16 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Simple Tasks with OpenMP
Examples
Matrix Matrix
Multiplication
C = AB (1)
C
i,j
=
k
A
i,k
B
k,j
(2)
Approximation of
1
0
dx
4
1 +x
2
= (3)
[arctan(x)]
1
0
= (4)
N
i=0
4
1 +x
2
i
x (5)
How efciently can these problems be
parallelized?
,
Page 17 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Matrix Matrix Multiplication
Examples
,
Page 18 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Approximation of
Examples
,
Page 19 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Approximation of I
Source Code
1 program integ
_
pi
2 use omp
_
lib
3 implicit none
4
5 integer(kind=8) :: ii, num
_
steps, jj
6 integer :: tid, nthreads
7 real(kind=8) :: step, xx, pi, summ, start
_
time, run
_
time
8
9 num
_
steps = 100000000
10 step = 1d0/dble(num
_
steps)
11
12 do jj = 1,8 ! Number of requested threads
13 pi = 0d0
14 call omp
_
set
_
num
_
threads(jj)
15 start
_
time = omp
_
get
_
wtime()
16 nthreads = omp
_
get
_
num
_
threads()
17
18 !$omp single
,
Page 20 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Approximation of II
Source Code
19 write(
*
,
*
) "Number of threads: ", nthreads
20 !$omp end single
21
22 !$omp parallel do reduction(+:pi) private(ii,xx)
23 do ii = 0,num
_
steps
24 xx = (dble(ii)+0.5d0)
*
step
25 pi = pi + 4d0 / (1d0 + xx
*
xx)
26 enddo
27 !$omp end parallel do
28
29 run
_
time = omp
_
get
_
wtime()-start
_
time
30 pi = pi
*
step
31 write(
*
,
*
) "pi approx ", pi
32 write(
*
,
*
) "wtime: ", run
_
time
33 enddo
34 end program integ
_
pi
,
Page 21 | F. Frie, Haupseminar NMQP | Exploring Parallel Computing | February 2014
Wrap Up
Prospects