XcalableMP Programming Model and Language
23
:
a = (float ( * )[N2])xmp_malloc(xmp_desc_of(a), N1, N2);
XcalableMP Fortran
!$xmp nodes p(2,2)
!$xmp template t(N2,N1)
!$xmp distribute t(block,block) onto p
real, allocatable :: a(:,:)
5 !$xmp align a(j,i) with t(j,i)
:
allocate(a(N2,N1))
Note If the size of the template is not fixed until runtime, the programmer has to
fix it at runtime with the template_fix construct.
2.6 template_fix Construct
The template_fix construct fixes the shape and/or the distribution of an unfixed
template.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t[:]
#pragma xmp distribute t[block] onto p
double * a;
5 #pragma xmp align a[i] with t[i]
int n = 100;
#pragma xmp template_fix t[n]
a = xmp_malloc(xmp_desc_of(a), n);
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t(:)
!$xmp distribute t(block) onto p
real, allocatable :: a(:)
5 integer :: n
!$xmp align a(i) with t(i)
n = 100
!$xmp template_fix t(n)
10 allocate(a(n))
23
:
a = (float ( * )[N2])xmp_malloc(xmp_desc_of(a), N1, N2);
XcalableMP Fortran
!$xmp nodes p(2,2)
!$xmp template t(N2,N1)
!$xmp distribute t(block,block) onto p
real, allocatable :: a(:,:)
5 !$xmp align a(j,i) with t(j,i)
:
allocate(a(N2,N1))
Note If the size of the template is not fixed until runtime, the programmer has to
fix it at runtime with the template_fix construct.
2.6 template_fix Construct
The template_fix construct fixes the shape and/or the distribution of an unfixed
template.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp template t[:]
#pragma xmp distribute t[block] onto p
double * a;
5 #pragma xmp align a[i] with t[i]
int n = 100;
#pragma xmp template_fix t[n]
a = xmp_malloc(xmp_desc_of(a), n);
XcalableMP Fortran
!$xmp nodes p(4)
!$xmp template t(:)
!$xmp distribute t(block) onto p
real, allocatable :: a(:)
5 integer :: n
!$xmp align a(i) with t(i)
n = 100
!$xmp template_fix t(n)
10 allocate(a(n))
