Professional Documents
Culture Documents
Lero 2013
Parallel
Design
What
are
the
data
dependencies?
Cells
need
to
interact
with
8
neighbours
so
dependencies
with
cells
north,
south,
east,
west,
northeast,
northwest,
southeast,
southwest
What
decomposi9on
strategy
will
suit
such
dependencies?
Row
to
row
(n/s)
Column
(e/w)
Cartesian
(n,s,e,w,
ne,nw,se,sw)
Lero 2013
Row
Decomposi9on
Rank
0
Rank
1
Rank size-1
Lero 2013
Column
Decomposi9on
Rank 0
Rank 1
Rank size-1
Lero 2013
Cartesian
Decomposi9on
Rank
0
Rank
1
Rank size-1
Lero 2013
Cartesian
Decomposi9on
Rank
0
Rank
1
NJ
ndims
=?
number
of
dimensions
dims=(?,?)
number
of
processes
in
each
dimension
periods=(?,?)
specifying
whether
the
grid
is
periodic
(1/true)
or
not
(0/false)
in
each
dimension
Rank
size-1
reorder
=
?
determines
if
the
ranking
may
be
reordered
(true)
or
not
(false)
NI
Lero 2013
Cartesian
Decomposi9on
Global
grid
Local
grid
localInnerNumCols
Rank 0
Rank 1
Rank 2
Rank 2
Rank 3
localOuterNumCols
Rank size-1
Local
variables
To
determine
the
local
number
of
columns
allocated
to
each
process,
can
use
the
following
logic:
! int localInnerNumCols = NJ/dims[1];!
e.g.
if
NJ=100
and
dims[1]=5
then
localInnerNumCols=20
Remember:
each
process
is
actually
allocated
2
extra
ghost
rows
and
columns
for
cyclic
communica9on=> localInnerNumCols+2!
Lero 2013
Secng
up
variables
Need
to
decide
which
variables
you
will
need
e.g:
int !
int ! int ! int ! int ! !
localInnerNumCols = NJ/dims[1];! localOuterNumCols = localInnerNumCols+2;! localFirstCol= 0;! localLastCol=localInnerNumCols+1;! innerLastCol=localLastCol-1;!
localOuterNumCols
Local
grid
localInnerNumCols
Rank 2
Lero 2013
10
Global
vs
Local
I
am
rank
3
but
what
chunk
of
data
do
I
have
from
the
global
grid?
The
global
grid
is
the
NI
x
NJ
size
as
corresponds
to
the
serial
applica9on
The
local
grid
is
the
grid
distributed
to
each
rank
:
NI/ dims[0]
x
NJ/dims[1]
It
may
be
necessary
to
determine
where
on
the
global
grid
your
local
data
corresponds.
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
Rank 3 (1,0)
Lero
2013
11
Global
vs
Local
We
can
see
that
rank
3
has
the
sec9on
of
data
from
row
3
to
row
4
in
the
global
grid
from
column
1
to
column
2
in
the
global
grid
The
following
logic
determines
the
indices
with
respect
to
the
0
1 myFirstRow_glob=(coords[0]*localInnerNumRows)+1;!
myFirstCol_glob=(coords[1]*localInnerNumCols)+1;! 2 myLastRow_glob=myFirstRow_glob+localInnerNumRows-1;!
3 myLastCol_glob=myFirstCol_glob+localInnerNumCols-1;!
4 !
5 For
rank
3
with
coords
(1,0)
in
a
9x9
sized
grid:
!myFirstRow_glob=3, myLastRow_glob=4, ! 6
!myFirstCol_glob=1, myLastCol_glob=2! 7
0 1 2 3 4 5 6 7
Rank 3 (1,0)
Lero 2013
12
Lero 2013
13
South
to
North
!
north_rank
0,0
localInnerNumRows = 4
localInnerNumCols
1,1
south_rank
Lero
2013
14
West
to
East
! ! ! ! ! ! ! ! ! ! ! !
0,0
1,1
1,2
1,3
1,4
0,0
1,0
1,1
2,0
3,0
west_rank
east_rank
Derived Datatype
localInnerNumCols = 4
Lero 2013
15
NorthEast
to
SouthWest
!
North_East_rank
0,0
1,1
localLastCol
0,0
South_West_rank
Lero
2013
16
MPIGen Tool
hMp://mpigen.lero.ie
Lero 2013
17
Lero 2013
18