14
H. Murai et al.
2.3.1 Block Distribution
XcalableMP C
#pragma xmp distribute t[block] onto p
XcalableMP Fortran
!$xmp distribute t(block) onto p
The target template t is divided into contiguous blocks and distributed among
nodes in the node array p (Fig. 8). Let’s suppose that the size of the template is
N and the number of nodes is K. If N is divisible by K, a block of size N/K is
assigned to each node; otherwise, a block of size ceil(N/K) is assigned to each of
N/ceil(N/K) nodes, a block of size mod(N, K) to one node, and no block to (K −
N/ceil(N/K) − 1) nodes. The block distribution is useful for regular computations
such as a stencil one.
Note The function ceil(x) returns a minimum integer value greater than or equal to
x, and mod(x, y) returns x modulo y.
XcalableMP C
#pragma xmp nodes p[3]
#pragma xmp template t[22]
#pragma xmp distribute t[block] onto p
XcalableMP Fortran
!$xmp nodes p(3)
!$xmp template t(22)
!$xmp distribute t(block) onto p
Since ceil(22/3) is 8, eight elements are allocated on each of p[0] and p[1],
and the remaining six elements are allocated on p[2].
XMP/C
XMP/Fortran
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
p[0], p(1)
p[1], p(2)
p[2], p(3)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Fig. 8 Block distribution
Précédent

- 22/265

Suivant