Skip to content

Commit

Permalink
Fix the Removed MPI APIs to fatally error if possible.
Browse files Browse the repository at this point in the history
  Addresses open-mpi#6278

  In v4.0.x we intended that if the user did not configure with
  --enable-mpi1-compatibility, that they would get a Fatal error,
  even though we are building those removed symbols into libmpi.
  (to support MPI applications compiled and linked with v3.x)

  This commit changes removed MPI APIs to try to use either the
  error function attribute (if the compiler supports it) or to use
  use the C11 Static Assert (also if supported by the compiler)
  If the compiler doesn't offer this support, the user will instead
  just get an error trying to use a function that wasn't declared.

Signed-off-by: Geoffrey Paulsen <[email protected]>
  • Loading branch information
gpaulsen committed Jan 29, 2019
1 parent e323890 commit 141f14c
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Copyright (c) 2015 University of Houston. All rights reserved.
* Copyright (c) 2015-2018 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017-2018 IBM Corporation. All rights reserved.
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -279,10 +279,20 @@
# define __mpi_interface_deprecated__(msg) __attribute__((__deprecated__))
# endif
# endif
# if (OMPI_ENABLE_MPI1_COMPAT && !OMPI_BUILDING)
# define __mpi_interface_removed__(msg) __mpi_interface_deprecated__(msg)
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
# endif
# if (!OMPI_ENABLE_MPI1_COMPAT && !OMPI_BUILDING)
# if OPAL_HAVE_ATTRIBUTE_ERROR
# define __mpi_interface_removed__(msg) __attribute__((__error__(msg)))
# else
# if (__STDC_VERSION__ >= 201101L)
# define __mpi_interface_removed__(msg) _Static_assert(0,msg)
# endif
# endif
# else
/* If configured with --enable-mpi1-compatibility, emit
* warning with the deprecated function attribute instead.
*/
# define __mpi_interface_removed__(msg) __mpi_interface_deprecated__(msg)
# endif
# endif
#endif
Expand Down Expand Up @@ -1003,19 +1013,18 @@ OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE;

#if (!OMPI_OMIT_MPI1_COMPAT_DECLS || OMPI_BUILDING)
/*
* Removed datatypes. These datatypes are only available if Open MPI
* was configured with --enable-mpi1-compatibility.
* Removed datatypes. These datatypes _SHOULD_ only be available
* if Open MPI was configured with --enable-mpi1-compatibility,
* however they
*
* These datatypes were formally removed from the MPI specification
* and should no longer be used in MPI applications.
*/
#define MPI_UB OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_ub)
#define MPI_LB OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_lb)

OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_lb
__mpi_interface_removed__("MPI_LB was removed in MPI-3.0; use MPI_Type_create_resized instead.");
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub
__mpi_interface_removed__("MPI_UB was removed in MPI-3.0; use MPI_Type_create_resized instead.");
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_lb;
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub;
#endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */

/*
Expand Down Expand Up @@ -2739,7 +2748,7 @@ OMPI_DECLSPEC int MPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
__mpi_interface_removed__("MPI_Type_ub has been removed in MPI-3.0; use MPI_Type_get_extent instead.");
OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
__mpi_interface_removed__("PMPI_Type_ub has been removed in MPI-3.0; use PMPI_Type_get_extent instead.");
#endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */
#endif

#if defined(c_plusplus) || defined(__cplusplus)
}
Expand Down

0 comments on commit 141f14c

Please sign in to comment.