Trying to run the following code -

import mpi.*; import java.util.Random; public class Main { public static void main(String[] args) { MPI.Init(args); int rank = MPI.COMM_WORLD.Rank(); int size = MPI.COMM_WORLD.Size(); int[][] sendbuf = { {1, 2, 3, 4}, {1, 10, 3, 3}, {2, 2, 2, 2}, {1, 1, 1, 1} }; int[] recvbuf = new int[4]; if (rank == 0) { MPI.COMM_WORLD.Scatter(sendbuf, 4, 4, MPI.INT, recvbuf, 4, 4, MPI.INT, 0); System.out.println("Rank = " + rank + " Result: " + recvbuf[0] + " " + recvbuf[1] + " " + recvbuf[2] + " " + recvbuf[3]); } MPI.Finalize(); } } 

When the execution reaches the MPI.COMM_WORLD.Scatter command, errors are output:

 Caused by: mpi.MPIException: mpi.MPIException: java.lang.ClassCastException: [[I cannot be cast to [I at mpi.Comm.send(Comm.java:435) at mpi.PureIntracomm.MST_Scatter(PureIntracomm.java:1096) at mpi.PureIntracomm.Scatter(PureIntracomm.java:1066) at mpi.Intracomm.Scatter(Intracomm.java:420) at Main.main(Main.java:24) ... 6 more Caused by: mpi.MPIException: java.lang.ClassCastException: [[I 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: [[I cannot be cast to [I at mpi.SimplePackerInt.pack(SimplePackerInt.java:84) ... 11 more 
  • where does the library come from? what platform do you run on? - Mikhail Vaysman
  • When you call, you specify the type MPI.INT , and you pass an array of arrays int . - Mikhail Vaysman
  • this is MPI.INT - int; - Dossanov
  • compare int, int [] and int [] [] - see that these are different types? - Mikhail Vaysman
  • it turns out I can not use a two-dimensional array in MPI ?? - Dossanov

0