XcalableMP Programming Model and Language
13
2.2 template Directive
The template directive declares a template, which is a virtual array that is used
as a “template” of parallelization in the programs and to be distributed onto a node
array.
XcalableMP C
#pragma xmp template t[10]
XcalableMP Fortran
!$xmp template t(10)
This template directive declares a one-dimensional template t having ten
elements. Templates are indexed in the similar manner to arrays in the base
languages. For the above examples, the template t is indexed from zero to nine (i.e.
t[0] · · · t[9]), in XMP/C, or one to ten (i.e. t(1) · · · t(10)), in XMP/Fortran.
Hint In many cases, a template should be declared to have the same shape as your
target array.
XcalableMP C
#pragma xmp template t[10][20]
XcalableMP Fortran
!$xmp template t(20,10)
The template directive declares a two-dimensional template t that has 10 ×
20 elements. In XMP/C, t is indexed from t[0][0] to t[9][19], and, in XMP/Fortran,
from t(1,1) to t(20,10).
XcalableMP C
#pragma xmp template t[:]
XcalableMP Fortran
!$xmp template t(:)
In the above examples, a colon instead of an integer is specified as the size to
declare a one-dimensional dynamic template t. The colon indicates that the size
of the template is not fixed and to be fixed at runtime by the template_fix
construct (Sect. 2.6).
2.3 distribute Directive
The distribute directive specifies a distribution of the target template. Either of
block, cyclic, block-cyclic, or gblock (i.e. uneven block) can be specified to distribute
a dimension of a template.
Précédent

- 21/265

Suivant