Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- int main(int argc, char** argv)
- {
- int myid, n = 2, *rbuf = 0, *sbuf = 0 ;
- int size;
- MPI_Comm comm = MPI_COMM_WORLD;
- MPI_Init(&argc, &argv);
- MPI_Comm_size(comm, &size);
- MPI_Comm_rank(comm, &myid);
- sbuf = new int [size * n];
- rbuf = new int [size * n];
- for(int i = 0; i < size * n; i++)
- {
- sbuf[i] = myid;
- }
- cout << "Process " << myid << " | ";
- for(int i = 0; i < size * n; i++)
- cout << " " << sbuf[i];
- MPI_Alltoall(sbuf, n, MPI_INT, rbuf, n, MPI_INT, comm);
- cout << " " << "Process " << myid << " | ";
- for(int i = 0; i < size * n; i++)
- cout << " " << rbuf[i];
- cout << endl;
- MPI_Finalize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement