Skip to content

Commit ed9a670

Browse files
committed
Revert "mpi.h.in: delete removed MPI1 functions/datatypes (API change!)"
This reverts commit a6d6be2. Signed-off-by: Geoffrey Paulsen <[email protected]>
1 parent 5cc0141 commit ed9a670

22 files changed

+980
-12
lines changed

config/ompi_config_files.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ AC_DEFUN([OMPI_CONFIG_FILES],[
3636
ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile
3737
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-interfaces.h
3838
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-file-interfaces.h
39+
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-removed-interfaces.h
3940
ompi/mpi/fortran/use-mpi-f08/Makefile
4041
ompi/mpi/fortran/use-mpi-f08/bindings/Makefile
4142
ompi/mpi/fortran/use-mpi-f08/mod/Makefile

ompi/datatype/ompi_datatype_args.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -841,19 +841,25 @@ ompi_datatype_t* ompi_datatype_get_single_predefined_type_from_args( ompi_dataty
841841
return NULL;
842842
}
843843
}
844-
if( NULL == predef ) { /* This is the first iteration */
845-
predef = current_predef;
846-
} else {
847-
/**
848-
* What exactly should we consider as identical types?
849-
* If they are the same MPI level type, or if they map
850-
* to the same OPAL datatype? In other words, MPI_FLOAT
851-
* and MPI_REAL4 are they identical?
852-
*/
853-
if( predef != current_predef ) {
854-
return NULL;
844+
#if OMPI_ENABLE_MPI1_COMPAT
845+
if (current_predef != MPI_LB && current_predef != MPI_UB) {
846+
#endif
847+
if( NULL == predef ) { /* This is the first iteration */
848+
predef = current_predef;
849+
} else {
850+
/**
851+
* What exactly should we consider as identical types?
852+
* If they are the same MPI level type, or if they map
853+
* to the same OPAL datatype? In other words, MPI_FLOAT
854+
* and MPI_REAL4 are they identical?
855+
*/
856+
if( predef != current_predef ) {
857+
return NULL;
858+
}
855859
}
860+
#if OMPI_ENABLE_MPI1_COMPAT
856861
}
862+
#endif
857863
}
858864
return predef;
859865
}

ompi/include/mpi.h.in

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
/* Whether we have FORTRAN REAL*8 or not */
138138
#undef OMPI_HAVE_FORTRAN_REAL8
139139

140+
/* Whether in include MPI-1 compatibility */
141+
#undef OMPI_ENABLE_MPI1_COMPAT
142+
140143
/* Whether we have float _Complex or not */
141144
#undef HAVE_FLOAT__COMPLEX
142145

@@ -277,6 +280,50 @@
277280
# define __mpi_interface_deprecated__(msg) __attribute__((__deprecated__))
278281
# endif
279282
# endif
283+
# endif
284+
285+
/* For MPI removed APIs, there is no generally portable way to cause
286+
* the C compiler to error with a nice message, on the _usage_ of
287+
* one of these symbols. We've gone with tiered appraoch:
288+
*
289+
* If the user configured with --enable-mpi1-compatibility,
290+
* just emit a compiletime warning (via the deprecation function
291+
* attribute) that they're using an MPI1 removed function.
292+
*
293+
* Otherwise, we'd like to issue a fatal error directing the user
294+
* that they've used an MPI1 removed function. If the user's
295+
* compiler supports C11 _Static_assert feature, we #define
296+
* the MPI routines to instead be a call to _Static_assert
297+
* with an appropreate message suggesting the new MPI3 equivalent.
298+
*
299+
* Otherwise, if the user's compiler supports the error function
300+
* attribute, define the MPI routines with that error attribute.
301+
* This is supported by most modern GNU compilers.
302+
*
303+
* Finally if the compiler doesn't support any of those, just
304+
* Don't declare those MPI routines at all in mpi.h
305+
*
306+
* Don't do MACRO magic for building Profiling library as it
307+
* interferes with the above.
308+
*/
309+
# if (OMPI_ENABLE_MPI1_COMPAT || OMPI_BUILDING)
310+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
311+
# define OMPI_REMOVED_USE_STATIC_ASSERT 0
312+
# define __mpi_interface_removed__(func, newfunc) __mpi_interface_deprecated__(#func " was removed in MPI-3.0. Use " #newfunc " instead. continuing...")
313+
# elif (__STDC_VERSION__ >= 201112L)
314+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 1
315+
# define OMPI_REMOVED_USE_STATIC_ASSERT 1
316+
// This macro definition may show up in compiler output. So we both
317+
// outdent it back to column 0 and give it a user-friendly name to
318+
// help users grok what we are trying to tell them here.
319+
#define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(func, newfunc) _Static_assert(0, #func " was removed in MPI-3.0. Use " #newfunc " instead.")
320+
# elif OPAL_HAVE_ATTRIBUTE_ERROR
321+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 0
322+
# define OMPI_REMOVED_USE_STATIC_ASSERT 0
323+
# define __mpi_interface_removed__(func, newfunc) __attribute__((__error__(#func " was removed in MPI-3.0. Use " #newfunc " instead.")))
324+
# else
325+
# define OMPI_OMIT_MPI1_COMPAT_DECLS 1
326+
# define OMPI_REMOVED_USE_STATIC_ASSERT 0
280327
# endif
281328
# endif
282329
#endif
@@ -290,6 +337,22 @@
290337
# define __mpi_interface_deprecated__(msg)
291338
#endif
292339

340+
#if !defined(__mpi_interface_removed__)
341+
# define __mpi_interface_removed__(A,B)
342+
#endif
343+
344+
#if !defined(THIS_SYMBOL_WAS_REMOVED_IN_MPI30)
345+
# define THIS_SYMBOL_WAS_REMOVED_IN_MPI30(func, newfunc)
346+
#endif
347+
348+
#if !defined(OMPI_REMOVED_USE_STATIC_ASSERT)
349+
# define OMPI_REMOVED_USE_STATIC_ASSERT 0
350+
#endif
351+
352+
#if !defined(OMPI_OMIT_MPI1_COMPAT_DECLS)
353+
# define OMPI_OMIT_MPI1_COMPAT_DECLS !OMPI_ENABLE_MPI1_COMPAT
354+
#endif
355+
293356
/*
294357
* To accomodate programs written for MPI implementations that use a
295358
* straight ROMIO import
@@ -990,6 +1053,33 @@ OMPI_DECLSPEC extern struct ompi_predefined_info_t ompi_mpi_info_env;
9901053
OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUS_IGNORE;
9911054
OMPI_DECLSPEC extern MPI_Fint *MPI_F_STATUSES_IGNORE;
9921055

1056+
/*
1057+
* Removed datatypes. These datatypes are only available if Open MPI
1058+
* was configured with --enable-mpi1-compatibility.
1059+
*
1060+
* These datatypes were formally removed from the MPI specification
1061+
* and should no longer be used in MPI applications.
1062+
*/
1063+
#if (OMPI_ENABLE_MPI1_COMPAT || OMPI_BUILDING)
1064+
# define MPI_UB OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_ub)
1065+
# define MPI_LB OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_lb)
1066+
1067+
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_lb;
1068+
OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub;
1069+
1070+
#else
1071+
/* If not building or configured --enable-mpi1-compatibility, then
1072+
* we don't want these datatypes, instead we define MPI_UB and
1073+
* MPI_LB to our Static Assert message if the compiler supports
1074+
* that staticly assert with a nice message.
1075+
*/
1076+
# if (OMPI_REMOVED_USE_STATIC_ASSERT)
1077+
# define MPI_UB THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_UB, MPI_Type_create_resized);
1078+
# define MPI_LB THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_LB, MPI_Type_create_resized);
1079+
# endif /* OMPI_REMOVED_USE_STATIC_ASSERT */
1080+
#endif /* Removed datatypes */
1081+
1082+
9931083
/*
9941084
* MPI predefined handles
9951085
*/
@@ -2646,6 +2736,98 @@ OMPI_DECLSPEC int OMPI_C_MPI_NULL_DELETE_FN( MPI_Comm comm, int comm_keyval,
26462736
void* extra_state )
26472737
__mpi_interface_deprecated__("MPI_NULL_DELETE_FN was deprecated in MPI-2.0; use MPI_COMM_NULL_DELETE_FN instead.");
26482738

2739+
#if !OMPI_OMIT_MPI1_COMPAT_DECLS
2740+
/*
2741+
* Removed typedefs. These typedefs are only available if Open MPI
2742+
* was configured with --enable-mpi1-compatibility.
2743+
*
2744+
* These typedefs were formally removed from the MPI specification
2745+
* and should no longer be used in MPI applications.
2746+
*
2747+
* Even though MPI_Handler_function is removed, we do not use the
2748+
* attributes marking it as such, because otherwise the compiler
2749+
* will warn for all the functions that are declared using them
2750+
* (e.g., MPI_Errhandler_create).
2751+
*/
2752+
typedef void (MPI_Handler_function)(MPI_Comm *, int *, ...);
2753+
/* MPI_Handler_function was removed in MPI-3.0; use MPI_Comm_use_errhandler_function instead. */
2754+
2755+
/*
2756+
* Removed prototypes. These prototypes are only available if Open
2757+
* MPI was configured with --enable-mpi1-compatibility.
2758+
*
2759+
* These functions were formally removed from the MPI specification
2760+
* and should no longer be used in MPI applications.
2761+
*/
2762+
OMPI_DECLSPEC int MPI_Address(void *location, MPI_Aint *address)
2763+
__mpi_interface_removed__(MPI_Address, MPI_Get_address);
2764+
OMPI_DECLSPEC int PMPI_Address(void *location, MPI_Aint *address)
2765+
__mpi_interface_removed__(PMPI_Address, PMPI_Get_address);
2766+
OMPI_DECLSPEC int MPI_Errhandler_create(MPI_Handler_function *function,
2767+
MPI_Errhandler *errhandler)
2768+
__mpi_interface_removed__(MPI_Errhandler_create, MPI_Comm_create_errhandler);
2769+
OMPI_DECLSPEC int PMPI_Errhandler_create(MPI_Handler_function *function,
2770+
MPI_Errhandler *errhandler)
2771+
__mpi_interface_removed__(PMPI_Errhandler_create, PMPI_Comm_create_errhandler);
2772+
OMPI_DECLSPEC int MPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler *errhandler)
2773+
__mpi_interface_removed__(MPI_Errhandler_get, MPI_Comm_get_errhandler);
2774+
OMPI_DECLSPEC int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler *errhandler)
2775+
__mpi_interface_removed__(PMPI_Errhandler_get, PMPI_Comm_get_errhandler);
2776+
OMPI_DECLSPEC int MPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler)
2777+
__mpi_interface_removed__(MPI_Errhandler_set, MPI_Comm_set_errhandler);
2778+
OMPI_DECLSPEC int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler)
2779+
__mpi_interface_removed__(PMPI_Errhandler_set, PMPI_Comm_set_errhandler);
2780+
OMPI_DECLSPEC int MPI_Type_extent(MPI_Datatype type, MPI_Aint *extent)
2781+
__mpi_interface_removed__(MPI_Type_extent, MPI_Type_get_extent);
2782+
OMPI_DECLSPEC int PMPI_Type_extent(MPI_Datatype type, MPI_Aint *extent)
2783+
__mpi_interface_removed__(PMPI_Type_extent, PMPI_Type_get_extent);
2784+
OMPI_DECLSPEC int MPI_Type_hindexed(int count, int array_of_blocklengths[],
2785+
MPI_Aint array_of_displacements[],
2786+
MPI_Datatype oldtype, MPI_Datatype *newtype)
2787+
__mpi_interface_removed__(MPI_Type_hindexed, MPI_Type_create_hindexed);
2788+
OMPI_DECLSPEC int PMPI_Type_hindexed(int count, int array_of_blocklengths[],
2789+
MPI_Aint array_of_displacements[],
2790+
MPI_Datatype oldtype, MPI_Datatype *newtype)
2791+
__mpi_interface_removed__(PMPI_Type_hindexed, PMPI_Type_create_hindexed);
2792+
OMPI_DECLSPEC int MPI_Type_hvector(int count, int blocklength, MPI_Aint stride,
2793+
MPI_Datatype oldtype, MPI_Datatype *newtype)
2794+
__mpi_interface_removed__(MPI_Type_hvector, MPI_Type_create_hvector);
2795+
OMPI_DECLSPEC int PMPI_Type_hvector(int count, int blocklength, MPI_Aint stride,
2796+
MPI_Datatype oldtype, MPI_Datatype *newtype)
2797+
__mpi_interface_removed__(PMPI_Type_hvector, PMPI_Type_create_hvector);
2798+
OMPI_DECLSPEC int MPI_Type_lb(MPI_Datatype type, MPI_Aint *lb)
2799+
__mpi_interface_removed__(MPI_Type_lb, MPI_Type_get_extent);
2800+
OMPI_DECLSPEC int PMPI_Type_lb(MPI_Datatype type, MPI_Aint *lb)
2801+
__mpi_interface_removed__(PMPI_Type_lb, PMPI_Type_get_extent);
2802+
OMPI_DECLSPEC int MPI_Type_struct(int count, int array_of_blocklengths[],
2803+
MPI_Aint array_of_displacements[],
2804+
MPI_Datatype array_of_types[],
2805+
MPI_Datatype *newtype)
2806+
__mpi_interface_removed__(MPI_Type_struct, MPI_Type_create_struct);
2807+
OMPI_DECLSPEC int PMPI_Type_struct(int count, int array_of_blocklengths[],
2808+
MPI_Aint array_of_displacements[],
2809+
MPI_Datatype array_of_types[],
2810+
MPI_Datatype *newtype)
2811+
__mpi_interface_removed__(PMPI_Type_struct, PMPI_Type_create_struct);
2812+
OMPI_DECLSPEC int MPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
2813+
__mpi_interface_removed__(MPI_Type_ub, MPI_Type_get_extent);
2814+
OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub)
2815+
__mpi_interface_removed__(PMPI_Type_ub, PMPI_Type_get_extent);
2816+
#endif /* !OMPI_OMIT_MPI1_COMPAT_DECLS */
2817+
2818+
#if OMPI_REMOVED_USE_STATIC_ASSERT
2819+
#define MPI_Address(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Address, MPI_Get_address)
2820+
#define MPI_Errhandler_create(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Errhandler_create, MPI_Comm_create_errhandler)
2821+
#define MPI_Errhandler_get(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Errhandler_get, MPI_Comm_get_errhandler)
2822+
#define MPI_Errhandler_set(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Errhandler_set, MPI_Comm_set_errhandler)
2823+
#define MPI_Type_extent(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_extent, MPI_Type_get_extent)
2824+
#define MPI_Type_hindexed(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_hindexed, MPI_Type_create_hindexed)
2825+
#define MPI_Type_hvector(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_hvector, MPI_Type_create_hvector)
2826+
#define MPI_Type_lb(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_lb, MPI_Type_get_extent)
2827+
#define MPI_Type_struct(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_struct, MPI_Type_create_struct)
2828+
#define MPI_Type_ub(...) THIS_SYMBOL_WAS_REMOVED_IN_MPI30(MPI_Type_ub, MPI_Type_get_extent)
2829+
#endif
2830+
26492831
#if defined(c_plusplus) || defined(__cplusplus)
26502832
}
26512833
#endif

