[mpich-discuss] compare two MPI_Datatypes
Rob Latham
robl at mcs.anl.gov
Wed Feb 29 11:27:30 CST 2012
On Tue, Feb 28, 2012 at 02:33:53PM -0600, Wei-keng Liao wrote:
> How do I compare two MPI_Datatypes to see if they are equal?
>
> If MPI_Datatype is intended to be an opaque data type, then
> one should not make a direct comparison, such as "if (type1 == type2)".
> I can see in MPICH, MPI_Datatype is typedef-ed to int.
> So for the primitive data types, such as MPI_FLOAT, this is fine.
> For user defined types, this may not be right.
In addition to the thread Dave posted (and I don't know why I didn't
mention it in that older thread), you can marshal the datatypes, then
hash the marshaled representation. You don't get a 100% guarantee the
two types are the same but depending on your use case that might be
OK.
If you're really interested in pursuing this, I can show you some code
I put together. The type marshalling came from Dave Goodell and Dries
Kimpe based on the libmpitype dataloop library Rob Ross wrote.
==rob
--
Rob Latham
Mathematics and Computer Science Division
Argonne National Lab, IL USA
More information about the mpich-discuss
mailing list