Hi, I have built openmpi-1.9a1r27380 with Java support and try some small programs. When I try to scatter the columns of a matrix, I don't get the expected results.
tyr java 106 mpijavac ColumnMain.java tyr java 107 mpiexec -np 6 java ColumnMain matrix: 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 24.00 Column of process 0 Column of process 4 0.00 0.00 0.00 0.00 Column of process 1 Column of process 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Column of process 3 0.00 0.00 0.00 0.00 Column of process 2 NaN NaN 0.00 0.00 NaN 0.00 NaN 0.00 I use the following program. import mpi.*; public class ColumnMain { static final int P = 4; /* # of rows */ static final int Q = 6; /* # of columns */ static final int NUM_ELEM_PER_LINE = 6; /* to print a vector */ public static void main (String args[]) throws MPIException { int ntasks, /* number of parallel tasks */ mytid, /* my task id */ i, j, /* loop variables */ tmp; /* temporary value */ double matrix[][], column[]; Datatype column_t; /* strided vector */ MPI.Init (args); matrix = new double[P][Q]; column = new double[P]; mytid = MPI.COMM_WORLD.Rank (); ntasks = MPI.COMM_WORLD.Size (); /* check that we have the correct number of processes in our * universe */ if (mytid == 0) { if (ntasks != Q) { System.err.println ("\n\nI need exactly " + Q + " processes.\n\n" + "Usage:\n" + " mpiexec -np " + Q + " java <program name>\n"); } } if (ntasks != Q) { MPI.Finalize (); System.exit (0); } /* Build the new type for a strided vector. */ column_t = Datatype.Vector (P, 1, Q, MPI.DOUBLE); column_t.Commit (); if (mytid == 0) { tmp = 1; for (i = 0; i < P; ++i) /* initialize matrix */ { for (j = 0; j < Q; ++j) { matrix[i][j] = tmp++; } } System.out.println ("\nmatrix:\n"); /* print matrix */ for (i = 0; i < P; ++i) { for (j = 0; j < Q; ++j) { System.out.printf ("%10.2f", matrix[i][j]); } System.out.println (); } System.out.println (); } MPI.COMM_WORLD.Scatter (matrix, 0, 1, column_t, column, 0, P, MPI.DOUBLE, 0); /* Each process prints its column. The output will probably * intermingle on the screen so that you must use * "-output-filename" in Open MPI. */ System.out.println ("\nColumn of process " + mytid + "\n"); for (i = 0; i < P; ++i) { if (((i + 1) % NUM_ELEM_PER_LINE) == 0) { System.out.printf ("%10.2f\n", column[i]); } else { System.out.printf ("%10.2f", column[i]); } } System.out.println (); column_t.finalize (); MPI.Finalize(); } } Does anybody know if something is wrong with my program or if I can't use a strided vector in Java (even if it is available in the API) or if it is a problem of openmpi-1.9a1r27380? Thank you very much for any help in advance. Kind regards Siegmar