File: comm_test.java

package info (click to toggle)
mpj 0.44%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,600 kB
  • ctags: 6,809
  • sloc: java: 49,853; ansic: 2,508; xml: 596; sh: 311; perl: 156; makefile: 26
file content (68 lines) | stat: -rw-r--r-- 1,853 bytes parent folder | download | duplicates (3)
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
package mpi.comm;

import mpi.*;
import java.util.Arrays;

/*
 * things i have done today, 
 * 1. Intracomm class, createGroup method. Intracomm constructor. 
 * created this comm_test class
 * 2. was trying to make this stupid collective 
 * operations work. as their 
 * and the backup should be 20th Jan and get aamirmpj, 
 * the whole code now .... 
 */

public class comm_test {
  /* this test runs with eight processors at the moment. */
  public static void main(String args[]) throws Exception {
    try {
      comm_test a = new comm_test(args);
    }
    catch (Exception e) {
    }
  }

  public comm_test() {
  }

  public comm_test(String[] args) throws Exception {

    MPI.Init(args);
    Group grp1 = MPI.COMM_WORLD.Group();
    Comm myComm;
    int[] incl1 = { 0, 2, 4, 6 };
    int rank = MPI.COMM_WORLD.Rank();
    int size = MPI.COMM_WORLD.Size();

    if (size < 8) {
      if (rank == 0)
	System.out.println("comm->comm_test: RUNS WITH 8 processes atleast");

      MPI.COMM_WORLD.Barrier();
      MPI.Finalize();
      return;
    }

    Group grp2 = grp1.Incl(incl1);
    // System.out.println("world<"+rank+">,newComm<"+grp2.Rank()+">");

    /*
     * i've to write this if statement because group methods return null at the
     * moment, which results in nullpointer exception. this has to be fixed by
     * returning EMPTY and other relevant flags
     */

    // if( rank== 0 || rank==2|| rank==4 || rank==6 ) {
    // System.out.println("rank "+rank+" is within");
    myComm = MPI.COMM_WORLD.Create(grp2);
    // }
    // if(myComm == null){
    // System.out.println("rank "+rank+" myComm rank = "+myComm.Rank());
    // }
    MPI.COMM_WORLD.Barrier();
    if (rank == 0)
      System.out.println("comm_test TEST COMPLETE");
    MPI.Finalize();
  }
}