22
H. Murai et al.
When an asterisk is specified as a subscript in a dimension of the target template
in the align directive, the array will be “replicated” along the axis of the
dimension.
In XMP/C, a[0:4] will be replicated and allocated on p[0][0] and p[0][1]
while, in XMP/Fortran, a(1:4) will be allocated on p(1,1) and p(2,1).
2.5 Dynamic Allocation of Distributed Array
This section explains how distributed (i.e. global) arrays are allocated at runtime.
The basic procedure is common in XMP/C and XMP/Fortran with a few specific
difference.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t[N]
#pragma xmp distribute t[block] onto p
float * a;
5 #pragma xmp align a[i] with t[i]
:
a = xmp_malloc(xmp_desc_of(a), N);
In XMP/C, first, declare a pointer of the type of the target array; second, align it
as if it were an array; finally, allocate memory for it with the xmp_malloc() function. xmp_desc_of() is an intrinsic/built-in function that returns the descriptor of
the XMP object (i.e. nodes, templates, or global arrays) specified by the argument.
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t(N)
!$xmp distribute t(block) onto p
real, allocatable :: a(:)
5 !$xmp align a(i) with t(i)
allocate(a(N))
In XMP/Fortran, first, declare an allocatable array; second, align it; finally,
allocate memory for it with the allocate statement.
For multi-dimensional arrays, the procedure is the same as that for onedimensional ones, as follows:
XcalableMP C
#pragma xmp nodes p[2][2]
#pragma xmp template t[N1][N2]
#pragma xmp distribute t[block][block] onto p
float ( * a)[N2];
5 #pragma xmp align a[i][j] with t[i][j]
Précédent

- 30/265

Suivant