I am digging through documentation but I still can't figure out how to use other data types than array of ints. Is there any way to send data other than array of ints? The below code works fine if I use an array just of integers. I tried replacing MPI.INT with MPI.OBJECT but that doesn't work as well. Here's an example of sending some data to all procs except root.
import mpi.*;
public class MPIHello {
static class Node {
private static int data;
public Node(int d) {
this.data = d;
}
public static int getData() {
return data;
}
};
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MPI.Init(args);
int me = MPI.COMM_WORLD.Rank();
int size = MPI.COMM_WORLD.Size();
Node[] Buf = new Node[1];
if (me == 0)
{
for (int i=1; i<size; i++)
{
Buf[0] = new Node(13);
MPI.COMM_WORLD.Send(Buf, 0, Buf.length, MPI.INT, i, 0);
}
}
else
{
MPI.COMM_WORLD.Recv(Buf, 0, Buf.length, MPI.INT, 0, 0);
System.out.println(Buf[0].getData());
}
MPI.Finalize();
}
}
1) Tried sending Object[] arr = new Object[1]; that won't work as well