Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- #define MCW MPI_COMM_WORLD
- int main(int argc, char* argv[]){
- MPI_Init(&argc, &argv);
- int id, np;
- MPI_Comm_size(MCW, &np);
- MPI_Comm_rank(MCW, &id);
- float a, sum = 0;
- a = np/10.;
- MPI_Reduce(&a, &sum, 1, MPI_FLOAT, MPI_SUM, np-1, MCW);
- printf("id=%d, a=%f\n", id, a);
- if(id == np-1){
- printf("id=%d, np=%d, s=%f\n", id, np, sum);
- }
- MPI_Finalize();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement