Groups | Search | Server Info | Login | Register
Groups > comp.parallel.mpi > #59
| From | "Georg Bisseling" <spam@bisseling.de> |
|---|---|
| Newsgroups | comp.parallel.mpi |
| Subject | Re: MPI_Allreduce on structure of doubles. Portable? |
| Date | 2013-07-07 11:03 +0200 |
| Organization | Me, myself & I |
| Message-ID | <op.wzugsnhtz4pjzz@localhost.localdomain> (permalink) |
| References | <aab1e1fa-a79c-4636-856b-6716a49e88ed@googlegroups.com> |
Am 05.02.2013, 17:30 Uhr, schrieb <jacolagwa@gmail.com>:
> Hello,
>
>
> Consider something like this:
>
> ---
>
> typedef struct TS {
> double a,b,c;
> } S;
>
> ...
> S x,y;
> ...
> MPI_Allreduce(&x, &y, 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
>
> ---
>
> Is the above code completely portable (without using MPI_Type_struct and
> all)?
>
> Thanks!
> JS
>
Since I am 5 months late with the answer this is just for the records, I'm
afraid.
Since any ANSI C compiler must be able to pack doubles tight in arrays it
will pack doubles tight in structs too. And of course we expect the
struct's address to be the same as the first field's. If these assumptions
are not met, then we are not talking about an implementation of ANSI C as
I understood it.
So under all forseeable and sane conditions the code is portable. If not,
then it is a fault in the target of the port. ;-)
BUT: you may start all the hassle of defining your MPI datatypes just to
free your mind when laying out your data structures.
Another way to think about it: when you need binary serialization for you
data structures to store them in files you may consider abusing this
serialization for messages.
ciao
Georg
Back to comp.parallel.mpi | Previous | Next — Previous in thread | Find similar
MPI_Allreduce on structure of doubles. Portable? jacolagwa@gmail.com - 2013-02-05 08:30 -0800 Re: MPI_Allreduce on structure of doubles. Portable? "Georg Bisseling" <spam@bisseling.de> - 2013-07-07 11:03 +0200
csiph-web