1

When using derived types in MPI for communication of data which is not contiguous in memory, the sequence of datatype-displacement pairs defining the derived type seems to be assumed to be the same for each process, but I cannot find any guarantee of this being the case.

In C, suppose I had initialized on every process the struct

struct my_struct
{
    char foo;
    char bar;
};

Suppose that this data is organized on the root process (taken to be process zero) as

xxxx00000000xxxx00000000 - Process 0 (root process)

I would say the derived type is the sequence {(char,0),(char,12)}. When I build the derived type using MPI all that maters is this sequence and the initial location in memory of the data I am sending. However on another process, say process 1, what prevents the structure from initially being allocated as

xxxx0000xxxx000000000000 - Process 1 (target process)

When the derived datatype is sent by the root process, since the only information being used is the user defined derived type sequence, the data sent would be faulty, since the data structures were allocated in different ways.

Is this situation a common problem? I have seen derived types as being considered unportable for related reasons to this. What are the best practices for safely and efficiently transmitting non-contiguous data? Does one simply assume that the derived type sequence is guaranteed to be the same across all processes and nodes, and then "manually" check that all data is in fact transmitted correctly, or is there a better method?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.