I
I
ipatin2016-02-27 19:32:29
Java
ipatin, 2016-02-27 19:32:29

Errors when executing the Bcast command from the MPJ Express library?

I'm trying to run the following code:

import mpi.*;

public class Task {

    public static void main(String args[]){

        int root = 0;
        int number = 1;

        MPI.Init(args);
        int size = MPI.COMM_WORLD.Size();
        int rank = MPI.COMM_WORLD.Rank();
        String name = MPI.Get_processor_name();

        MPI.COMM_WORLD.Bcast(number, 0, size, MPI.INT, root);
        System.out.println("Process " + rank + " (" + name + ") got " + number);

        MPI.Finalize();
    }
}

When execution reaches the MPI.COMM_WORLD.Bcast command, the following errors occur:
MPJ Express (0.44) is started in the multicore configuration
java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at runtime.starter.MulticoreStarter$1.run(MulticoreStarter.java:281)
  at java.lang.Thread.run(Thread.java:745)
Caused by: mpi.MPIException: mpi.MPIException: java.lang.ClassCastException: java.lang.Integer cannot be cast to [I
  at mpi.Comm.send(Comm.java:435)
  at mpi.PureIntracomm.MST_Broadcast(PureIntracomm.java:719)
  at mpi.PureIntracomm.Bcast(PureIntracomm.java:604)
  at mpi.Intracomm.Bcast(Intracomm.java:252)
  at Task.main(Task.java:15)
  ... 6 more
Caused by: mpi.MPIException: java.lang.ClassCastException: java.lang.Integer cannot be cast to [I
  at mpi.SimplePackerInt.pack(SimplePackerInt.java:87)
  at mpi.Comm.send(Comm.java:424)
  ... 10 more
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to [I
  at mpi.SimplePackerInt.pack(SimplePackerInt.java:84)
  ... 11 more

What could it be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MamOn, 2016-02-28
@MamOn

Try passing new int[] { number } as the first parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question