Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/Fortran predefined datatypes for C++ types #340

Closed
mpiforumbot opened this issue Jul 24, 2016 · 20 comments
Closed

C/Fortran predefined datatypes for C++ types #340

mpiforumbot opened this issue Jul 24, 2016 · 20 comments

Comments

@mpiforumbot
Copy link
Collaborator

mpiforumbot commented Jul 24, 2016

Originally by RolfRabenseifner on 2012-06-30 17:51:39 -0500


Description

-Part 1:*

MPI-2.2 page 517 lines 17-22 defines "C++-Only Named Predefined Datatypes" for the C++ types bool and complex<float>, complex<double>, complex<long double>.

MPI-2.2 language interoperability requires on page 503 line 8:

"All predefined datatypes can be used in datatype constructors in any language."

The MPI-2.2 is inconsistent, because it did not provide C and Fortran named predefined
datatypes for these C++ types.

This should be corrected with this MPI-2.2 errata.

It cannot be corrected through MPI-3.0 because it is expected that the C++ interface is removed in MPI-3.0 based on ticket #281 (Removal of C++).

-Part 2:*

MPI_C_COMPLEX was missing in the list of predefined datatypes for reduction operations.

-Part 3:*

The comments to this ticket showed that there is an additional problem with
the C++ types
Complex<float>, Complex<double>, and Complex<long double>,
and their MPI datatype handles defined in MPI-2.0 in 1997:

Complex<...> does not exist. The standardized C++ type is std::complex<...>.

History

Extended Scope

None.

Proposed Solution

This solution has three parts:

  • Part 1 is about the new CXX datatype handles
  • Part 2 adds the missing MPI_C_COMPLEX to the "Complex" reduction group.
  • Part 3 changes C++ Complex<...> into std::complex<...>

-MPI-2.2 Section 3.2.2, page 29 line 11 reads*

See Section 16.3.10 for information on interlanguage communication
with these types.

-but should read* (due to Part 1+3)

All predefined datatype handles are available in all language bindings.
See Section__s 16.3.6 and__ 16.3.10 on page 503 and 510 for information on interlanguage communication
with these types.
If there is an accomanying C++ compiler then the datatypes in Table 3.4 are also
supported in C and Fortran.

||=MPI datatype =||=C++ datatypes =||
||MPI_CXX_BOOL ||bool ||
||MPI_CXX_FLOAT_COMPLEX ||std::complex ||
||MPI_CXX_DOUBLE_COMPLEX ||std::complex ||
||MPI_CXX_LONG_DOUBLE_COMPLEX ||std::complex ||

Table 3.4: Predefined MPI datatypes corresponding to C++ datatypes

-MPI-2.2 Section 5.9.1, page 165, line 46 reads*

||Logical: ||MPI_LOGICAL, MPI_C_BOOL ||

-but should read* (due to Part 1)

||Logical: ||MPI_LOGICAL, MPI_C_BOOL__,__ ||
|| ||MPI_CXX_BOOL ||

-MPI-2.2 Section 5.9.1, page 165, lines 47 - page 166, line 7 read*

||Complex: ||MPI_COMPLEX, ||
|| ||MPI_C_FLOAT_COMPLEX, ||
|| ||MPI_C_DOUBLE_COMPLEX, ||
|| ||MPI_C_LONG_DOUBLE_COMPLEX, ||
|| ||and handles returned from ||
|| ||MPI_TYPE_CREATE_F90_COMPLEX, ||
|| ||and if available: MPI_DOUBLE_COMPLEX, ||
|| ||MPI_COMPLEX4, MPI_COMPLEX8, ||
|| ||MPI_COMPLEX16, MPI_COMPLEX32 ||

-but should read* (due to Part 1+2)

||Complex: ||MPI_COMPLEX, MPI_C_COMPLEX, ||
|| ||MPI_C_FLOAT_COMPLEX (as synonym), ||
|| ||MPI_C_DOUBLE_COMPLEX, ||
|| ||MPI_C_LONG_DOUBLE_COMPLEX, ||
|| ||MPI_CXX_FLOAT_COMPLEX, ||
|| ||MPI_CXX_DOUBLE_COMPLEX, ||
|| ||MPI_CXX_LONG_DOUBLE_COMPLEX, ||
|| ||and handles returned from ||
|| ||MPI_TYPE_CREATE_F90_COMPLEX, ||
|| ||and if available: MPI_DOUBLE_COMPLEX, ||
|| ||MPI_COMPLEX4, MPI_COMPLEX8, ||
|| ||MPI_COMPLEX16, MPI_COMPLEX32 ||

-MPI-2.2 Section 16.1.6, page 472 line 3,19-21 read*

