XcalableMP Programming Model and Language
55
4.4 reduction Construct
This construct performs a reduction operation. It has the same meaning as the
reduction clause of the loop construct, but this construct can be specified
anywhere executable constructs can be located (Fig. 42).
XcalableMP C
#pragma xmp nodes p[4]
:
sum = xmpc_node_num() + 1;
#pragma xmp reduction (+:sum)
XcalableMP Fortran
!$xmp nodes p(4)
:
sum = xmp_node_num()
!$xmp reduction (+:sum)
You can specify the executing node set by using the on clause. In the example
below, only the values on the last two of the four nodes are targeted by the
reduction construct (Fig. 43).
XcalableMP C
#pragma xmp nodes p[4]
:
sum = xmpc_node_num() + 1;
#pragma xmp reduction (+:sum) on p[2:2]
Fig. 42 reduction construct (1)
55
4.4 reduction Construct
This construct performs a reduction operation. It has the same meaning as the
reduction clause of the loop construct, but this construct can be specified
anywhere executable constructs can be located (Fig. 42).
XcalableMP C
#pragma xmp nodes p[4]
:
sum = xmpc_node_num() + 1;
#pragma xmp reduction (+:sum)
XcalableMP Fortran
!$xmp nodes p(4)
:
sum = xmp_node_num()
!$xmp reduction (+:sum)
You can specify the executing node set by using the on clause. In the example
below, only the values on the last two of the four nodes are targeted by the
reduction construct (Fig. 43).
XcalableMP C
#pragma xmp nodes p[4]
:
sum = xmpc_node_num() + 1;
#pragma xmp reduction (+:sum) on p[2:2]
Fig. 42 reduction construct (1)
