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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
package mpi.group;
import mpjdev.*;
import mpjbuf.*;
import mpi.*;
import java.util.Arrays;
public class Group_incl {
public static void main(String args[]) throws Exception {
try {
Group_incl a = new Group_incl(args);
}
catch (Exception e) {
}
}
public Group_incl() {
}
public Group_incl(String[] args) throws Exception {
MPI.Init(args);
mpi.Group grp = MPI.COMM_WORLD.Group();
int me = grp.Rank();
int tasks = grp.Size();
if (tasks < 8) {
if (me == 0)
System.out.println("group->Group_incl: MUST RUN with 8 tasks");
MPI.COMM_WORLD.Barrier();
MPI.Finalize();
return;
}
int[] incl1 = { 4, 0, 5 };
mpi.Group ngrp = grp.Incl(incl1);
int new_me = ngrp.Rank();
if (me == 0) {
if (new_me != 0 && new_me != 1 && new_me != 2) {
System.out.println("Error(1): ");
}
} else if (me == 1) {
if (new_me != -1) {
System.out
.println("Error(2): This process <" + me + ">is not in the new "
+ "group and its rank should be -1, instead it is <" + new_me
+ ">");
}
} else if (me == 2) {
if (new_me != -1) {
System.out
.println("Error(3): This process <" + me + ">is not in the new "
+ "group and its rank should be -1, instead it is <" + new_me
+ ">");
}
} else if (me == 3) {
if (new_me != -1) {
System.out
.println("Error(4): This process <" + me + ">is not in the new "
+ "group and its rank should be -1, instead it is <" + new_me
+ ">");
}
} else if (me == 4) {
if (new_me != 0 && new_me != 1 && new_me != 2) {
System.out.println("Error(5): ");
}
} else if (me == 5) {
if (new_me != 0 && new_me != 1 && new_me != 2) {
System.out.println("Error(6): ");
}
} else if (me == 6) {
if (new_me != -1) {
System.out
.println("Error(7): This process <" + me + ">is not in the new "
+ "group and its rank should be -1, instead it is <" + new_me
+ ">");
}
} else if (me == 7) {
if (new_me != -1) {
System.out
.println("Error(8): This process <" + me + ">is not in the new "
+ "group and its rank should be -1, instead it is <" + new_me
+ ">");
}
}
MPI.COMM_WORLD.Barrier();
if (me == 0)
System.out.println("Group_incl TEST COMPLETED");
MPI.Finalize();
}
}
|