Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] How to "guess" the incoming data type ?
From: Eugene Loh (eugene.loh_at_[hidden])
Date: 2010-04-25 23:38:54

Sylvestre Ledru wrote:

>I am currently extending an application with MPI capabilities.
>This high-level application allows users to use dynamic types. Therefor,
>on the slaves, I have no way to know what the master will send me.
>Therefor, in the slave side, I need to "guess" what I am receiving.
>For example, I am using contiguous data on the master defined this way:
>MPI_Datatype matrixOfDouble;
>MPI_Type_contiguous(size, MPI_DOUBLE, &matrixOfDouble);
>sent this way:
>double A[] = {1,3,3,2,3,4};
>MPI_Send(&A, 1, matrixOfDouble, i, TAG, MPI_COMM_WORLD);
>On the slave, in my example, since I know I am going to receive a
>matrixOfDouble, I can do the following:
>MPI_Get_elements( &stat, matrixOfDouble, &count);
>double BRecv[count];
>MPI_Recv(BRecv, BUFSIZE, matrixOfDouble, i, TAG, MPI_COMM_WORLD, &stat)
>I would like to know if (and how) it is possible on the slave side to
>know that the received type is matrixOfDouble ?
>If it is not possible, is there any other way in MPI ?
>(I would like to avoid a extra master=> slave message to send the type).
Could you encode it into the tag? Or, append a data type to the front
of each message? Basically, you need to add this information somehow.