Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. int arr[5] = { 15, 30, 11, 20, 5 };
  2.  
  3. float local_sum = 0;
  4. int i;
  5. for (i = 0; i < sizeof(arr) / sizeof(arr[0]); i++) {
  6.   local_sum += arr[i];
  7. }
  8.  
  9. // Reduce all of the local sums into the global sum
  10. float global_sum;
  11. MPI_Reduce(&local_sum, &global_sum, 1, MPI_FLOAT, MPI_SUM, 0, MPI_COMM_WORLD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement