Openmpi perform Java MPI jobs
Next blog (set up open MPI cluster environment) Install java environment
sudo yum install-y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
Compile and install Openmpi
$./configure--prefix=/opt/openmpi--enable-mpi-java
$ make
$ sudo make install
* Note: To use the "–enable-mpi-java" option * Install validation
After the installation is complete, check that the/opt/openmpi/bin/mpijavac file exists and that the installation is successful if the file exists. performing Java MPI jobs Hello.java File
Import java.net.InetAddress;
Import mpi.*;
Class Hello {
static public void main (string[] args) throws Exception {
MPI. Init (args);
String hostname = Inetaddress.getlocalhost (). GetHostName ();
int myrank = MPI.COMM_WORLD.getRank ();
int size = MPI.COMM_WORLD.getSize ();
System.out.println ("<" + hostname + "": "+" Hello World from Rank "+ Myrank +" of "+ size);
Mpi. Finalize ();
}
Hosts file
Test1 slots=2
test2 slots=2
compiling Java code
$ Mpijavac Hello.java
running Java Classes
$ mpiexec--hostfile hosts-np 4 java Hello
<test1>: Hello World from rank 0 of 4
<test1>: Hello wor LD from rank 1 of 4
<test2>: Hello World from rank 2 of 4
<test2>: Hello World from rank 3 of 4
Reprint please link the form to indicate this article link
This article link: http://blog.csdn.net/kongxx/article/details/52237416