150
M. Nakao
Table 1 Functions to call MPI program from XMP program [19]
Language Return value type Function
Description
XMP/C
Void
xmp_init_mpi(int*, char***) Initialize MPI environment
XMP/F
(None)
xmp_init_mpi()
XMP/C
MPI_Comm
xmp_get_mpi_comm(void)
Create MPI communicator from
XMP/F
Integer
xmp_get_mpi_comm()
XMP node set
XMP/C
Void
xmp_finalize_mpi(void)
Finalize MPI environment
XMP/F
(None)
xmp_finalize_mpi()
#include
#include
#pragma xmp nodes p[*]
int main(int argc, char **argv){
xmp_init_mpi(&argc, &argv);
MPI_Comm comm;
comm = xmp_get_mpi_comm();
foo(comm);
xmp_finalize_mpi();
return 0;
}
#include
void foo(MPI_Comm comm){
int rank, size;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
:
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Fig. 2 Example of calling MPI program (mpi.c) from XMP program (xmp.c) [19]
environment. Note that xmp_get_mpi_comm() and other MPI functions must be
placed between xmp_init_mpi() and xmp_finalize_mpi().
The implementations of xmp_init_mpi() and xmp_finalize_mpi() are empty
because, as shown in Fig. 1, the xmp_init_all() and xmp_finalize_all() are
always invoked at the beginning and the end of the program, and these
functions initialize and finalize the MPI environment. Next, an implementation
of xmp_get_mpi_comm() will be described. As shown in Sect. 2, the task directive
creates a new MPI communicator. Thus, an MPI communicator is stored at a stack
data architecture in Omni compiler runtime library. The xmp_get_mpi_comm()
returns an MPI communicator at the top of the stack.
An example of compilation using Omni compiler is as follows:
$ mpicc mpi.c -c -o mpi.o
$ xmpcc xmp.c -c -o xmp.o
$ xmpcc mpi.o xmp.o -o a.out
M. Nakao
Table 1 Functions to call MPI program from XMP program [19]
Language Return value type Function
Description
XMP/C
Void
xmp_init_mpi(int*, char***) Initialize MPI environment
XMP/F
(None)
xmp_init_mpi()
XMP/C
MPI_Comm
xmp_get_mpi_comm(void)
Create MPI communicator from
XMP/F
Integer
xmp_get_mpi_comm()
XMP node set
XMP/C
Void
xmp_finalize_mpi(void)
Finalize MPI environment
XMP/F
(None)
xmp_finalize_mpi()
#include
#include
#pragma xmp nodes p[*]
int main(int argc, char **argv){
xmp_init_mpi(&argc, &argv);
MPI_Comm comm;
comm = xmp_get_mpi_comm();
foo(comm);
xmp_finalize_mpi();
return 0;
}
#include
void foo(MPI_Comm comm){
int rank, size;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
:
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Fig. 2 Example of calling MPI program (mpi.c) from XMP program (xmp.c) [19]
environment. Note that xmp_get_mpi_comm() and other MPI functions must be
placed between xmp_init_mpi() and xmp_finalize_mpi().
The implementations of xmp_init_mpi() and xmp_finalize_mpi() are empty
because, as shown in Fig. 1, the xmp_init_all() and xmp_finalize_all() are
always invoked at the beginning and the end of the program, and these
functions initialize and finalize the MPI environment. Next, an implementation
of xmp_get_mpi_comm() will be described. As shown in Sect. 2, the task directive
creates a new MPI communicator. Thus, an MPI communicator is stored at a stack
data architecture in Omni compiler runtime library. The xmp_get_mpi_comm()
returns an MPI communicator at the top of the stack.
An example of compilation using Omni compiler is as follows:
$ mpicc mpi.c -c -o mpi.o
$ xmpcc xmp.c -c -o xmp.o
$ xmpcc mpi.o xmp.o -o a.out
