[Mpi-forum] C++ types inaccessible after #281

N.M. Maclaren nmm1 at cam.ac.uk
Thu Jun 28 07:06:28 CDT 2012


I am putting various responses together, for clarity.


On Jun 27 2012, Marc Snir wrote:
>
> The standard does not say much about datatypes that do not correspond to 
> primitive datatypes of the host language. I would suggest that is we 
> define an MPI_Complex type for a language that that does not have a 
> primitive complex, then the implementation will decide how it defines a 
> complex (e.g., two successive doubles) and perform reductions 
> accordingly. A good quality implementation will make C++/C interaction 
> easier.

That assumes that there is only one, and there may not be.  Inter alia,
complex IS a primitive datatype in Fortran, but not in C+, and only
sort-of in C.


On Jun 28 2012, Rolf Rabenseifner wrote:
>
>I would propose to fill the gap by
>- defining in C and Fortran MPI_CPP_BOOL for C++ bool
>- defining in C and Fortran MPI_CPP_COMPLEX,
>  MPI_CPP_DOUBLE_COMPLEX, MPI_CPP_LONG_DOUBLE_COMPLEX,

Yes.  That would fix the problem.

>  if the C/C++ standards do not require that 
>  C "... _Complex" and C++ "Complex<...>" is internally 
>  implemented in an identical way,

They don't.
 
>To be decided by the C/C++ specialists:
> - Is MPI_CPP_..._COMPLEX needed or is MPI_C_..._COMPLEX
>   enough for C++?
> - If MPI_CPP_..._COMPLEX is needed, what are the external 32
>   sizes? 
>   (I expect, it's external32 and therefore same as for C.) 
> - Which is the external32 size for MPI_CPP_BOOL?

The former, certainly - as others have said, the representation
will almost always be the same.  C++ bool is not required to be
one byte, and its representation is unspecified, but will almost
always be one byte and 1.

>To be decided by the whole Forum:
> - Do we make this MPI-2.2 errata to help the C++
>   programmer using the MPI C language binding?

Speaking for my users, yes, please!


>> On Jun 27, 2012, at 3:10 PM, Jeff Squyres wrote:
>>
>> > Don't forget a few points:
>> >
>> > - As Jim pointed out, all MPI datatypes are supposed to be available
>> > in all language bindings. Hence, if we have (for example)
>> > MPI_CXX_COMPLEX, it needs to be available in both C and the various
>> > Fortran bindings.
>> >
>> > - This is not as wonky as it sounds;

With Fortran's C interoperability, it's not at all wonky, and an
increasing number of Fortran+C programs are doing it.

>> > - That being said, handling reductions on MPI_CXX_COMPLEX from
>> > C-based MPI implementations may be a little problematic if the types
>> > are not equivalent between C and C++, for example...

Yes, that's the only issue that needs more than the representation.
In all cases, it may be necessary to call into the owning language to
do the reduction.


Regards,
Nick Maclaren.




More information about the mpi-forum mailing list