152
M. Nakao
#include
#include
int main(int argc, char **argv){
MPI_Init(&argc, &argv);
xmp_init(MPI_COMM_WORLD);
foo();
xmp_finalize();
MPI_Finalize();
return 0;
}
void foo(){
#pragma xmp nodes p[*]
:
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Fig. 3 Example of calling XMP program from MPI program [19]
• Before calling xmp_init(), MPI_Init() must be called in the MPI program.
Therefore, we added a procedure that ensures MPI_Init() is not called in
xmp_init_all().
• As shown in Sect. 2, xmp_init_all() duplicates MPI_COMM_WORLD to perform XMP communication. We also added a procedure that ensures the communicator specified in xmp_init() is duplicated instead of MPI_COMM_WORLD.
Basically, xmp_finalize() is also implemented to call xmp_finalize_all() in
Sect. 2. As with xmp_init(), after calling xmp_finalize(), MPI_Finalize() is called
in an MPI program. Therefore, we added a procedure to ensure that MPI_Finalize()
is not called in xmp_finalize_all().
The method to compile and execute is the same as Sect. 3.1.
3.3 Function to Call XMP Program from Python Program
There are two types of calling an XMP program from a Python program in Omni
compiler; the one is “calling from a parallel Python program,” the other is “calling
from a sequential Python program.”
3.3.1 From Parallel Python Program
Figure 4 shows an example of calling an XMP program from a parallel Python
program. We assume the use of “mpi4py” for a Python MPI environment. In line
2 of the left figure, an XMP package is imported which is in Omni compier. In
line 4, the shared library (bar.so) created from the right figure is read. In line 8,
Précédent

- 159/265

Suivant