Skip to content

Commit 570806c

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]> (back-ported from commit 880f2d5)
1 parent a8b225a commit 570806c

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 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;
@@ -92,12 +92,14 @@ int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype,
9292

9393
/* Do the actual packing */
9494
iov_count = 1;
95-
rc = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size );
95+
ret = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size );
9696
*position += size;
9797
OBJ_DESTRUCT( &local_convertor );
9898

9999
/* All done. Note that the convertor returns 1 upon success, not
100-
OMPI_SUCCESS. */
101-
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
102-
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
100+
OPAL_SUCCESS. */
101+
if (1 != ret) {
102+
rc = OMPI_ERROR;
103+
}
104+
OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
103105
}

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 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
*
@@ -72,6 +72,5 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount,
7272
datatype, outbuf,
7373
outsize, position);
7474

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

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
*
@@ -63,6 +63,5 @@ int MPI_Pack_external_size(const char datarep[], int incount,
6363

6464
rc = ompi_datatype_pack_external_size(datarep, incount,
6565
datatype, size);
66-
OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR,
67-
MPI_COMM_WORLD, rc, FUNC_NAME);
66+
OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
6867
}

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 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
*
@@ -78,6 +78,7 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
7878

7979

8080
if( insize > 0 ) {
81+
int ret;
8182
OBJ_CONSTRUCT( &local_convertor, opal_convertor_t );
8283
/* the resulting convertor will be set the the position ZERO */
8384
opal_convertor_copy_and_prepare_for_recv( ompi_mpi_local_convertor, &(datatype->super),
@@ -96,15 +97,15 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
9697

9798
/* Do the actual unpacking */
9899
iov_count = 1;
99-
rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size );
100+
ret = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size );
100101
*position += size;
101102
OBJ_DESTRUCT( &local_convertor );
102-
} else {
103-
rc = 1;
103+
/* All done. Note that the convertor returns 1 upon success, not
104+
OPAL_SUCCESS. */
105+
if (1 != ret) {
106+
rc = OMPI_ERROR;
107+
}
104108
}
105109

106-
/* All done. Note that the convertor returns 1 upon success, not
107-
OMPI_SUCCESS. */
108-
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
109-
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
110+
OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
110111
}

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 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
*
@@ -69,7 +69,5 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz
6969
rc = ompi_datatype_unpack_external(datarep, inbuf, insize,
7070
position, outbuf, outcount,
7171
datatype);
72-
73-
OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR,
74-
MPI_COMM_WORLD, rc, FUNC_NAME);
72+
OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
7573
}

0 commit comments

Comments
 (0)