Skip to content

Commit 0d6d5d4

Browse files
committed
Fixes Issue 6278 (removed prototypes only warning)
This commit is intended to be cherry-picked to v4.0.x and the following commit will ammend to this functionality for master's removal. Changes the prototypes for MPI removed functions in the following ways: There are 4 cases: - User wants MPI-1 compatibility (--enable-mpi1-compatibility) MPI_Address (and friends) are declared in mpi.h with deprecation notice - User does not want MPI-1 compatibility, and has a C11-capable compiler Declare an MPI_Address (etc.) macro in mpi.h, which will cause a compile-time error using _Static_assert C11 feature - User does not want MPI-1 compatibility, and does not have a C11-capable compiler - User does not want MPI-1 compatibility, and does not have a C11-capable compiler, but the compiler supports error function attributes. Declare an MPI_Address (etc.) macro in mpi.h, which will cause a compile-time error using error function attribute. - User does not want MPI-1 compatibility, and does not have a C11-capable compiler, or a compiler that supports error function attributes. Do not declare MPI_Address (etc.) in mpi.h at all. Unless the user is compiling with something like -Werror, this will allow the user's code to compile. We are choosing this because it seems like a losing battle to make some kind of compile time error that is friendly to the user (and doesn't make it look like mpi.h itself is broken). On v4.0.x, this will allow the user code to both compile (albeit with a warning) and link (because the MPI_Address will be in the MPI library because we are preserving ABI back to 3.0.x). On master/v5.0.x, this will allow the user code to compile, but it will fail to link (because the MPI_Address symbol will not be in the MPI library). (cherry picked from commit 4214b5a) Signed-off-by: Geoffrey Paulsen <[email protected]> Conflicts: ompi/include/mpi.h.in Conflicts: ompi/include/mpi.h.in
1 parent e2c7224 commit 0d6d5d4

File tree

1 file changed

+64
-43
lines changed

1 file changed

+64
-43
lines changed

ompi/include/mpi.h.in

Lines changed: 64 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Copyright (c) 2015 University of Houston. All rights reserved.
2020
* Copyright (c) 2015-2018 Research Organization for Information Science
2121
* and Technology (RIST). All rights reserved.
22-
* Copyright (c) 2017-2018 IBM Corporation. All rights reserved.
22+
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
2323
* $COPYRIGHT$
2424
*
2525
* Additional copyrights may follow
@@ -279,9 +279,29 @@
279279
# define __mpi_interface_deprecated__(msg) __attribute__((__deprecated__))
280280
# endif
281281
# endif
282-
# if OMPI_ENABLE_MPI1_COMPAT
283-
# define __mpi_interface_removed__(msg) __mpi_interface_deprecated__(msg)
282+
# endif
283+
284+
/* For removed API, there is no portable way to cause the
285+
* C compiler to error with a nice message on the usage of
286+
* one of these symbols, so instead we use a C11 static_assert
287+
* If the user is not using a C11 compiler, they will get an
288+
* undefined reference, but no line number or nice message.
289+
*/
290+
# if (OMPI_ENABLE_MPI1_COMPAT || OMPI_BUILDING)
291+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
292+
# define MPI_INTERFACE_REMOVED(func, newfunc, ...) func(__VA_ARGS) __mpi_interface_deprecated__((#func " was removed in MPI-3.0. Use " #newfunc " instead. continuing..."))
293+
# else
294+
# if (__STDC_VERSION__ >= 201112L)
295+
# define MPI_INTERFACE_REMOVED(func, newfunc, ...) _Static_assert(0, #func " was removed in MPI-3.0. Use " #newfunc " instead.")
296+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
297+
# else
298+
# if OPAL_HAVE_ATTRIBUTE_ERROR
299+
# define MPI_INTERFACE_REMOVED(func, newfunc, ...) func(__VA_ARGS) __attribute__((__error__(#func " was removed in MPI-3.0. Use " #newfunc " instead.")))
284300
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
301+
# else
302+
# define MPI_INTERFACE_REMOVED(func, newfunc, ...) func(__VA_ARGS)
303+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 1
304+
# endif
285305
# endif
286306
# endif
287307
# endif
@@ -2687,62 +2707,63 @@ typedef void (MPI_Handler_function)(MPI_Comm *, int *, ...);
26872707
* These functions were formally removed from the MPI specification
26882708
* and should no longer be used in MPI applications.
26892709
*/
2690-
OMPI_DECLSPEC int MPI_Address(void *location, MPI_Aint *address)
2691-
__mpi_interface_removed__("MPI_Address was removed in MPI-3.0; use MPI_Get_address instead.");
2692-
OMPI_DECLSPEC int PMPI_Address(void *location, MPI_Aint *address)
2693-
__mpi_interface_removed__("PMPI_Address was removed in MPI-3.0; use MPI_Get_address instead.");
2710+
OMPI_DECLSPEC int MPI_Address(void *location, MPI_Aint *address);
2711+
#define MPI_Address(...) MPI_INTERFACE_REMOVED(MPI_Address, MPI_Get_address)
2712+
OMPI_DECLSPEC int PMPI_Address(void *location, MPI_Aint *address);
2713+
#define PMPI_Address(...) MPI_INTERFACE_REMOVED(PMPI_Address, PMPI_Get_address)
26942714
OMPI_DECLSPEC int MPI_Errhandler_create(MPI_Handler_function *function,
2695-
MPI_Errhandler *errhandler)
2696-
__mpi_interface_removed__("MPI_Errhandler_create was removed in MPI-3.0; use MPI_Comm_create_errhandler instead.");
2715+
MPI_Errhandler *errhandler);
2716+
#define MPI_Errhandler_create MPI_INTERFACE_REMOVED(MPI_Errhandler_create, MPI_Comm_create_errhandler)
26972717
OMPI_DECLSPEC int PMPI_Errhandler_create(MPI_Handler_function *function,
2698-
MPI_Errhandler *errhandler)
2699-
__mpi_interface_removed__("PMPI_Errhandler_create was removed in MPI-3.0; use PMPI_Comm_create_errhandler instead.");
2700-
OMPI_DECLSPEC int MPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler *errhandler)
2701-
__mpi_interface_removed__("MPI_Errhandler_get was removed in MPI-3.0; use MPI_Comm_get_errhandler instead.");
2702-
OMPI_DECLSPEC int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler *errhandler)
2703-
__mpi_interface_removed__("PMPI_Errhandler_get was removed in MPI-3.0; use PMPI_Comm_get_errhandler instead.");
2704-
OMPI_DECLSPEC int MPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler)
2705-
__mpi_interface_removed__("MPI_Errhandler_set was removed in MPI-3.0; use MPI_Comm_set_errhandler instead.");
2706-
OMPI_DECLSPEC int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler)
2707-
__mpi_interface_removed__("PMPI_Errhandler_set was removed in MPI-3.0; use PMPI_Comm_set_errhandler instead.");
2708-
OMPI_DECLSPEC int MPI_Type_extent(MPI_Datatype type, MPI_Aint *extent)
2709-
__mpi_interface_removed__("MPI_Type_extent was removed in MPI-3.0; use MPI_Type_get_extent instead.");
2710-
OMPI_DECLSPEC int PMPI_Type_extent(MPI_Datatype type, MPI_Aint *extent)
2711-
__mpi_interface_removed__("PMPI_Type_extent was removed in MPI-3.0; use PMPI_Type_get_extent instead.");
2718+
MPI_Errhandler *errhandler);
2719+
#define PMPI_Errhandler_create MPI_INTERFACE_REMOVED(PMPI_Errhandler_create, PMPI_Comm_create_errhandler)
2720+
OMPI_DECLSPEC int MPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler *errhandler);
2721+
#define MPI_Errhandler_get(...) MPI_INTERFACE_REMOVED(MPI_Errhandler_get, MPI_Comm_get_errhandler)
2722+
OMPI_DECLSPEC int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler *errhandler);
2723+
#define PMPI_Errhandler_get(...) MPI_INTERFACE_REMOVED(PMPI_Errhandler_get, PMPI_Comm_get_errhandler)
2724+
OMPI_DECLSPEC int MPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler);
2725+
#define MPI_Errhandler_set(...) MPI_INTERFACE_REMOVED(MPI_Errhandler_set, MPI_Comm_set_errhandler)
2726+
OMPI_DECLSPEC int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler);
2727+
#define PMPI_Errhandler_set(...) MPI_INTERFACE_REMOVED(PMPI_Errhandler_set, PMPI_Comm_set_errhandler)
2728+
OMPI_DECLSPEC int MPI_Type_extent(MPI_Datatype type, MPI_Aint *extent);
2729+
#define MPI_Type_extent(...) MPI_INTERFACE_REMOVED(MPI_Type_extent, MPI_Type_get_extent)
2730+
OMPI_DECLSPEC int PMPI_Type_extent(MPI_Datatype type, MPI_Aint *extent);
2731+
#define PMPI_Type_extent(...) MPI_INTERFACE_REMOVED(PMPI_Type_extent, PMPI_Type_get_extent)
27122732
OMPI_DECLSPEC int MPI_Type_hindexed(int count, int array_of_blocklengths[],
27132733
MPI_Aint array_of_displacements[],
2714-
MPI_Datatype oldtype, MPI_Datatype *newtype)
2715-
__mpi_interface_removed__("MPI_Type_hindexed was removed in MPI-3.0; use MPI_Type_create_hindexed instead.");
2734+
MPI_Datatype oldtype, MPI_Datatype *newtype);
2735+
#define MPI_Type_hindexed(...) MPI_INTERFACE_REMOVED(MPI_Type_hindexed, MPI_Type_create_hindexed)
27162736
OMPI_DECLSPEC int PMPI_Type_hindexed(int count, int array_of_blocklengths[],
27172737
MPI_Aint array_of_displacements[],
2718-
MPI_Datatype oldtype, MPI_Datatype *newtype)
2719-
__mpi_interface_removed__("PMPI_Type_hindexed was removed in MPI-3.0; use PMPI_Type_create_hindexed instead.");
2738+
MPI_Datatype oldtype, MPI_Datatype *newtype);
2739+
#define PMPI_Type_hindexed(...) MPI_INTERFACE_REMOVED(PMPI_Type_hindexed, PMPI_Type_create_hindexed)
27202740
OMPI_DECLSPEC int MPI_Type_hvector(int count, int blocklength, MPI_Aint stride,
2721-
MPI_Datatype oldtype, MPI_Datatype *newtype)
2722-
__mpi_interface_removed__("MPI_Type_hvector was removed in MPI-3.0; use MPI_Type_create_hvector instead.");
2741+
MPI_Datatype oldtype, MPI_Datatype *newtype);
2742+
#define MPI_Type_hvector(...) MPI_INTERFACE_REMOVED(MPI_Type_hvector, MPI_Type_create_hvector)
27232743
OMPI_DECLSPEC int PMPI_Type_hvector(int count, int blocklength, MPI_Aint stride,
2724-
MPI_Datatype oldtype, MPI_Datatype *newtype)
2725-
__mpi_interface_removed__("PMPI_Type_hvector was removed in MPI-3.0; use PMPI_Type_create_hvector instead.");
2726-
OMPI_DECLSPEC int MPI_Type_lb(MPI_Datatype type, MPI_Aint *lb)
2727-
__mpi_interface_removed__("MPI_Type_lb has been removed in MPI-3.0; use MPI_Type_get_extent instead.");
2728-
OMPI_DECLSPEC int PMPI_Type_lb(MPI_Datatype type, MPI_Aint *lb)
2729-
__mpi_interface_removed__("PMPI_Type_lb has been removed in MPI-3.0; use PMPI_Type_get_extent instead.");
2744+
MPI_Datatype oldtype, MPI_Datatype *newtype);
2745+
#define PMPI_Type_hvector(...) MPI_INTERFACE_REMOVED(PMPI_Type_hvector, PMPI_Type_create_hvector)
2746+
OMPI_DECLSPEC int MPI_Type_lb(MPI_Datatype type, MPI_Aint *lb);
2747+
#define MPI_Type_lb(...) MPI_INTERFACE_REMOVED(MPI_Type_lb, MPI_Type_get_extent)
2748+
OMPI_DECLSPEC int PMPI_Type_lb(MPI_Datatype type, MPI_Aint *lb);
2749+
#define PMPI_Type_lb(...) MPI_INTERFACE_REMOVED(PMPI_Type_lb, PMPI_Type_get_extent)
27302750
OMPI_DECLSPEC int MPI_Type_struct(int count, int array_of_blocklengths[],
27312751
MPI_Aint array_of_displacements[],
27322752
MPI_Datatype array_of_types[],
2733-
MPI_Datatype *newtype)
2734-
__mpi_interface_removed__("MPI_Type_struct was removed in MPI-3.0; use MPI_Type_create_struct instead.");
2753+
MPI_Datatype *newtype);
2754+
#define MPI_Type_struct MPI_INTERFACE_REMOVED(MPI_Type_struct, MPI_Type_create_struct)
27352755
OMPI_DECLSPEC int PMPI_Type_struct(int count, int array_of_blocklengths[],
27362756
MPI_Aint array_of_displacements[],
27372757
MPI_Datatype array_of_types[],
2738-
MPI_Datatype *newtype)
2739-
__mpi_interface_removed__("PMPI_Type_struct was removed in MPI-3.0; use PMPI_Type_create_struct instead.");
2740-
OMPI_DECLSPEC int MPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
2741-
__mpi_interface_removed__("MPI_Type_ub has been removed in MPI-3.0; use MPI_Type_get_extent instead.");
2742-
OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
2743-
__mpi_interface_removed__("PMPI_Type_ub has been removed in MPI-3.0; use PMPI_Type_get_extent instead.");
2758+
MPI_Datatype *newtype);
2759+
#define PMPI_Type_struct MPI_INTERFACE_REMOVED(PMPI_Type_struct, PMPI_Type_create_struct)
2760+
OMPI_DECLSPEC int MPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub);
2761+
#define MPI_Type_ub(...) MPI_INTERFACE_REMOVED(MPI_Type_ub, MPI_Type_get_extent)
2762+
OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub);
2763+
#define PMPI_Type_ub(...) MPI_INTERFACE_REMOVED(PMPI_Type_ub, PMPI_Type_get_extent)
27442764
#endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */
27452765

2766+
27462767
#if defined(c_plusplus) || defined(__cplusplus)
27472768
}
27482769
#endif

0 commit comments

Comments
 (0)