1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
package mpi.group;
import mpjdev.*;
import mpjbuf.*;
import mpi.*;
import java.util.Arrays;
public class Group_self {
public static void main(String args[]) throws Exception {
try {
Group_self a = new Group_self(args);
}
catch (Exception e) {
}
}
public Group_self() {
}
public Group_self(String[] args) throws Exception {
MPI.Init(args);
mpi.Group grp = MPI.COMM_WORLD.Group();
int me = grp.Rank();
int tasks = grp.Size();
int data[] = new int[10];
int rdata[] = new int[10];
int src_dest = 0;
int tag = 10;
for (int i = 0; i < data.length; i++) {
data[i] = i;
}
mpi.Request req = MPI.COMM_SELF.Isend(data, 0, 10, MPI.INT, src_dest, tag);
MPI.COMM_SELF.Recv(rdata, 0, 10, MPI.INT, src_dest, tag);
req.Wait();
for (int i = 0; i < rdata.length; i++) {
if (rdata[i] != i) {
System.out.println("Error at index " + i + ": it is " + data[i]
+ "while " + "we are expecting " + i);
break;
}
}
MPI.COMM_WORLD.Barrier();
if (me == 0)
System.out.println("Group_self TEST COMPLETED");
MPI.Finalize();
}
}
|