XcalableMP Programming Model and Language
27
Note that the task is executed by the node set specified by the on clause.
Therefore, xmpc_node_num() and xmp_node_num() return the id in the node
set.
For example, consider inserting xmpc_node_num() or xmp_node_num()
into the task in the first program.
XcalableMP C
#include
#pragma xmp nodes p[4]
int main(){
5 #pragma xmp task on p[1:3]
{
printf("%d: Hello\n", xmpc_node_num());
}
10
return 0;
}
XcalableMP Fortran
program main
!$xmp nodes p(4)
!$xmp task on p(2:4)
5
write( * , * ) xmp_node_num(), ": Hello"
!$xmp end task
end program main
The node p[1] outputs “0: Hello” in XMP/C, and p(2) “1: Hello” in XMP/Fortran.
Note A new node set should be collectively generated by all of the executing nodes
at the point of a task construct unless it is surrounded by a tasks construct.
Therefore, in the above example, p[0] in XMP/C and p(1) in XMP/Fortran must
process the task construct.
3.1.2 tasks Construct
Let’s consider that each of two tasks invokes a function.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp task on p[0:2]
27
Note that the task is executed by the node set specified by the on clause.
Therefore, xmpc_node_num() and xmp_node_num() return the id in the node
set.
For example, consider inserting xmpc_node_num() or xmp_node_num()
into the task in the first program.
XcalableMP C
#include
#pragma xmp nodes p[4]
int main(){
5 #pragma xmp task on p[1:3]
{
printf("%d: Hello\n", xmpc_node_num());
}
10
return 0;
}
XcalableMP Fortran
program main
!$xmp nodes p(4)
!$xmp task on p(2:4)
5
write( * , * ) xmp_node_num(), ": Hello"
!$xmp end task
end program main
The node p[1] outputs “0: Hello” in XMP/C, and p(2) “1: Hello” in XMP/Fortran.
Note A new node set should be collectively generated by all of the executing nodes
at the point of a task construct unless it is surrounded by a tasks construct.
Therefore, in the above example, p[0] in XMP/C and p(1) in XMP/Fortran must
process the task construct.
3.1.2 tasks Construct
Let’s consider that each of two tasks invokes a function.
XcalableMP C
#pragma xmp nodes p[4]
#pragma xmp task on p[0:2]
