patflick / mxx

C++11 Message Passing
http://patflick.github.io/mxx
Apache License 2.0
74 stars 17 forks source link

Creating a struct datatype for use in collective? #21

Open thvasilo opened 5 years ago

thvasilo commented 5 years ago

Hello,

I'm wondering what's the correct way to define a custom struct datatype to be later used in a collective.

I'm my case I have structs defined as:

MyStruct{
float a;
float b;
int c;
};

that I would like to collect to the root using gatherv.

I know how to do this using plain MPI, but I'm wondering what's the process for mxx in order to avoid the error

static assertion failed: Type `T` is not a `trivial` type and is thus not supported for mxx send/recv operations. This type needs one of the following to be supported as trivial datatype: specialized build_datatype<T>, a member function `datatype`, or global function `make_datatype(Layout& l, T&)`

The error describes my options but I haven't been able to find examples of how to make mxx aware of custom datatypes.