From 05b5d9670b05eb8ccab8390d5a9f592e06fa7775 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 30 Mar 2016 11:43:45 +0900 Subject: [PATCH 1/4] datatype/[un]pack_external[_size]: move subroutines down to ompi/datatype so it can be directly used by test/datatype/external32 (back-ported from commit open-mpi/ompi@5932287cef34d864d025d22db33b9ed71858d265) Signed-off-by: Gilles Gouaillardet --- ompi/datatype/Makefile.am | 3 + ompi/datatype/ompi_datatype.h | 13 ++- ompi/datatype/ompi_datatype_external.c | 135 +++++++++++++++++++++++++ ompi/mpi/c/pack_external.c | 40 +------- ompi/mpi/c/pack_external_size.c | 22 ++-- ompi/mpi/c/unpack_external.c | 37 +------ test/datatype/external32.c | 116 ++------------------- 7 files changed, 172 insertions(+), 194 deletions(-) create mode 100644 ompi/datatype/ompi_datatype_external.c diff --git a/ompi/datatype/Makefile.am b/ompi/datatype/Makefile.am index b14c05a5a71..643e8147fdd 100644 --- a/ompi/datatype/Makefile.am +++ b/ompi/datatype/Makefile.am @@ -13,6 +13,8 @@ # Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights # reserved. # Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2016 Research Organization for Information Science +# and Technology (RIST). All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -37,6 +39,7 @@ libdatatype_la_SOURCES = \ ompi_datatype_create_vector.c \ ompi_datatype_create_darray.c \ ompi_datatype_create_subarray.c \ + ompi_datatype_external.c \ ompi_datatype_external32.c \ ompi_datatype_match_size.c \ ompi_datatype_module.c \ diff --git a/ompi/datatype/ompi_datatype.h b/ompi/datatype/ompi_datatype.h index 17e1632e07d..ff6a1b0b2f1 100644 --- a/ompi/datatype/ompi_datatype.h +++ b/ompi/datatype/ompi_datatype.h @@ -7,7 +7,7 @@ * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -363,5 +363,16 @@ OMPI_DECLSPEC int ompi_datatype_safeguard_pointer_debug_breakpoint( const void* int count ); #endif /* OPAL_ENABLE_DEBUG */ +OMPI_DECLSPEC int ompi_datatype_pack_external( const char datarep[], const void *inbuf, int incount, + ompi_datatype_t *datatype, void *outbuf, + MPI_Aint outsize, MPI_Aint *position); + +OMPI_DECLSPEC int ompi_datatype_unpack_external( const char datarep[], const void *inbuf, MPI_Aint insize, + MPI_Aint *position, void *outbuf, int outcount, + ompi_datatype_t *datatype); + +OMPI_DECLSPEC int ompi_datatype_pack_external_size( const char datarep[], int incount, + ompi_datatype_t *datatype, MPI_Aint *size); + END_C_DECLS #endif /* OMPI_DATATYPE_H_HAS_BEEN_INCLUDED */ diff --git a/ompi/datatype/ompi_datatype_external.c b/ompi/datatype/ompi_datatype_external.c new file mode 100644 index 00000000000..d47531ef29e --- /dev/null +++ b/ompi/datatype/ompi_datatype_external.c @@ -0,0 +1,135 @@ +/* -*- Mode: C; c-basic-offset:4 ; -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2016 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015-2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" +#include + +#include "ompi/runtime/params.h" +#include "ompi/communicator/communicator.h" +#include "ompi/datatype/ompi_datatype.h" +#include "opal/datatype/opal_convertor.h" + +int ompi_datatype_pack_external(const char datarep[], const void *inbuf, int incount, + ompi_datatype_t *datatype, void *outbuf, + MPI_Aint outsize, MPI_Aint *position) +{ + int rc = MPI_SUCCESS; + opal_convertor_t local_convertor; + struct iovec invec; + unsigned int iov_count; + size_t size; + + OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); + + /* The resulting convertor will be set to the position zero. We have to use + * CONVERTOR_SEND_CONVERSION in order to force the convertor to do anything + * more than just packing the data. + */ + opal_convertor_copy_and_prepare_for_send( ompi_mpi_external32_convertor, + &(datatype->super), incount, (void *) inbuf, + CONVERTOR_SEND_CONVERSION, + &local_convertor ); + + /* Check for truncation */ + opal_convertor_get_packed_size( &local_convertor, &size ); + if( (*position + size) > (size_t)outsize ) { /* we can cast as we already checked for < 0 */ + OBJ_DESTRUCT( &local_convertor ); + return MPI_ERR_TRUNCATE; + } + + /* Prepare the iovec with all informations */ + invec.iov_base = (char*) outbuf + (*position); + invec.iov_len = size; + + /* Do the actual packing */ + iov_count = 1; + rc = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size ); + *position += size; + OBJ_DESTRUCT( &local_convertor ); + + /* All done. Note that the convertor returns 1 upon success, not + OMPI_SUCCESS. */ + return (rc == 1) ? OMPI_SUCCESS : MPI_ERR_UNKNOWN; +} + +int ompi_datatype_unpack_external (const char datarep[], const void *inbuf, MPI_Aint insize, + MPI_Aint *position, void *outbuf, int outcount, + ompi_datatype_t *datatype) +{ + int rc = MPI_SUCCESS; + opal_convertor_t local_convertor; + struct iovec outvec; + unsigned int iov_count; + size_t size; + + OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); + + /* the resulting convertor will be set to the position ZERO */ + opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor, + &(datatype->super), outcount, outbuf, + 0, + &local_convertor ); + + /* Check for truncation */ + opal_convertor_get_packed_size( &local_convertor, &size ); + if( (*position + size) > (unsigned int)insize ) { + OBJ_DESTRUCT( &local_convertor ); + return MPI_ERR_TRUNCATE; + } + + /* Prepare the iovec with all informations */ + outvec.iov_base = (char*) inbuf + (*position); + outvec.iov_len = size; + + /* Do the actual unpacking */ + iov_count = 1; + rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); + *position += size; + OBJ_DESTRUCT( &local_convertor ); + + /* All done. Note that the convertor returns 1 upon success, not + OMPI_SUCCESS. */ + return (rc == 1) ? OMPI_SUCCESS : MPI_ERR_UNKNOWN; +} + +int ompi_datatype_pack_external_size(const char datarep[], int incount, + ompi_datatype_t *datatype, MPI_Aint *size) +{ + opal_convertor_t local_convertor; + size_t length; + + OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); + + /* the resulting convertor will be set to the position ZERO */ + opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor, + &(datatype->super), incount, NULL, + CONVERTOR_SEND_CONVERSION, + &local_convertor ); + + opal_convertor_get_unpacked_size( &local_convertor, &length ); + *size = (MPI_Aint)length; + OBJ_DESTRUCT( &local_convertor ); + + return OMPI_SUCCESS; +} diff --git a/ompi/mpi/c/pack_external.c b/ompi/mpi/c/pack_external.c index 72cb58df787..8304efcd913 100644 --- a/ompi/mpi/c/pack_external.c +++ b/ompi/mpi/c/pack_external.c @@ -47,10 +47,6 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount, MPI_Aint outsize, MPI_Aint *position) { int rc = MPI_SUCCESS; - opal_convertor_t local_convertor; - struct iovec invec; - unsigned int iov_count; - size_t size; MEMCHECKER( memchecker_datatype(datatype); @@ -72,36 +68,10 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount, OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } - OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); + rc = ompi_datatype_pack_external(datarep, inbuf, incount, + datatype, outbuf, + outsize, position); - /* The resulting convertor will be set to the position zero. We have to use - * CONVERTOR_SEND_CONVERSION in order to force the convertor to do anything - * more than just packing the data. - */ - opal_convertor_copy_and_prepare_for_send( ompi_mpi_external32_convertor, - &(datatype->super), incount, (void *) inbuf, - CONVERTOR_SEND_CONVERSION, - &local_convertor ); - - /* Check for truncation */ - opal_convertor_get_packed_size( &local_convertor, &size ); - if( (*position + size) > (size_t)outsize ) { /* we can cast as we already checked for < 0 */ - OBJ_DESTRUCT( &local_convertor ); - return OMPI_ERRHANDLER_INVOKE( MPI_COMM_WORLD, MPI_ERR_TRUNCATE, FUNC_NAME ); - } - - /* Prepare the iovec with all informations */ - invec.iov_base = (char*) outbuf + (*position); - invec.iov_len = size; - - /* Do the actual packing */ - iov_count = 1; - rc = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size ); - *position += size; - OBJ_DESTRUCT( &local_convertor ); - - /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR, - MPI_COMM_WORLD, MPI_ERR_UNKNOWN, FUNC_NAME); + OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR, + MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/pack_external_size.c b/ompi/mpi/c/pack_external_size.c index 1eef2123f93..f16ddf40cdd 100644 --- a/ompi/mpi/c/pack_external_size.c +++ b/ompi/mpi/c/pack_external_size.c @@ -13,7 +13,7 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2016 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -45,8 +45,7 @@ static const char FUNC_NAME[] = "MPI_Pack_external_size"; int MPI_Pack_external_size(const char datarep[], int incount, MPI_Datatype datatype, MPI_Aint *size) { - opal_convertor_t local_convertor; - size_t length; + int rc = MPI_SUCCESS; MEMCHECKER( memchecker_datatype(datatype); @@ -62,17 +61,8 @@ int MPI_Pack_external_size(const char datarep[], int incount, } - OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); - - /* the resulting convertor will be set to the position ZERO */ - opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor, - &(datatype->super), incount, NULL, - CONVERTOR_SEND_CONVERSION, - &local_convertor ); - - opal_convertor_get_unpacked_size( &local_convertor, &length ); - *size = (MPI_Aint)length; - OBJ_DESTRUCT( &local_convertor ); - - return OMPI_SUCCESS; + rc = ompi_datatype_pack_external_size(datarep, incount, + datatype, size); + OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR, + MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/unpack_external.c b/ompi/mpi/c/unpack_external.c index 04d7a890de0..fba791eb4a3 100644 --- a/ompi/mpi/c/unpack_external.c +++ b/ompi/mpi/c/unpack_external.c @@ -46,10 +46,6 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz MPI_Datatype datatype) { int rc = MPI_SUCCESS; - opal_convertor_t local_convertor; - struct iovec outvec; - unsigned int iov_count; - size_t size; MEMCHECKER( memchecker_datatype(datatype); @@ -70,33 +66,10 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz } - OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); + rc = ompi_datatype_unpack_external(datarep, inbuf, insize, + position, outbuf, outcount, + datatype); - /* the resulting convertor will be set to the position ZERO */ - opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor, - &(datatype->super), outcount, outbuf, - 0, - &local_convertor ); - - /* Check for truncation */ - opal_convertor_get_packed_size( &local_convertor, &size ); - if( (*position + size) > (unsigned int)insize ) { - OBJ_DESTRUCT( &local_convertor ); - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TRUNCATE, FUNC_NAME); - } - - /* Prepare the iovec with all informations */ - outvec.iov_base = (char*) inbuf + (*position); - outvec.iov_len = size; - - /* Do the actual unpacking */ - iov_count = 1; - rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); - *position += size; - OBJ_DESTRUCT( &local_convertor ); - - /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR, - MPI_COMM_WORLD, MPI_ERR_UNKNOWN, FUNC_NAME); + OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR, + MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/test/datatype/external32.c b/test/datatype/external32.c index 8cd1b28a1b1..d09938510ba 100644 --- a/test/datatype/external32.c +++ b/test/datatype/external32.c @@ -43,110 +43,6 @@ static void dump_hex(void* what, size_t length) } } -int MPI_Pack_external_size(const char datarep[], int incount, - ompi_datatype_t *datatype, MPI_Aint *size) -{ - opal_convertor_t local_convertor; - size_t length; - - OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); - - /* the resulting convertor will be set to the position ZERO */ - opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor, - &(datatype->super), incount, NULL, - CONVERTOR_SEND_CONVERSION, - &local_convertor ); - - opal_convertor_get_unpacked_size( &local_convertor, &length ); - *size = (MPI_Aint)length; - OBJ_DESTRUCT( &local_convertor ); - - return OMPI_SUCCESS; -} - -int MPI_Pack_external(const char datarep[], const void *inbuf, int incount, - ompi_datatype_t *datatype, void *outbuf, - MPI_Aint outsize, MPI_Aint *position) -{ - int rc = MPI_SUCCESS; - opal_convertor_t local_convertor; - struct iovec invec; - unsigned int iov_count; - size_t size; - - OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); - - /* The resulting convertor will be set to the position zero. We have to use - * CONVERTOR_SEND_CONVERSION in order to force the convertor to do anything - * more than just packing the data. - */ - opal_convertor_copy_and_prepare_for_send( ompi_mpi_external32_convertor, - &(datatype->super), incount, (void *) inbuf, - CONVERTOR_SEND_CONVERSION, - &local_convertor ); - - /* Check for truncation */ - opal_convertor_get_packed_size( &local_convertor, &size ); - if( (*position + size) > (size_t)outsize ) { /* we can cast as we already checked for < 0 */ - OBJ_DESTRUCT( &local_convertor ); - return MPI_ERR_TRUNCATE; - } - - /* Prepare the iovec with all informations */ - invec.iov_base = (char*) outbuf + (*position); - invec.iov_len = size; - - /* Do the actual packing */ - iov_count = 1; - rc = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size ); - *position += size; - OBJ_DESTRUCT( &local_convertor ); - - /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - return (rc == 1) ? OMPI_SUCCESS : OMPI_ERROR; -} - -int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insize, - MPI_Aint *position, void *outbuf, int outcount, - ompi_datatype_t *datatype) -{ - int rc = MPI_SUCCESS; - opal_convertor_t local_convertor; - struct iovec outvec; - unsigned int iov_count; - size_t size; - - OBJ_CONSTRUCT(&local_convertor, opal_convertor_t); - - /* the resulting convertor will be set to the position ZERO */ - opal_convertor_copy_and_prepare_for_recv( ompi_mpi_external32_convertor, - &(datatype->super), outcount, outbuf, - 0, - &local_convertor ); - - /* Check for truncation */ - opal_convertor_get_packed_size( &local_convertor, &size ); - if( (*position + size) > (unsigned int)insize ) { - OBJ_DESTRUCT( &local_convertor ); - return MPI_ERR_TRUNCATE; - } - - /* Prepare the iovec with all informations */ - outvec.iov_base = (char*) inbuf + (*position); - outvec.iov_len = size; - - /* Do the actual unpacking */ - iov_count = 1; - rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); - *position += size; - OBJ_DESTRUCT( &local_convertor ); - - /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - return (rc == 1) ? OMPI_SUCCESS : OMPI_ERROR; -} - int check_contiguous( void* send_buffer, void* packed, ompi_datatype_t* datatype, int count, void* arg ) { @@ -220,15 +116,15 @@ static int pack_unpack_datatype( void* send_data, ompi_datatype_t *datatype, int void* buffer; int error; - error = MPI_Pack_external_size("external32", - count, datatype, &buffer_size); + error = ompi_datatype_pack_external_size("external32", + count, datatype, &buffer_size); if( MPI_SUCCESS != error ) goto return_error_code; buffer = (void*)malloc(buffer_size); if( NULL == buffer ) { error = MPI_ERR_UNKNOWN; goto return_error_code; } - error = MPI_Pack_external("external32", (void*)send_data, count, datatype, - buffer, buffer_size, &position); + error = ompi_datatype_pack_external("external32", (void*)send_data, count, datatype, + buffer, buffer_size, &position); if( MPI_SUCCESS != error ) goto return_error_code; if( 0 != validator(send_data, buffer, datatype, count, validator_arg) ) { printf("Error during pack external. Bailing out\n"); @@ -238,8 +134,8 @@ static int pack_unpack_datatype( void* send_data, ompi_datatype_t *datatype, int printf("packed %ld bytes into a %ld bytes buffer ", position, buffer_size); dump_hex(buffer, position); printf("\n"); position = 0; - error = MPI_Unpack_external("external32", buffer, buffer_size, &position, - recv_data, count, datatype); + error = ompi_datatype_unpack_external("external32", buffer, buffer_size, &position, + recv_data, count, datatype); if( MPI_SUCCESS != error ) goto return_error_code; free(buffer); From be1c180403edfee3addadeeadcc650d0b732c82d Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Thu, 2 Mar 2017 09:12:02 +0900 Subject: [PATCH 2/4] MPI_Unpack: fix return status this regression was previously introduced in open-mpi/ompi@221e6e2eabe60b7be5902cb8ef05966dcc077f4b (back-ported from commit open-mpi/ompi@f2e33c725fa77cfd8ecd585d131e9ae4c6497714) Signed-off-by: Gilles Gouaillardet --- ompi/mpi/c/unpack.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ompi/mpi/c/unpack.c b/ompi/mpi/c/unpack.c index 88d25aa4cec..00782451e71 100644 --- a/ompi/mpi/c/unpack.c +++ b/ompi/mpi/c/unpack.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -99,11 +99,10 @@ int MPI_Unpack(const void *inbuf, int insize, int *position, rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); *position += size; OBJ_DESTRUCT( &local_convertor ); - - /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - rc = (1 == rc) ? OMPI_SUCCESS : OMPI_ERROR; } - OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME); + /* All done. Note that the convertor returns 1 upon success, not + OMPI_SUCCESS. */ + OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR, + comm, MPI_ERR_UNKNOWN, FUNC_NAME); } From 09d07cfbce56f54ab38c4245784e49da0ef92f7a Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 6 Apr 2016 09:45:45 +0900 Subject: [PATCH 3/4] MPI_Unpack: fix error code when insize <= 0 this fixes a regression from open-mpi/ompi@f2e33c725fa77cfd8ecd585d131e9ae4c6497714 (cherry picked from commit open-mpi/ompi@7b803ac5574259f457ef7bf27c305ab2b2bbd167) --- ompi/mpi/c/unpack.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ompi/mpi/c/unpack.c b/ompi/mpi/c/unpack.c index 00782451e71..491542cfe10 100644 --- a/ompi/mpi/c/unpack.c +++ b/ompi/mpi/c/unpack.c @@ -99,6 +99,8 @@ int MPI_Unpack(const void *inbuf, int insize, int *position, rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); *position += size; OBJ_DESTRUCT( &local_convertor ); + } else { + rc = 1; } /* All done. Note that the convertor returns 1 upon success, not From 0c695720a5e45cf3405ebcb882c5f4ca3cf8b7d0 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 1 Mar 2017 09:59:58 +0900 Subject: [PATCH 4/4] 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 (back-ported from commit open-mpi/ompi@880f2d54318e5ba052d1be40a7aaa3c6f1d3e7d5) --- ompi/mpi/c/pack.c | 14 ++++++++------ ompi/mpi/c/pack_external.c | 5 ++--- ompi/mpi/c/pack_external_size.c | 5 ++--- ompi/mpi/c/unpack.c | 15 ++++++++------- ompi/mpi/c/unpack_external.c | 6 ++---- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/ompi/mpi/c/pack.c b/ompi/mpi/c/pack.c index 5bdbccaad28..46d9b1a0b8e 100644 --- a/ompi/mpi/c/pack.c +++ b/ompi/mpi/c/pack.c @@ -13,7 +13,7 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -45,7 +45,7 @@ static const char FUNC_NAME[] = "MPI_Pack"; int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, int outsize, int *position, MPI_Comm comm) { - int rc = MPI_SUCCESS; + int rc = MPI_SUCCESS, ret; opal_convertor_t local_convertor; struct iovec invec; unsigned int iov_count; @@ -92,12 +92,14 @@ int MPI_Pack(const void *inbuf, int incount, MPI_Datatype datatype, /* Do the actual packing */ iov_count = 1; - rc = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size ); + ret = opal_convertor_pack( &local_convertor, &invec, &iov_count, &size ); *position += size; OBJ_DESTRUCT( &local_convertor ); /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR, - comm, MPI_ERR_UNKNOWN, FUNC_NAME); + OPAL_SUCCESS. */ + if (1 != ret) { + rc = OMPI_ERROR; + } + OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME); } diff --git a/ompi/mpi/c/pack_external.c b/ompi/mpi/c/pack_external.c index 8304efcd913..cc5dddbca1a 100644 --- a/ompi/mpi/c/pack_external.c +++ b/ompi/mpi/c/pack_external.c @@ -13,7 +13,7 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -72,6 +72,5 @@ int MPI_Pack_external(const char datarep[], const void *inbuf, int incount, datatype, outbuf, outsize, position); - OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR, - MPI_COMM_WORLD, rc, FUNC_NAME); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/pack_external_size.c b/ompi/mpi/c/pack_external_size.c index f16ddf40cdd..b3b3ceef337 100644 --- a/ompi/mpi/c/pack_external_size.c +++ b/ompi/mpi/c/pack_external_size.c @@ -13,7 +13,7 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015-2016 Research Organization for Information Science + * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -63,6 +63,5 @@ int MPI_Pack_external_size(const char datarep[], int incount, rc = ompi_datatype_pack_external_size(datarep, incount, datatype, size); - OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR, - MPI_COMM_WORLD, rc, FUNC_NAME); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/unpack.c b/ompi/mpi/c/unpack.c index 491542cfe10..4d33a38e268 100644 --- a/ompi/mpi/c/unpack.c +++ b/ompi/mpi/c/unpack.c @@ -78,6 +78,7 @@ int MPI_Unpack(const void *inbuf, int insize, int *position, if( insize > 0 ) { + int ret; OBJ_CONSTRUCT( &local_convertor, opal_convertor_t ); /* the resulting convertor will be set the the position ZERO */ 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, /* Do the actual unpacking */ iov_count = 1; - rc = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); + ret = opal_convertor_unpack( &local_convertor, &outvec, &iov_count, &size ); *position += size; OBJ_DESTRUCT( &local_convertor ); - } else { - rc = 1; + /* All done. Note that the convertor returns 1 upon success, not + OPAL_SUCCESS. */ + if (1 != ret) { + rc = OMPI_ERROR; + } } - /* All done. Note that the convertor returns 1 upon success, not - OMPI_SUCCESS. */ - OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR, - comm, MPI_ERR_UNKNOWN, FUNC_NAME); + OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME); } diff --git a/ompi/mpi/c/unpack_external.c b/ompi/mpi/c/unpack_external.c index fba791eb4a3..55ada651ef0 100644 --- a/ompi/mpi/c/unpack_external.c +++ b/ompi/mpi/c/unpack_external.c @@ -13,7 +13,7 @@ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2015 Research Organization for Information Science + * Copyright (c) 2015-2017 Research Organization for Information Science * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * @@ -69,7 +69,5 @@ int MPI_Unpack_external (const char datarep[], const void *inbuf, MPI_Aint insiz rc = ompi_datatype_unpack_external(datarep, inbuf, insize, position, outbuf, outcount, datatype); - - OMPI_ERRHANDLER_RETURN((OMPI_SUCCESS == rc) ? OMPI_SUCCESS : OMPI_ERROR, - MPI_COMM_WORLD, rc, FUNC_NAME); + OMPI_ERRHANDLER_RETURN(rc, MPI_COMM_WORLD, rc, FUNC_NAME); }