hi,

I met a question recently when I tested the MPI_send and MPI_Recv
functions.  When I run the following codes, the  processes hanged and I
found there was not data transmission in my network at all.

BTW: I finished this test on two X86-64 computers with 16GB memory and
installed Linux.

 1 #include <stdio.h>
 2 #include <mpi.h>
 3 #include <stdlib.h>
 4 #include <unistd.h>
 5
 6
 7 int main(int argc, char** argv)
 8 {
 9       int localID;
 10     int numOfPros;
 11     size_t Gsize = (size_t)2 * 1024 * 1024 * 1024;
 12
 13     char* g = (char*)malloc(Gsize);
 14
 15     MPI_Init(&argc, &argv);
 16     MPI_Comm_size(MPI_COMM_WORLD, &numOfPros);
 17     MPI_Comm_rank(MPI_COMM_WORLD, &localID);
 18
 19     MPI_Datatype MPI_Type_lkchar;
 20     MPI_Type_contiguous(2048, MPI_BYTE, &MPI_Type_lkchar);
 21     MPI_Type_commit(&MPI_Type_lkchar);
 22
 23     if (localID == 0)
 24     {
 25         MPI_Send(g, 1024*1024, MPI_Type_lkchar, 1, 1, MPI_COMM_WORLD);
 26     }
 27
 28     if (localID != 0)
 29     {
 30         MPI_Status status;
 31         MPI_Recv(g, 1024*1024, MPI_Type_lkchar, 0, 1, \
 32                 MPI_COMM_WORLD, &status);
 33     }
 34
 35     MPI_Finalize();
 36
 37     return 0;
 38 }

Thanks
Xianjun

Reply via email to