LinuxCommandLibrary

mpijavac

Compile MPI Java source code

TLDR

Compile a Java source file

$ mpijavac [path/to/source_file.java]
copy

Pass application-specific classpaths to compiler
$ mpijavac -cp [path/to/my/app.jar] [path/to/source_file.java]
copy

Show the flags necessary to build MPI Java applications
$ mpijavac --showme
copy

Show the flags necessary to compile MPI Java applications
$ mpijavac --showme:compile
copy

Show full invoked Java compiler command line
$ mpijavac [path/to/source_file.java] --showme
copy

SYNOPSIS

mpijavac [javac_options] source_files

PARAMETERS

javac_options
    All options supported by the standard javac command are passed through by mpijavac. These can include options for specifying output directories (-d), source/target versions, debugging information (-g), and more.

source_files
    One or more Java source files (.java files) to be compiled. These are typically the files containing your MPI application code.

--version
    Displays the version information for the mpijavac wrapper and potentially the underlying MPI library.

--help
    Displays a brief usage message and available options for the mpijavac command.

--showme
    Prints the exact javac command line that mpijavac would execute, including the automatically added classpath and other options, without actually running it.

DESCRIPTION

The mpijavac command is a convenient wrapper script provided by MPI (Message Passing Interface) implementations, such as Open MPI or MPICH, to simplify the compilation of Java applications that utilize the MPI API.

Essentially, it acts as a frontend to the standard Java compiler, javac. Its primary function is to automatically set the necessary classpath to include the MPI Java library files (e.g., mpi.jar). This eliminates the need for developers to manually specify the -classpath option when compiling MPI-enabled Java source code.

By abstracting away the specifics of the MPI library location, mpijavac makes the development workflow for parallel Java applications significantly smoother, mirroring the convenience provided by wrappers like mpicc for C/C++ or mpif90 for Fortran MPI programs. It ensures that the compiler can locate and link against the MPI bindings required for the program to function correctly in a parallel environment.

CAVEATS

mpijavac requires a compatible Java Development Kit (JDK) to be installed and accessible in the system's PATH. It also relies on the MPI installation having been compiled and installed with Java bindings enabled. If MPI Java bindings are not correctly set up or found, mpijavac may fail or produce errors related to missing classes. While it simplifies compilation, the resulting Java classes still require an MPI runtime environment (e.g., mpirun) for parallel execution.

RUNNING MPI JAVA PROGRAMS

After successfully compiling your Java MPI source files using mpijavac, the resulting .class files are executed using an MPI process launcher, typically mpirun or orterun. The command usually looks like: mpirun -np N java MyMPIProgram, where N is the number of processes, and MyMPIProgram is the main class without the .class extension.

UNDERLYING MECHANISM

mpijavac works by invoking the standard javac executable with additional arguments. Crucially, it automatically adds the path to the MPI Java library (e.g., /path/to/mpi/lib/mpi.jar) to the -classpath option passed to javac. This ensures that all MPI-related classes and interfaces are available during compilation. It typically determines the correct MPI library path based on its own installation location or environment variables.

HISTORY

The Message Passing Interface (MPI) standard, initially defined in the early 1990s, primarily focused on C, C++, and Fortran. As Java gained prominence, efforts were made to create Java bindings for MPI. This led to the development of specifications like MPJ API and eventually official Java bindings within the MPI-2.0 and MPI-3.0 standards. With these bindings, MPI implementations (like Open MPI, MPICH) started providing convenience wrappers such as mpijavac to facilitate the compilation process for Java developers, abstracting away the complexities of classpath management for MPI libraries. Its usage grew with the increasing adoption of Java for high-performance computing tasks.

SEE ALSO

javac(1), java(1), mpirun(1), orterun(1), mpicc(1), mpicxx(1), mpif90(1)

Copied to clipboard