Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] Can we avoid derived datatypes?: Update!
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2012-01-05 08:16:52


On Jan 5, 2012, at 5:35 AM, devendra rai wrote:

> In general, we cannot assume portability of sending a C/C++ struct as a stream of bytes. There must be a promise that data representation on machines involved in the transmission must perform the same data layout.

Correct.

> I have a function that commits the new datatype: Add_New_MPITypes(). This is called just after MPI_Init(...).
> After a few subsequent function calls, I am doing MPI-Send/Receive in another function, which looks like:
>
> void sendMessagetoSlave(void* Payload, int MESSAGETYPE)
> {
> switch (MESSAGETYPE)
> {
> case MSGINSTALLP:
> {
> //Add_MPI_msgInstallP_Type(); /*Was already done in Add_New_MPITypes() */
> msgInstallP InstallPMessage;
> InstallPMessage = *(msgInstallP*)Payload;
> MPI_Ssend(
> (void*)Payload, /* Payload */
> sizeof(msgInstallP), /* size of the payload */
> MPI_MSGINSTALLP, /* MPI Data type */
> InstallPMessage.location, /* location to which the message is being sent */
> MASTERSLAVECONTROLMESSAGE, /* Tag */
> MPI_COMM_WORLD /* Communicator */
> );
> }
> break;
>
> default:
> break;
> }
> }
>
> The linker complains that it does not know MPI_MSGINSTALLP derived datatype. Specifically, the message from the linker is:
>
> "‘MPI_MSGINSTALLP’ was not declared in this scope".

This sounds like another C++ programming error, and not an MPI-specific error.

I'll answer this one, but please know that this list is intended for Open MPI-specific questions, or questions about MPI in general, not general C/C++ programming help.

The issue is where MPI_MSGINSTALLP is prototyped, and where it is "visible". In this case, it sounds like MPI_MSGINSTALLP is declared in another function somewhere else, or is otherwise not either globally visible or visible in the namespace where sendMessagetoSlave() resides. Hence, when the compiler compiles sendMessagetoSlave, it has no idea what the symbol MPI_MSGINSTALLP is. It's like this:

void foo() {
  int i;
}

void bar() {
  // can't use "i" here because "i" lives in foo(), and bar() has
  // no idea what "i" is
}

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/