>> Japanese

Work Mapping

Loop directive

The loop construct specifies that each iteration of the following loop is executed by a node set specified by the on clause, so that the iterations are distributed among nodes and executed in parallel.

[F] !$xmp loop [ ( loop-index [, loop-index]...  ) ] on {node-ref | template-ref} [reduction-clause] ... 
[C] #pragma xmp loop [ ( loop-index [, loop-index] ... ) ] on {node-ref | template-ref} [reduction-clause] ...

where reduction-clause is:
    reduction ( reduction-kind : reduction-spec [, reduction-spec]... )

reduction-spec is:
    reduction-variable [ / location-variable [, location-variable ]... / ]
  • Specify the index to be divided between the loop and on statements. In the case of a single loop statement, this can be omitted.
  • on-ref specifies the template name or the node set name.
  • reduction-ref is defined as follows.
  • [F] +, *, -, .and., .or., .eqv., .neqv., max, min, iand, ior, ieor, firstmax, firstmin, lastmax, lastmin
    [C] +, *, -, &, |, ^, &&, ||, max, min, firstmax, firstmin, lastmax, lastmin

Single loop

#pragma xmp loop on t(i)
for( i = 0; i < 20; i++)
   a[i] = func(i);

Nested loop

#pragma xmp loop (j, i) on t(j, i)
for( i = 0; i < 20; i++)
   for( j = 0; j < 10; j++)
      a[i][j] = func(i , j);

Reduction clause

sum = 0;
#pragma xmp loop on t(i) reduction(+:sum)
for( i = 0; i < 20; i++)
   sum += i;

The following calculation is performed at each node (with four nodes).


After the end of the loop statement, the reduction clause causes a summation calculation to be performed based on the value of sums held at each node. In this case, a value of 190 is assigned to the sum in each node.

Task and Tasks directives

The task construct defines a task that is executed by a specified node set.

The tasks construct is used to instruct the executing nodes to execute the multiple tasks it surrounds in arbitrary order.

[F] !$xmp task on { nodes-ref | template-ref}
      !$xmp end task

[C] #pragma xmp task on { nodes-ref | template-ref }

[F] !$xmp tasks
      !$xmp end tasks

[C] #pragma xmp tasks

For the following example, p(1) executes func_a() and p(2) executes func_b() one.

#pragma xmp task on p(1)

#pragma xmp task on p(2)