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

📄 syncbug.java

📁 MPI for java for Distributed Programming
💻 JAVA
字号:
import mpi.*;class syncbug {  static public void main(String[] args) throws MPIException {        int me,tasks,i;    int SIZE = 4;    int [] s = new int[SIZE];    int [] r = new int[SIZE];    int tag = 87;        MPI.Init(args);    me = MPI.COMM_WORLD.Rank();    tasks = MPI.COMM_WORLD.Size();    Request req [] = new Request[SIZE];    if(me == 0) {	    	for(i = 0 ; i<SIZE ; i++) {               System.out.println("process "+me +"sending to 1");			  req[i] = MPI.COMM_WORLD.Issend(s, 0, SIZE, MPI.INT,1, tag+i);          System.out.println("process "+me +"sent to 1");			}	for(i=0 ; i<SIZE ; i++) {          System.out.println("process "+me +"receving 1");			  MPI.COMM_WORLD.Recv(r, 0, SIZE, MPI.INT,1,tag+i ); 	              System.out.println("process "+me +"received 1");			}		for(i=0 ; i<SIZE ; i++) {    	  req[i].Wait();		}	    }else { 	    	for(i=0 ; i<SIZE ; i++) {              System.out.println("process "+me +"sending 0");			  req[i] = MPI.COMM_WORLD.Issend(s,0,SIZE,MPI.INT,0,tag+i); 	              System.out.println("process "+me +" sent 0");			}		for(i=0 ; i<SIZE ; i++) {              System.out.println("process "+me +"receiving 0");			  MPI.COMM_WORLD.Recv(s,0,SIZE,MPI.INT,0,tag+i); 	              System.out.println("process "+me +"received 0");			}		for(i=0 ; i<SIZE ; i++) {    	  req[i].Wait();			}	    }    System.out.println("process "+me+" finished");   MPI.COMM_WORLD.Barrier();        MPI.Finalize();  }}

⌨️ 快捷键说明

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