Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include "mpi.h"
- #include <iostream>
- using namespace std;
- int main(int argc, char *argv[]) {
- int n, rank, size, i;
- double a[10];
- MPI::Init(argc, argv);
- size = MPI::COMM_WORLD.Get_size();
- rank = MPI::COMM_WORLD.Get_rank();
- MPI::Status status;
- MPI::Request zahtjev;
- if (rank == 0)
- {
- for (i=0; i<10; i++)
- {
- a[i]=sqrt(i);
- }
- MPI::COMM_WORLD.Send(a, 10, MPI::DOUBLE, 1, 17);
- MPI::COMM_WORLD.Recv(a,10, MPI::DOUBLE, 2, 17,status);
- cout << rank << ":poruka " << status.Get_tag()<< endl;
- cout << rank << ":je stigla od ranga " << status.Get_source() << endl;
- }
- else if(rank == 1)
- {
- MPI::COMM_WORLD.Recv(a,10, MPI::DOUBLE, 0, 17, status);
- MPI::COMM_WORLD.Send(a, 10, MPI::DOUBLE, 2, 17);
- cout << rank << ":poruka " << status.Get_tag()<< endl;
- cout << rank << ":je stigla od ranga " << status.Get_source() << endl;
- }
- else
- {
- MPI::COMM_WORLD.Send(a, 10, MPI::DOUBLE, 0, 17);
- MPI::COMM_WORLD.Recv(a, 10, MPI::DOUBLE, 1, 17, status);
- cout << rank << ":poruka " << status.Get_tag()<< endl;
- cout << rank << ":je stigla od ranga " << status.Get_source() << endl;
- }
- MPI::Finalize();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement