Hello,
I'm using MPI_Isend and MPI_Recv in a loop like in the code I attached
to this mail. In each iteration the code becomes slower and slower.
What is the reason of this behaviour? How can I
prevent this?
Using MPI_Send instead of MPI_ISend I have no problem.
But when I have data with a size greater than 8192 Bytes in this case
MPI_Send hangs.
Thanks for help,
Bernward
#include <mpi.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int
main (int argc, char *argv[])
{
int rank;
int i;
MPI_Request request;
MPI_Status status;
double send[22000];
double recv[22000];
int size = 6000;
time_t *t;
time_t oldtime;
MPI_Init (&argc, &argv);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
oldtime = time(t);
for (i = 0; ; i++)
{
if (rank == 0)
{
MPI_Isend (send, size, MPI_DOUBLE, 1, 1, MPI_COMM_WORLD, &request);
MPI_Recv (recv, size, MPI_DOUBLE, 1, 2, MPI_COMM_WORLD, &status);
}
if (rank == 1)
{
MPI_Isend (send, size, MPI_DOUBLE, 0, 2, MPI_COMM_WORLD, &request);
MPI_Recv (recv, size, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD, &status);
}
if ((rank == 0) && (i > 0) && (i % 1000 == 0)) {
printf("iteration = %i, time = %u\n", i, time(t)-oldtime);
oldtime = time(t);
}
}
MPI_Finalize ();
return 0;
}
|