I am totally new to MPJ which is an API for developing MPI based programs in Java. I wrote a simple code as follows:
import mpi.MPI;
import mpi.Status;
public class Send {
public static void main(String[] args) throws Exception
{
MPI.Init(args);
int rank = MPI.COMM_WORLD.Rank();
int size = MPI.COMM_WORLD.Size();
int peer;
int buffer[] = new int[10];
int len = 1;
int dataToBeSent = 99;
int tag = 100;
if(rank == 0)
{
buffer[0] = dataToBeSent;
peer = 1;
MPI.COMM_WORLD.Send(buffer, 0, len, MPI.INT, peer, tag);
System.out.println("process <"+rank+"> sent a msg to process <"+peer+">");
}
else if(rank == 1)
{
peer = 0 ;
Status status = MPI.COMM_WORLD.Recv(buffer, 0, buffer.length, MPI.INT, peer, tag);
System.out.println("process <"+rank+"> recv'ed a msg\n"+ "\tdata <"+buffer[0]+"> \n"+"\tsource <"+status.source+"> \n"+"\ttag<"+status.tag+"> \n"+"\tcount <"+status.count +">");
}
MPI.Finalize();
}
}
When I compile, I get the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: mpi/MPI : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at Send.main(Send.java:7)
Java Result: 1
To resolve this issue, I came to know that both my JDK and JRE versions must be the same. After executing the following commands, I found that they are same and not different:
C:\Users\Dev>javac -version
javac 1.6.0
C:\Users\Dev>java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
In Ubuntu Java 8, I get the following Exception:
Exception in thread "main" mpi.MPIException: Usage: java MPI <myrank> <conf_file> <device_name> conf_file can be, ../conf/xdev.conf <Local>OR http://holly.dsg.port.ac.uk:15000/xdev.conf <Remote>
at mpi.MPI.Init(MPI.java:233)
at mpi.MPI.Init(MPI.java:233) at mpi.MPI.Init(MPI.java:233)
at Send.main(Send.java:7)
Java Result: 1
How do I resolve this issue and get MPI running on my system in Java?