Mixed-Language Programming with XcalableMP
149
void foo(){
printf("Hello\n");
}
int main(){
foo();
return 0;
}
void foo(){
printf("Hello\n");
}
static int xmpc_main(int argc, char **argv){
foo();
return 0;
}
int main(int argc, char **argv){
xmp_init_all(argc, argv);
int r = xmpc_main(argc, argv);
xmp_finalize_all();
return r;
}
Fig. 1 Example of translation in Omni compiler [19]
3 Functions for Mixed-Language
For a mixed-language programming with XMP, Omni compiler has the following
functions.
• Calling an MPI program from an XMP program
• Calling an XMP program from an MPI program
• Calling an XMP program from a Python program
3.1 Function to Call MPI Program from XMP Program
Table 1 shows the functions to call an MPI program from an XMP program. These
functions are defined in Appendix A.1 of the XMP specification version 1.4. 3
Figure 2 also shows an example of how to use these functions. In line 1 of the
left figure, an XMP header file (xmp.h) is included to use the functions in Table 1.
In line 2, an MPI header file (mpi.h) is included to obtain the information of the MPI
communicator type that is used in line 7. In line 6, xmp_init_mpi() initializes an
MPI environment. In line 8, xmp_get_mpi_comm() returns an MPI communicator
from the information of the executing XMP node set. In line 9, foo() which is
defined in right figure is called. In line 10, xmp_finalize_mpi() finalizes the MPI
3 https://xcalablemp.org/download/spec/xmp-spec-1.4.pdf
Précédent

- 156/265

Suivant