40
H. Murai et al.
Fig. 28 Example of shadow directive (2)
only on either of the bounds. In the example below, it is declared that a distributed
array a has a shadow area of width one only on the upper bound (Fig. 28).
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t[16]
#pragma xmp distribute t(block) onto p
double a[16];
5 #pragma xmp align a[i] with t[i]
#pragma xmp shadow a[0:1]
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t(16)
!$xmp distribute t(block) onto p
real :: a(16)
5 !$xmp align a(i) with t(i)
!$xmp shadow a(0:1)
The values on the left- and right-hand sides of a colon designate the widths on
the lower and upper bounds, respectively.
4.1.2 Updating Shadow
To copy data to shadow areas from neighboring nodes, use the reflect construct.
In the example below, the shadow areas of an array a that are of width one on both
the upper and lower bounds are updated (Fig. 29).
XcalableMP C
#pragma xmp reflect (a)
#pragma xmp loop on t[i]
for(int i=1;i<15;i++)
5
a[i] = (a[i-1] + a[i] + a[i+1])/3;
H. Murai et al.
Fig. 28 Example of shadow directive (2)
only on either of the bounds. In the example below, it is declared that a distributed
array a has a shadow area of width one only on the upper bound (Fig. 28).
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t[16]
#pragma xmp distribute t(block) onto p
double a[16];
5 #pragma xmp align a[i] with t[i]
#pragma xmp shadow a[0:1]
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t(16)
!$xmp distribute t(block) onto p
real :: a(16)
5 !$xmp align a(i) with t(i)
!$xmp shadow a(0:1)
The values on the left- and right-hand sides of a colon designate the widths on
the lower and upper bounds, respectively.
4.1.2 Updating Shadow
To copy data to shadow areas from neighboring nodes, use the reflect construct.
In the example below, the shadow areas of an array a that are of width one on both
the upper and lower bounds are updated (Fig. 29).
XcalableMP C
#pragma xmp reflect (a)
#pragma xmp loop on t[i]
for(int i=1;i<15;i++)
5
a[i] = (a[i-1] + a[i] + a[i+1])/3;