||=MPI datatypes =||=C datatype =||=C++ types =||
||... ||... ||... ||
||MPI::COMPLEX || ||Complex ||
||MPI::DOUBLE_COMPLEX || ||Complex ||
||MPI::LONG_DOUBLE_COMPLEX || ||Complex ||

-but should read* (due to Part 3)

||=MPI datatypes =||=C datatype =||=C++ types =||
||... ||... ||... ||
||MPI::COMPLEX || ||std::cComplex ||
||MPI::DOUBLE_COMPLEX || ||std::cComplex ||
||MPI::LONG_DOUBLE_COMPLEX || ||std::cComplex ||

-MPI-2.2, Section 13.5.2, page 433, in the right column, the following lines should be added:* (due to Part 1)

||=C++ Types =||= Length=||
||MPI_CXX_BOOL || 1||
||MPI_CXX_FLOAT_COMPLEX || 2_4||
||MPI_CXX_DOUBLE_COMPLEX || 2_8||
||MPI_CXX_LONG_DOUBLE_COMPLEX || 2*16||

-MPI-2.2 Annex A.1.1, page 517 line 17-22 read*

||# C++-Only Named Predefined Datatypes||# C++ types||
||C++ type: MPI::Datatype || ||
||MPI::BOOL ||bool ||
||MPI::COMPLEX ||Complex ||
||MPI::DOUBLE_COMPLEX ||Complex ||
||MPI::LONG_DOUBLE_COMPLEX ||Complex ||

-but should read* (due to Part 1+3)

||||# C++-Only Named Predefined Datatypes__^1^||# C++ types^1^||
||__C type: MPI_Datatype
||C++ type: MPI::Datatype || ||
||Fortran type: INTEGER || || ||
||MPI_CXX_BOOL ||MPI::BOOL ||bool ||
||MPI_CXX_FLOAT_COMPLEX ||MPI::COMPLEX ||std::cComplex ||
||MPI_CXX_DOUBLE_COMPLEX ||MPI::DOUBLE_COMPLEX ||std::cComplex ||
||MPI_CXX_LONG_DOUBLE_COMPLEX ||MPI::LONG_DOUBLE_COMPLEX ||std::cComplex ||
||||||^1^ If an accompanying C++ compiler is missing, then the MPI datatypes in this table are not defined. ||

-With #281 (Removal of C++), only the middle C++ predefined datatype column is removed, and not the whole table.*

Alternative Solutions

None.

Impact on Implementations

The C and Fortran representations
MPI_CXX_BOOL, MPI_CXX_FLOAT_COMPLEX, MPI_CXX_DOUBLE_COMPLEX, MPI_CXX_LONG_DOUBLE_COMPLEX
of the existing C++ datatype handles
MPI::BOOL, MPI::COMPLEX, MPI::DOUBLE_COMPLEX, MPI::LONG_DOUBLE_COMPLEX must be implemented. They must be added to the reduction datatypes and to the external32 datatypes.
The existing MPI_C_COMPLEX must be also added to the reduction datatypes.
As MPI-2.2 errata, it must be also implemented for MPI-2.2 libraries.

MPI::COMPLEX, MPI::DOUBLE_COMPLEX, MPI::LONG_DOUBLE_COMPLEX were related to the non-standard
C++ types Complex<...>. They now correspond to the standardized C++ types
std::complex<float>, std::complex<double>, and std::complex<long double>.

Impact on Applications / Users

None.

Entry for the Change Log

Sections 3.2.2, 5.9.2, 13.5.2 Table 13.2, 16.1.16 Table 16.1, and Annex A.1.1
on pages 27, 164, 433, 472 and 513 and[[BR]]
MPI-2.2 Sections 3.2.2, 5.9.2, 13.5.2 Table 13.2, and Annex A.1.1 on pages 27, 164, 433, and 513.[[BR]]
MPI-2.2 errata: New named predefined datatypes MPI_CXX_BOOL, MPI_CXX_FLOAT_COMPLEX, MPI_CXX_DOUBLE_COMPLEX, and MPI_CXX_LONG_DOUBLE_COMPLEX in C and Fortran
for the C++ types bool, std::complex<float>, std::complex<double>,
and std::complex<long double>, corresponding to the deprecated C++ predefined datatypes
MPI::BOOL, MPI::COMPLEX, MPI::DOUBLE_COMPLEX, and MPI::LONG_DOUBLE_COMPLEX,[[BR]]
which are removed in MPI-3.0.[[BR]]
The non-standard C++ types Complex<...> are substituted by the standard types std::complex<...>.

-_The references "16.1.16 Table 16.1 on page 472" will be removed if ticket #281 passes.__[[BR]]
_The text "which are removed in MPI-3.0" will be removed if ticket #281 does not pass.*

