Facebook
From Wet Peccary, 6 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 300
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<mpi.h>
  4. int main(int argc, char **argv)
  5. {
  6.         int nr, n, i, liczba;
  7.         MPI_Status st;
  8.  
  9.         MPI_Init(&argc, &argv);
  10.         MPI_Comm_size(MPI_COMM_WORLD, &n);
  11.         MPI_Comm_rank(MPI_COMM_WORLD, &nr);
  12.         if (nr == 0)
  13.         {
  14.                 liczba = atoi(argv[1]);
  15.                 MPI_Bcast(&liczba, 1, MPI_INT, 0, MPI_COMM_WORLD);
  16.         }
  17.         else
  18.         {
  19.                 MPI_Bcast(&liczba, 1, MPI_INT, 0, MPI_COMM_WORLD);
  20.                 printf("moj nr to %d, odebralem %d \n", nr, liczba);   
  21.         }
  22.         MPI_Finalize();
  23.         return 0;
  24. }