Skip to content

Commit 326e7ef

Browse files
authored
Merge pull request #3578 from jjhursey/fix/v3.x/type_create_f90-dt
v3.0.x: ompi/mpi: Fixes for `mpi_type_create_f90_(real|complex)`
2 parents f88602a + 14f59c1 commit 326e7ef

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

ompi/mpi/c/type_create_f90_complex.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -45,6 +46,7 @@ static const char FUNC_NAME[] = "MPI_Type_create_f90_complex";
4546
int MPI_Type_create_f90_complex(int p, int r, MPI_Datatype *newtype)
4647
{
4748
uint64_t key;
49+
int p_key, r_key;
4850

4951
OPAL_CR_NOOP_PROGRESS();
5052

@@ -64,8 +66,10 @@ int MPI_Type_create_f90_complex(int p, int r, MPI_Datatype *newtype)
6466
/* if the user does not care about p or r set them to 0 so the
6567
* test associate with them will always succeed.
6668
*/
67-
if( MPI_UNDEFINED == p ) p = 0;
68-
if( MPI_UNDEFINED == r ) r = 0;
69+
p_key = p;
70+
r_key = r;
71+
if( MPI_UNDEFINED == p ) p_key = 0;
72+
if( MPI_UNDEFINED == r ) r_key = 0;
6973

7074
/**
7175
* With respect to the MPI standard, MPI-2.0 Sect. 10.2.5, MPI_TYPE_CREATE_F90_xxxx,
@@ -86,7 +90,7 @@ int MPI_Type_create_f90_complex(int p, int r, MPI_Datatype *newtype)
8690
const int* a_i[2];
8791
int rc;
8892

89-
key = (((uint64_t)p) << 32) | ((uint64_t)r);
93+
key = (((uint64_t)p_key) << 32) | ((uint64_t)r_key);
9094
if( OPAL_SUCCESS == opal_hash_table_get_value_uint64( &ompi_mpi_f90_complex_hashtable,
9195
key, (void**)newtype ) ) {
9296
return MPI_SUCCESS;
@@ -106,8 +110,8 @@ int MPI_Type_create_f90_complex(int p, int r, MPI_Datatype *newtype)
106110
snprintf(datatype->name, MPI_MAX_OBJECT_NAME, "COMBINER %s",
107111
(*newtype)->name);
108112

109-
a_i[0] = &r;
110-
a_i[1] = &p;
113+
a_i[0] = &p;
114+
a_i[1] = &r;
111115
ompi_datatype_set_args( datatype, 2, a_i, 0, NULL, 0, NULL, MPI_COMBINER_F90_COMPLEX );
112116

113117
rc = opal_hash_table_set_value_uint64( &ompi_mpi_f90_complex_hashtable, key, datatype );

ompi/mpi/c/type_create_f90_real.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -45,6 +46,7 @@ static const char FUNC_NAME[] = "MPI_Type_create_f90_real";
4546
int MPI_Type_create_f90_real(int p, int r, MPI_Datatype *newtype)
4647
{
4748
uint64_t key;
49+
int p_key, r_key;
4850

4951
OPAL_CR_NOOP_PROGRESS();
5052

@@ -64,8 +66,10 @@ int MPI_Type_create_f90_real(int p, int r, MPI_Datatype *newtype)
6466
/* if the user does not care about p or r set them to 0 so the
6567
* test associate with them will always succeed.
6668
*/
67-
if( MPI_UNDEFINED == p ) p = 0;
68-
if( MPI_UNDEFINED == r ) r = 0;
69+
p_key = p;
70+
r_key = r;
71+
if( MPI_UNDEFINED == p ) p_key = 0;
72+
if( MPI_UNDEFINED == r ) r_key = 0;
6973

7074
/**
7175
* With respect to the MPI standard, MPI-2.0 Sect. 10.2.5, MPI_TYPE_CREATE_F90_xxxx,
@@ -83,10 +87,10 @@ int MPI_Type_create_f90_real(int p, int r, MPI_Datatype *newtype)
8387

8488
if( *newtype != &ompi_mpi_datatype_null.dt ) {
8589
ompi_datatype_t* datatype;
86-
const int* a_i[2] = {&r, &p};
90+
const int* a_i[2] = {&p, &r};
8791
int rc;
8892

89-
key = (((uint64_t)p) << 32) | ((uint64_t)r);
93+
key = (((uint64_t)p_key) << 32) | ((uint64_t)r_key);
9094
if( OPAL_SUCCESS == opal_hash_table_get_value_uint64( &ompi_mpi_f90_real_hashtable,
9195
key, (void**)newtype ) ) {
9296
return MPI_SUCCESS;

0 commit comments

Comments
 (0)