24
H. Murai et al.
In the above sample code, first, a template t whose size is unfixed (“:”) is
declared; second, a pointer a, in XMP/C, or an allocatable array a, in XMP/Fortran,
is aligned with the template; third, the size of the template is fixed with a
template_fix construct; finally, the pointer or the allocatable array is allocated
with the xmp_malloc() built-in function in XMP/C or the allocate statement
in XMP/Fortran, respectively.
Note The template_fix constructs can be applied to a template only once.
This construct can also be used to fix a mapping array of a template that is
distributed in “gblock( * )” at declaration.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t[:]
#pragma xmp distribute t[gblock( * )] onto p
double * a;
5 #pragma xmp align a[i] with t[i]
int n = 100;
int m[] = {40,30,20,10};
10 #pragma xmp template_fix[gblock(m)] t[n]
a = xmp_malloc(xmp_desc_of(a), n);
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t(:)
!$xmp distribute t(gblock) onto p
real, allocatable :: a(:)
5 integer :: n, m(4)
!$xmp align a(i) with t(i)
n = 100
m(:) = (/40,30,20,10/)
10 !$xmp template_fix(gblock(m)) t(n)
allocate(a(n))
Précédent

- 32/265

Suivant