>> Japanese

# Data Mapping

## nodes directive

``````[F] !\$xmp nodes nodes-decl [, nodes-decl ]...
[C] #pragma xmp nodes nodes-decl [, nodes-decl ]...

where nodes-decl is one of:
node-name (node-spec [, node-spec] ...)
node-name (node-spec [, node-spec] ...) = node-ref

nodes-spec must be one of:
int-expr
*``````

The nodes directive declares a named node array.

``````ex. 1 : #pragma xmp nodes p(4)
ex. 2 : #pragma xmp nodes p(*)
ex. 3 : #pragma xmp nodes p(2, 2)
ex. 4 : #pragma xmp nodes p(2, 3, *)
ex. 5 : #pragma xmp nodes p(10)
#pragma xmp nodes q(4)=p(5:8)``````
• node-name must not conflict with any other local name in the same scoping unit.
• nodes-spec defines the number of nodes. This must be a positive integer or "∗". If "∗" is specified, processing is matched to the number of nodes specified when the program is executed.
• Multidimensional node sets, such as in ex. 3 and 4, can also be declared. The product of the number of nodes for each dimension must be the same as the number of computation nodes employed.
• In ex. 4, when the number of nodes at execution time is specified to be 12, "∗" would be 2. nodes-spec can be "∗" only in the last dimension.
• In ex. 5, the node set p is used, with q defined as the subnode set. In this case, a subnode set q of p(5) to p(8) is created.

## template directive

``````[F] !\$xmp template template-decl [, template-decl ]...
[C] #pragma xmp template template-decl [, template-spec]...

where template-decl is:
template-name ( template-spec [, template-spec ]... )

and template-spec must be one of:
[int-expr :] int-expr
:``````

The template directive declares a template as a virtual index.

``````ex. 1 : #pragma xmp template t(0:9)
ex. 2 : #pragma xmp template t(0:9, 0:19)``````
• template-name must not conflict with any other local name in the same scoping unit.
• template-spec uses a colon to define the index range. In ex. 1, the index is defined as 0 through 9.
• As in ex. 2, a two-dimensional (or larger) template can be declared.

## distribute directive

``````[F] !\$xmp distribute template-name (dist-format [, dist-format]... ) onto nodes-name
[C] #pragma xmp distribute template-name (dist-format [, dist-format]... ) onto nodes-name

where dist-format must be one of:
*
block [ ( int-expr ) ]
cyclic [ ( int-expr ) ]
gblock ( { * | int-array } )
``````

The distribute directive specifies distribution of a template.

``````ex. 1 : #pragma xmp distribute t(block) onto p
ex. 2 : #pragma xmp distribute t(block, cyclic) onto p
ex. 3 :#pragma xmp distribute t(block, *) onto p``````

• Possible distribution are "∗", "block", "block(n)", "cyclic", "cyclic(n)", and "gblock(m)".
• "∗" means that this particular dimension is duplicated.

### block distribution

``````#pragma xmp nodes p(4)
#pragma xmp template t(0:19)
#pragma xmp distribute t(block) onto p``````

nodeindexes of template
p(1) 0, 1, 2, 3, 4
p(2) 5, 6, 7, 8, 9
p(3) 10, 11, 12, 13, 14
p(4) 15, 16, 17, 18, 19

### cyclic distribution

``````#pragma xmp nodes p(4)
#pragma xmp template t(0:19)
#pragma xmp distribute t(cyclic) onto p``````

nodeindexes of template
p(1) 0, 4, 8, 12, 16
p(2) 1, 5, 9, 13, 17
p(3) 2, 6, 10, 14, 18
p(4) 3, 7, 11, 15, 19

### cyclic(n) distribution

``````#pragma xmp nodes p(4)
#pragma xmp template t(0:19)
int n = 2;
#pragma xmp distribute t(cyclic(n)) onto p``````

nodeindexes of template
p(1) 0, 1, 8, 9, 16, 17
p(2) 2, 3, 10, 11, 18, 19
p(3) 4, 5, 12, 13
p(4) 6, 7, 14, 15