Section 5.9.2 on page 164 and
MPI-2.2 Section 5.9.2, page 165, line 47.[[BR]]
MPI-2.2 errata: MPI_C_COMPLEX is added to the "Complex" reduction group.

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-06-30 18:50:18 -0500


Corrections in

  • Chapter 5, Collective Communication, 5.9.2 Predefined Reduction Ooperations
  • Chapter 13, IO, 13.5.2, Table 13.2
  • Annex A.1.1

@mpiforumbot
Copy link
Collaborator Author

Originally by jedbrown on 2012-06-30 18:59:53 -0500


Why the uppercase C in Complex? Are these intended to work with std::complex<...> or with some other implied complex type (that happens to have the same layout..)? I think it would be better to say std::complex (including the namespace) when that is the intended meaning.

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-01 02:38:06 -0500


Is your question about the family MPI_C_COMPLEX, MPI_C_FLOAT_COMPLEX, MPI_C_DOUBLE_COMPLEX,
MPI_C_LONG_DOUBLE_COMPLEX?

This is part of the existing MPI-2.2, see p516 lines 39-42.

The C is introduced that it is distiguisched to MPI_COMPLEX which refers to Fortran COMPLEX, see p517 line 8.

Side effect of your question:
In the table on page 165, MPI_C_COMPLEX is missing.
I added it to the table in the solutions section, and added an additional change-log entry.

@mpiforumbot
Copy link
Collaborator Author

Originally by jedbrown on 2012-07-01 03:49:16 -0500