ompi/mpi/c/Makefile.am

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,20 @@ libmpi_c_mpi_la_SOURCES = \
437437
win_wait.c
438438

439439

440+
if OMPI_ENABLE_MPI1_COMPAT
441+
libmpi_c_mpi_la_SOURCES += \
442+
address.c \
443+
errhandler_create.c \
444+
errhandler_get.c \
445+
errhandler_set.c \
446+
type_extent.c \
447+
type_hindexed.c \
448+
type_hvector.c \
449+
type_lb.c \
450+
type_struct.c \
451+
type_ub.c
452+
endif
453+
440454
# Conditionally install the header files
441455

442456
if WANT_INSTALL_HEADERS

ompi/mpi/c/address.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2015 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
14+
* Copyright (c) 2019 IBM Corporation. All rights reserved.
15+
* $COPYRIGHT$
16+
*
17+
* Additional copyrights may follow
18+
*
19+
* $HEADER$
20+
*/
21+
22+
#include "ompi_config.h"
23+
#include <stdio.h>
24+
25+
/* This implementation has been removed from the MPI 3.0 standard.
26+
* Open MPI v4.0.x is keeping the implementation in the library, but
27+
* removing the prototypes from the headers, unless the user configures
28+
* with --enable-mpi1-compatibility.
29+
*/
30+
31+
#include "ompi/mpi/c/bindings.h"
32+
#include "ompi/runtime/params.h"
33+
#include "ompi/communicator/communicator.h"
34+
#include "ompi/errhandler/errhandler.h"
35+
36+
#if OMPI_BUILD_MPI_PROFILING
37+
#if OPAL_HAVE_WEAK_SYMBOLS
38+
#pragma weak MPI_Address = PMPI_Address
39+
#endif
40+
/* undef before defining, to prevent possible redefinition when
41+
* using _Static_assert to error on usage of removed functions.
42+
*/
43+
#undef MPI_Address
44+
#define MPI_Address PMPI_Address
45+
#endif
46+
47+
static const char FUNC_NAME[] = "MPI_Address";
48+
49+
50+
int MPI_Address(void *location, MPI_Aint *address)
51+
{
52+
53+
OPAL_CR_NOOP_PROGRESS();
54+
55+
if( MPI_PARAM_CHECK ) {
56+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
57+
if (NULL == location || NULL == address) {
58+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
59+
}
60+
}
61+
62+
*address = (MPI_Aint)location;
63+
return MPI_SUCCESS;
64+
}

0 commit comments

Comments
 (0)