Skip to content

Commit 880f2d5

Browse files
committed
mpi/c: revamp error handling in MPI_{Pack,Unpack}[_external]
Thanks Alex and the folks at Mellanox for the help. Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent d5266ab commit 880f2d5

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

ompi/mpi/c/pack.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2015-2016 Research Organization for Information Science
16+
* Copyright (c) 2015-2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
1919
*
@@ -45,7 +45,7 @@ static const char FUNC_NAME[] = "MPI_Pack";
4545
int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
4646
void *outbuf, int outsize, int *position, MPI_Comm comm)
4747
{
48-
int rc = MPI_SUCCESS;
48+
int rc = MPI_SUCCESS, ret;
4949
opal_convertor_t local_convertor;
5050
struct iovec invec;
5151
unsigned int iov_count;
@@ -95,14 +95,16 @@ int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
9595

9696
/* Do the actual packing */
9797
iov_count = 1;
98-
rc = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size );
98+
ret = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size );
9999
*position += size;
100100
OBJ_DESTRUCT( &local_convertor );
101101

102102
OPAL_CR_EXIT_LIBRARY();
103103

104104
/* All done. Note that the convertor returns 1 upon success, not
105-
OMPI_SUCCESS. */
106-
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
107-
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
105+
OPAL_SUCCESS. */
106+
if (1 != ret) {
107+
rc = OMPI_ERROR;
108+
}
109+
OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
108110
}

ompi/mpi/c/pack_external.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2015-2016 Research Organization for Information Science
16+
* Copyright (c) 2015-2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
1919
*
@@ -76,6 +76,5 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount,
7676

7777
OPAL_CR_EXIT_LIBRARY();
7878

79-
OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR,
80-
MPI_COMM_WORLD, rc, FUNC_NAME);
79+
OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
8180
}

ompi/mpi/c/pack_external_size.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2015-2016 Research Organization for Information Science
16+
* Copyright (c) 2015-2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
1919
*
@@ -66,6 +66,5 @@ int MPI_Pack_external_size(const char datarep[], int incount,
6666
datatype, size);
6767
OPAL_CR_EXIT_LIBRARY();
6868

69-
OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR,
70-
MPI_COMM_WORLD, rc, FUNC_NAME);
69+
OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
7170
}

ompi/mpi/c/unpack.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015-2016 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -79,6 +79,7 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
7979
OPAL_CR_ENTER_LIBRARY();
8080

8181
if( insize > 0 ) {
82+
int ret;
8283
OBJ_CONSTRUCT( &local_convertor, opal_convertor_t );
8384
/* the resulting convertor will be set the the position ZERO */
8485
opal_convertor_copy_and_prepare_for_recv( ompi_mpi_local_convertor, &(datatype->super),
@@ -98,17 +99,17 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
9899

99100
/* Do the actual unpacking */
100101
iov_count = 1;
101-
rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size );
102+
ret = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size );
102103
*position += size;
103104
OBJ_DESTRUCT( &local_convertor );
104-
} else {
105-
rc = 1;
105+
/* All done. Note that the convertor returns 1 upon success, not
106+
OPAL_SUCCESS. */
107+
if (1 != ret) {
108+
rc = OMPI_ERROR;
109+
}
106110
}
107111

108112
OPAL_CR_EXIT_LIBRARY();
109113

110-
/* All done. Note that the convertor returns 1 upon success, not
111-
OMPI_SUCCESS. */
112-
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
113-
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
114+
OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
114115
}

ompi/mpi/c/unpack_external.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2015-2016 Research Organization for Information Science
16+
* Copyright (c) 2015-2017 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
1919
*
@@ -70,9 +70,7 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz
7070
rc = ompi_datatype_unpack_external(datarep, inbuf, insize,
7171
position, outbuf, outcount,
7272
datatype);
73-
7473
OPAL_CR_EXIT_LIBRARY();
7574

76-
OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR,
77-
MPI_COMM_WORLD, rc, FUNC_NAME);
75+
OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
7876
}

0 commit comments

Comments
 (0)