daily pastebin goal
65%
SHARE
TWEET

aaa

a guest Mar 23rd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "mpi.h"
  2. #include <stdio.h>
  3.  
  4. int main(){
  5.     int world_rank;
  6.     MPI_Comm_Rank(MPI_COMM_WORLD,&world_rank);
  7.     int arr[][]={1,2,3;2,4,5;1,3,2};
  8.     int arr2[][]={2,4,1;2,5,6;3,5,7};
  9.     int sum[3][3];
  10.     if(world_rank == 0){
  11.         for(int i=0;i<2;i++)
  12.             for(int j=0;j<3;j++)
  13.                 sum[i][j]=arr[i][j]+arr2[i][j];
  14.         MPI_Send(&sum,MPI_INT,1,0,MPI_COMM_WOLRD);     
  15.        
  16.     }
  17.     if(world_rank == 1){
  18.         MPI_Recv(&sum,1,MPI_INT,0,0,MPI_COMM_WORLD,MPI_STATUS_IGNORE);
  19.         for(int i=2;i<3;i++)
  20.             for(int j=0;j<3;j++)
  21.                 sum[i][j]=arr[i][j]+arr2[i][j];
  22.    
  23.     }
  24.     MPI_FINALIZE();
  25.     return 0;
  26.  
  27.  
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top