### gblock(m) distribution

``````#pragma xmp nodes p(4)
#pragma xmp template t(0:19)
int m[4] = {3, 5, 8, 4};
#pragma xmp distribute t(gblock(m)) onto p``````

nodeindexes of template
p(1) 0, 1, 2
p(2) 3, 4, 5, 6, 7
p(3) 8, 9, 10, 11, 12, 13, 14, 15
p(4) 16, 17, 18, 19

## align directive

``````[F] !\$xmp align array-name ( align-source [, align-source]... ) with template-name ( align-subscript [, align-subscript]... )
[C] #pragma xmp align array-name [align-source] [[align-source]]... with template-name ( align-subscript [, align-subscript]... )

where align-source must be one of:
scalar-int-variable
*
:

and align-subscript must be one of:
scalar-int-variable [ { + | - } int-expr ]
*
:``````

The align directive specifies that an array is to be mapped in the same way as a specified template.

• "∗" indicates that no division is performed.
• ":" indicates all valid index range.
``````ex. 1 : #pragma xmp align a[i] with t(i)         // A one-dimensional array and a one-dimensional template
ex. 2 : #pragma xmp align a[:] with t(:)         // This is equivalent to the ex. 1.
ex. 3 : #pragma xmp align a[i][j] with t(j, i)   // A two-dimensional array and a two-dimensional template
ex. 4 : #pragma xmp align a[*][i] with t(i)      // A two-dimensional array and a one-dimensional template
ex. 5 : #pragma xmp align a[i] with t(i, *)      // A one-dimensional array and a two-dimensional template
ex. 6 : #pragma xmp align a[i] with t(i+1)       // Indices of the array and template are to be changed``````

### A one-dimensional array and a one-dimensional template

``````#pragma xmp template t(0:19)
#pragma xmp nodes p(4)
#pragma xmp distribute t(block) onto p
int a[20];
#pragma xmp align a[i] with t(i)``````

Each node processes the index of the array a[] below.

### A two-dimensional array and a two-dimensional template

``````#pragma xmp nodes p(2, 2)
#pragma xmp template t(0:9, 0:9)
#pragma xmp distribute t(block, cyclic) onto p
int a[10][10];
#pragma xmp align a[i][j] with t(j, i)``````

Note: The order for the template indices is based on Fortran conventions. For the C language, therefore, the order of i and j for the array and the template is reversed.

Each node processes the indices of array a[][] below.

node1st indexes of a[][]2nd indexes of a[][]
p(1,1) 0, 1, 2, 3, 4 0, 2, 4, 6, 8
p(2,1) 5, 6, 7, 8, 9 0, 2, 4, 6, 8
p(1,2) 0, 1, 2, 3, 4 1, 3, 5, 7, 9
p(2,2) 5, 6, 7, 8, 9 1, 3, 5, 7, 9

### A two-dimensional array and a one-dimensional template

``````#pragma xmp nodes p(4)
#pragma xmp template t(0:19)
#pragma xmp distribute t(block) onto p
int a[10][20];
#pragma xmp align a[*][i] with t(i)``````

The first dimension of array a[][] is "∗, and so it is not divided, and only the second dimension index is divided among each of nodes and processed.

### A one-dimensional array and a two-dimensional template

``````#pragma xmp nodes p(2,2)
#pragma xmp template t(0:19, 0:19)
#pragma xmp distribute t(block, block) onto p
int a[10];
#pragma xmp align a[i] with t(i, *)``````

Both p(1,1) and p(2,2) have indices from 0 to 4, both p(2,1) and p(2,2) have indices from 5 to 9.

### The case when the indices of the array and template are to be changed

``````#pragma xmp nodes p(4)
#pragma xmp template t(1:20)
#pragma xmp distribute t(block) onto p
int a[20];
#pragma xmp align a[i] with t(i+1)``````

p(1) has indices from 1 to 5, but the template corresponds to indices 0 to 4 of array a[].