XcalableMP Programming Model and Language
49
:
10 #pragma xmp gmove
a[9:5] = b[0:5];
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t1(16)
!$xmp template t2(16)
!$xmp distribute t1(cyclic) onto p
5 !$xmp distribute t2(block) onto p
integer :: a(16), b(16)
!$xmp align a(i) with t1(i)
!$xmp align b(i) with t2(i)
:
10 !$xmp gmove
a(10:14) = b(1:5)
While array a is distributed in a cyclic manner, array b is distributed in a block
manner.
In XMP/C, p[0] sends b[0] and b[4] to p[2] and p[3]. p[1] sends b[1]
to p[2]. Each element of p[2] and p[3] will be copied locally. Similarly, in
XMP/Fortran, p(1) sends b(1) and b(5) to p(3) and p(4). p(2) sends b(2)
to p(3). Each element of p(3) and p(4) will be copied locally (Fig. 36).
By using this method, the distribution of an array can be “changed” during
computation.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t1[16]
#pragma xmp template t2[16]
int W[4] = {2,4,8,2};
5 #pragma xmp distribute t1[gblock(W)] onto p
#pragma xmp distribute t2[block] onto p
int a[16], b[16];
#pragma xmp align a[i] with t1[i]
#pragma xmp align b[i] with t2[i]
10
:
#pragma xmp gmove
a[:] = b[:];
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t1(16)
!$xmp template t2(16)
integer :: W(4) = (/2,4,7,3/)
5 !$xmp distribute t1(gblock(W)) onto p
!$xmp distribute t2(block) onto p
Précédent

- 57/265

Suivant