Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <mpi.h>
  3.  
  4. int main(int argc, char **argv){
  5.         int myrank;
  6.         int comm_size;
  7.         int table1[] = {1, 2, 3, 4, 5, 6, 7,8, 9, 10};
  8.         int table2[] = {11, 12, 13, 14, 15, 16,17,18,19,20};
  9.         int min = 0;
  10.         int max = 0;
  11.         int i = 0;
  12.         MPI_Init(&argc, &argv);
  13.         MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
  14.         MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
  15.         if (myrank == 1){
  16.                 max = 0;
  17.                 min = 99999;
  18.                 for (i = 0; i<10; i++){
  19.                         if (max < table1[i]){ max = table1[i];}
  20.                         if (min > table1[i]){ min = table1[i];}
  21.                         printf("Max: %d, min: %d", max, min);
  22.                 }
  23.         }
  24.         MPI_Finalize();
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement