Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <time.h>
- #define SIZE 1024 * 1024 * 32
- #define DEFAULT_TAG 100
- static int array[SIZE];
- int main(int argc, char** argv) {
- int ierr;
- ierr = MPI_Init(&argc, &argv);
- int currentProcessID;
- int rootProcess = 0;
- int worldSize;
- ierr = MPI_Comm_rank(MPI_COMM_WORLD, ¤tProcessID);
- ierr = MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
- MPI_Request requests[2];
- MPI_Status stats[2];
- int startSize = 1;
- int part = 1024 * 7 + 999;// 1024 * 7;
- if (currentProcessID == 0) {
- MPI_Isend(
- &array[0],
- part,
- MPI_INT,
- 1,
- DEFAULT_TAG,
- MPI_COMM_WORLD,
- &requests[0]
- );
- } else {
- clock_t start, end, end2;
- start = clock();
- MPI_Irecv(
- &array[0],
- part,
- MPI_INT,
- 0,
- DEFAULT_TAG,
- MPI_COMM_WORLD,
- &requests[1]
- );
- MPI_Wait(&requests[1], &stats[1]);
- end = clock();
- printf("Time need to call isend(size = %d bytes) is %f sec \n",
- part * sizeof(int),
- ((double) (end - start)) / CLOCKS_PER_SEC
- );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement