Skip to content

Commit 5383003

Browse files
committed
fortran: Add missing predefined datatype named constants.
This commit add the following Fortran named constants which are defined in the MPI standard but are missing in Open MPI. - `MPI_LONG_LONG` (defined as a synonym of `MPI_LONG_LONG_INT`) - `MPI_CXX_FLOAT_COMPLEX` - `MPI_C_BOOL` And this commit also changes the value of the following Fortran named constant for consistency. - `MPI_C_COMPLEX` `(MPI_C_FLOAT_COMPLEX` is defined as a synonym of this) Each needs a different solution described below. For `MPI_LONG_LONG`: The value of `MPI_LONG_LONG` is defined to have a same value as `MPI_LONG_LONG_INT` because of the following reasons. 1. It is defined as a synonym of `MPI_LONG_LONG_INT` in the MPI standard. 2. `MPI_LONG_LONG_INT` and `MPI_LONG_LONG` has a same value for C in `mpi.h`. 3. `ompi_mpi_long_long` is not defined in `ompi/datatype/ompi_datatype_module.c`. For `MPI_CXX_FLOAT_COMPLEX`: Existing `MPI_CXX_COMPLEX` is replaced with `MPI_CXX_FLOAT_COMPLEX` bacause `MPI_CXX_FLOAT_COMPLEX` is the right name defined in MPI-3.1 and `MPI_CXX_COMPLEX` is not defined in MPI-3.1 (nor older). But for compatibility, `MPI_CXX_COMPLEX` is treated as a synonym of `MPI_CXX_FLOAT_COMPLEX` on Open MPI. For `MPI_C_BOOL`: `MPI_C_BOOL` is newly added. The value which `MPI_C_COMPLEX` had used (68) is assinged for it because the value becomes no longer in use (described later) and it is a suited position as a datatype added on MPI-2.2. For `MPI_C_COMPLEX`: Existing `MPI_C_FLOAT_COMPLEX` is replaced with `MPI_C_COMPLEX` and `MPI_C_FLOAT_COMPLEX` is changed to have the same value. In other words, make `MPI_C_COMPLEX` the canonical name and make `MPI_C_FLOAT_COMPLEX` an alias of it. This is bacause the relation of these datatypes is same as the relation of `MPI_LONG_LONG_INT` and `MPI_LONG_LONG`, and `MPI_LONG_LONG_INT` and `MPI_LONG_LONG` are implemented like that. But in the datatype engine, we use `ompi_mpi_c_float_complex` instead of `ompi_mpi_c_complex` as a variable name to keep the consistency with the other similar types such as `ompi_mpi_c_double_complex` (see George's comment in #1927). We don't delete `ompi_mpi_c_complex` now because it is used in some other places in Open MPI code. It may be cleand up in the future. In addition, `MPI_CXX_COMPLEX`, which was defined only in the Open MPI Fortran binding, is added to `mpi.h` for the C binding. This commit breaks binary compatibility of Fortran `MPI_C_COMPLEX`. When this commit is merged into v2.x branch, the change of `MPI_C_COMPLEX` should be excluded.
1 parent 0cb5dfe commit 5383003

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

ompi/datatype/ompi_datatype_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ ompi_predefined_datatype_t ompi_mpi_cxx_bool = OMPI_DATATYPE_INIT_PREDEFIN
109109
/*
110110
* Complex datatypes for C (base types), C++, and fortran
111111
*/
112-
ompi_predefined_datatype_t ompi_mpi_c_float_complex = OMPI_DATATYPE_INIT_PREDEFINED (C_FLOAT_COMPLEX, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_COMPLEX );
112+
ompi_predefined_datatype_t ompi_mpi_c_float_complex = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE (C_FLOAT_COMPLEX, C_COMPLEX, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_COMPLEX );
113113
ompi_predefined_datatype_t ompi_mpi_c_complex = OMPI_DATATYPE_INIT_PREDEFINED_BASIC_TYPE (C_FLOAT_COMPLEX, C_COMPLEX, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_COMPLEX );
114114
ompi_predefined_datatype_t ompi_mpi_c_double_complex = OMPI_DATATYPE_INIT_PREDEFINED (C_DOUBLE_COMPLEX, OMPI_DATATYPE_FLAG_DATA_C | OMPI_DATATYPE_FLAG_DATA_COMPLEX );
115115
#if HAVE_LONG_DOUBLE
@@ -533,7 +533,7 @@ int32_t ompi_datatype_init( void )
533533
}
534534

535535
/*
536-
* This MUST match the order of ompi/include/mpif-common.h
536+
* This MUST match the order of ompi/include/mpif-values.pl
537537
* Any change will break binary compatibility of Fortran programs.
538538
*/
539539
MOOG(datatype_null, 0);
@@ -614,7 +614,7 @@ int32_t ompi_datatype_init( void )
614614
MOOG(uint64_t, 65);
615615
MOOG(aint, 66);
616616
MOOG(offset, 67);
617-
MOOG(c_complex, 68);
617+
MOOG(c_bool, 68);
618618
MOOG(c_float_complex, 69);
619619
MOOG(c_double_complex, 70);
620620
MOOG(c_long_double_complex, 71);

ompi/include/mpi.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_aint;
10061006
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_offset;
10071007
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_count;
10081008
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_c_bool;
1009-
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_c_complex;
10101009
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_c_float_complex;
10111010
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_c_double_complex;
10121011
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_c_long_double_complex;
@@ -1153,7 +1152,7 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE;
11531152
#define MPI_OFFSET OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_offset)
11541153
#define MPI_C_BOOL OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_bool)
11551154
#if HAVE_FLOAT__COMPLEX
1156-
#define MPI_C_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_complex)
1155+
#define MPI_C_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_float_complex)
11571156
#define MPI_C_FLOAT_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_float_complex)
11581157
#endif
11591158
#if HAVE_DOUBLE__COMPLEX
@@ -1163,6 +1162,7 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE;
11631162
#define MPI_C_LONG_DOUBLE_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_c_long_double_complex)
11641163
#endif
11651164
#define MPI_CXX_BOOL OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_bool)
1165+
#define MPI_CXX_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_cplex)
11661166
#define MPI_CXX_FLOAT_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_cplex)
11671167
#define MPI_CXX_DOUBLE_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_dblcplex)
11681168
#define MPI_CXX_LONG_DOUBLE_COMPLEX OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_cxx_ldblcplex)

ompi/include/mpif-values.pl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ sub write_file {
162162
$handles->{MPI_LONG} = 41;
163163
$handles->{MPI_UNSIGNED_LONG} = 42;
164164
$handles->{MPI_LONG_LONG_INT} = 43;
165+
$handles->{MPI_LONG_LONG} = $handles->{MPI_LONG_LONG_INT};
165166
$handles->{MPI_UNSIGNED_LONG_LONG} = 44;
166167
$handles->{MPI_FLOAT} = 45;
167168
$handles->{MPI_DOUBLE} = 46;
@@ -173,7 +174,8 @@ sub write_file {
173174
$handles->{MPI_2INT} = 52;
174175
$handles->{MPI_SHORT_INT} = 53;
175176
$handles->{MPI_CXX_BOOL} = 54;
176-
$handles->{MPI_CXX_COMPLEX} = 55;
177+
$handles->{MPI_CXX_FLOAT_COMPLEX} = 55;
178+
$handles->{MPI_CXX_COMPLEX} = $handles->{MPI_CXX_FLOAT_COMPLEX};
177179
$handles->{MPI_CXX_DOUBLE_COMPLEX} = 56;
178180
$handles->{MPI_CXX_LONG_DOUBLE_COMPLEX} = 57;
179181
$handles->{MPI_INT8_T} = 58;
@@ -186,8 +188,9 @@ sub write_file {
186188
$handles->{MPI_UINT64_T} = 65;
187189
$handles->{MPI_AINT} = 66;
188190
$handles->{MPI_OFFSET} = 67;
189-
$handles->{MPI_C_COMPLEX} = 68;
190-
$handles->{MPI_C_FLOAT_COMPLEX} = 69;
191+
$handles->{MPI_C_BOOL} = 68;
192+
$handles->{MPI_C_COMPLEX} = 69;
193+
$handles->{MPI_C_FLOAT_COMPLEX} = $handles->{MPI_C_COMPLEX};
191194
$handles->{MPI_C_DOUBLE_COMPLEX} = 70;
192195
$handles->{MPI_C_LONG_DOUBLE_COMPLEX} = 71;
193196
$handles->{MPI_COUNT} = 72;

0 commit comments

Comments
 (0)