>> 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).

nodecalculationsum
p(1)0+1+2+3+410
p(2)5+6+7+8+935
p(3)10+11+12+13+1460
p(4)15+16+17+18+1985

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}
      (structured-block)
      !$xmp end task

[C] #pragma xmp task on { nodes-ref | template-ref }
      (structured-block)

[F] !$xmp tasks
      (task-construct)
      ...
      !$xmp end tasks

[C] #pragma xmp tasks
      {
        (task-construct)
        ...
      }

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

#pragma xmp task on p(1)
   func_a();

#pragma xmp task on p(2)
   func_b();