C99 defines the new keyword _Complex (and the header <complex.h> which contains #define complex _Complex so that new user code does not need to see _Complex). MPI-2.2 Example 5.20 contains typedef struct { double real,imag; } Complex;, a new MPI_Datatype, and a new MPI_Op. I have no problem with either of these, I'm only concerned with C++.

In MPI-2.2 Table 16.1 and page 517 lines 20-22, note that MPI::COMPLEX is supposed to represent the C++ datatype Complex<float>. But C++ does not provide any type called Complex, it is called std::complex (namespaced and lowercase). I believe the use of uppercase there in MPI-2.2 was erroneous. I think the namespace should also be included to disambiguate, but lowercase 'c' is necessary.

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-01 04:22:52 -0500


Jed's proposal:
Change C++ types in MPI-2.2 p517:20-22 and p472:19-21

  • Complex<float> into std::complex
  • Complex<double> into std::complex
  • Complex<long double> into std::complex

Remark: The C++ Complex<..> types were

  • introduced in MPI-2.0 p276:21-23 in July 1997,
  • and unchanged in MPI-2.1 p454:19-21 and Annex p495:4-6 in June 2008,
  • and unchanged in MPI-2.2 p517:20-22 and Annex p472:19-21 in Sep. 2009.

Before changing this, I would like to know,

  • what was meant with C++ Complex in July 1997?
  • has Complex<...> still a meaning?
  • are both types identical, i.e.have same size, extent, and alignment?
  • should we write both into the table, i.e.,
    Complex<...>, std::complex<...>?

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-01 05:24:29 -0500


Nick M. Maclaren wrote in an email:

On a related matter, there is no occurrence of "Complex" in C++11 except
as an example of a user-defined class. MPI should use std::complex to
refer to C++ complex (i.e. I agree with Jed Brown).

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-01 07:07:41 -0500


Impact on Implementations added.

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-01 09:20:17 -0500


Open question:

How is the extent and the alignment of MPI_CXX_BOOL, MPI_CXX_FLOAT_COMPLEX, MPI_CXX_DOUBLE_COMPLEX, and MPI_CXX_LONG_DOUBLE_COMPLEX defined, if there is no accompanying C++ compiler?

These are the only 4 types in Table 16.1 on MPI-2.2 p472 that do not have a C type (MPI_PACKED and MPI_BYTE do not count).

Proposals:

  • We add footnotes to the modified table on p517:17-22:

    |||| C++-Only Named Predefined Datatypes || C++ types ||
    ||C type: MPI_Datatype ||C++ type: MPI::Datatype || ||
    ||Fortran type: INTEGER || || ||
    ||MPI_CXX_BOOL ^1^ ||MPI::BOOL ||bool ||
    ||MPI_CXX_FLOAT_COMPLEX ^2^ ||MPI::COMPLEX ||Complex ||
    ||MPI_CXX_DOUBLE_COMPLEX ^3^ ||MPI::DOUBLE_COMPLEX ||Complex ||
    ||MPI_CXX_LONG_DOUBLE_COMPLEX ^4^ ||MPI::LONG_DOUBLE_COMPLEX ||Complex ||
    ||||||^1-4^ If an accompnying C++ compiler is missing, then the exent and alignment is set according to the corresponding C types ^1^_Bool, ^2^float _Complex, ^3^double _Complex, and ^4^long double _Complex. ||

  • We make them optional, i.e.they exist if and only if there is an accompanying C++ compiler.

    |||| C++-Only Named Predefined Datatypes ^1^ || C++ types ^1^ ||
    ||C type: MPI_Datatype ||C++ type: MPI::Datatype || ||
    ||Fortran type: INTEGER || || ||
    ||MPI_CXX_BOOL ||MPI::BOOL ||bool ||
    ||MPI_CXX_FLOAT_COMPLEX ||MPI::COMPLEX ||Complex ||
    ||MPI_CXX_DOUBLE_COMPLEX ||MPI::DOUBLE_COMPLEX ||Complex ||
    ||MPI_CXX_LONG_DOUBLE_COMPLEX ||MPI::LONG_DOUBLE_COMPLEX ||Complex ||
    ||||||^1^ If an accompnying C++ compiler is missing, then the datatypes in this table do not exist.||

Are there other options?

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-01 13:31:10 -0500


Nick M. Maclaren wrote by email:

These are the only 4 types in Table 16.1 on MPI-2.2 p472 that do not have
a C type (MPI_PACKED and MPI_BYTE do not count).

They are essentially the only ones where the C++ compiler does not
define that they are the same as the C type - i.e. that's fine.

||||||^1-4^ If an accompnying C++ compiler is missing, then the exent and alignment is set according to the corresponding C types ^1^_Bool, ^2^float _Complex, ^3^double _Complex, and ^4^long double _Complex. ||

I don't have time to study the standards in detail now, but I don't
believe that is required - i.e. that's a very bad idea.

||||||^1^ If an accompnying C++ compiler is missing, then the datatypes in this table do not exist.||

That's by far the best solution.

@mpiforumbot
Copy link
Collaborator Author

Originally by jsquyres on 2012-07-03 09:28:39 -0500


By "do not exist", do you mean that those handles exist, but they are set to MPI_DATATYPE_NULL (for example)? Or do you mean that mpi.h (etc.) do not define those symbol names at all?

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-11 07:46:52 -0500


  • Changed Complex<...> into std::complex<...>
  • Added "If an accompanying C++ compiler is missing, then the MPI datatypes in this table are not defined."
  • C++ table also added in Section 3.2.2

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-17 10:52:11 -0500


Update according to reading in the Forum, Monday July 16, 2012.

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2012-07-17 11:39:23 -0500


Passed with single-only-vote

@mpiforumbot
Copy link
Collaborator Author

Originally by htor on 2012-07-18 12:01:39 -0500


Committed to approved/coll - please review!

--> http://www.unixer.de/sec/mpi-report.pdf

Torsten

@mpiforumbot
Copy link
Collaborator Author

Originally by tony on 2012-07-18 12:31:21 -0500


These appear OK under Global Reductions.

However, inconsistency with Section 3.2.2 appears to need to talk about these types also, since they can be sent and received.
Extern32 should have these also. It appears like references to this data is removed, but removing the discussion of C++ bindings is different from discussing the idea that any language can transfer C++ datatypes.

@mpiforumbot
Copy link
Collaborator Author

Originally by jsquyres on 2012-07-18 13:58:03 -0500


The chapter 16 part of this ticket is moot because #281 removed all that C++ text from chapter 16.

@mpiforumbot
Copy link
Collaborator Author

Originally by anhvo on 2012-07-18 18:35:10 -0500


typo detected in pt2pt due to the application of this ticket:
http://www.open-mpi.org/~jsquyres/unofficial/mpi-report-cleandoc-r1441.pdf

Page 26, line 46: accomanying --> accompanying

@mpiforumbot
Copy link
Collaborator Author

Originally by davesolt on 2012-07-18 18:41:19 -0500


I reviewed the mpi-report-cleandoc-r1441.pdf for this ticket. I missed the accomanying typo and did not see any other problems with the execution of this ticket.

@mpiforumbot
Copy link
Collaborator Author

Originally by davesolt on 2012-07-18 18:46:26 -0500


accomanying --> accompanying fixed in svn

@mpiforumbot
Copy link
Collaborator Author

Originally by RolfRabenseifner on 2013-01-07 11:30:39 -0600


Since Sep. 21, 2012, this ticket is included in MPI-3.0 and the pdf is checked according to https://svn.mpi-forum.org/svn/mpi-forum-docs/trunk/meetings/2012-07-jul/mpi3-tickets.xlsx

Therefore, by proxy / on behalf of the ticket owner, I close it with priority "Ticket complete", resolution "Text committed".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant