⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group_incl.java

📁 MPI for java for Distributed Programming
💻 JAVA
字号:
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{
  }

  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();
  }
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -