Search code examples
javampj-express

MPJ / Cluster configuration can't receive messages from self on another thread


I am building a simple distributed application using MPJ (basically another producer/consumer problem), and I have huge problems receiving data from the same machine when using multiple threads.

Example code:

Thread t = new Thread(new Runnable() {
    @Override
    public void run() {
        int[] buf = new int[2];
        MPI.COMM_WORLD.Recv(buf, 0, 2, MPI.INT, MPI.ANY_SOURCE, 1);
        System.out.println("Got: " + buf[0]);
    }
});
t.start();
Thread.sleep(100);
MPI.COMM_WORLD.Isend(new int[] {1,0}, 0, 2, MPI.INT, MPI.COMM_WORLD.Rank(), 1);
Thread.sleep(100);
t.join();

Idea is simple: One thread listens to all machines and accepts requests that come from a) different machines (this works fine) b) different thread on same machine - this works only in multicore mode.

Is there a way to make this work in cluster configuration?

If this is not possible, is there at least a way how to properly quit the listener thread after some event (termination detection) without busy polling? (Request.Cancel is apparently not implemented in v0.43 -_-)

Thanks


Solution

  • You can try the MPJ Express "Hyrid device"

    The hybrid device is meant for users who plan to execute their parallel Java applications on such cluster of multicore machines. Hybrid device transparently uses both multicore configuration and cluster configuration for intra -node communication and cluster configuration (NIO device only) for inter-node communication, respectively

    Usage: mpjrun.sh -np 4 -dev hybdev HelloWorld