From a4c1511f2b07fdea3d6e95c8b625c93d48d84dbb Mon Sep 17 00:00:00 2001 From: Jake Tronge Date: Thu, 28 Sep 2023 16:51:36 -0600 Subject: [PATCH 1/6] Add initial ABI generation code and new libraries Two external MPI libraries are now created: libmpi.la and libmpi_abi.la. Backend code that was originally in libmpi.la has been extracted into libopen-mpi.la to be linked into both libraries. Parts of the Open MPI C interface are now being generated by a python script (abi.py) from modified source files (named with *.in). This script generates files for both the ompi ABI and the standard ABI from the same source file, also including new bigcount interfaces. To compile standard ABI code, there's a new mpicc_abi compiler wrapper. The standard ABI does not yet include all functions or symbols, so more complicated source files will not compile. ROMIO must be disabled for the code to link, since it's relying on the external MPI interface. Signed-off-by: Jake Tronge --- .gitignore | 5 + config/ompi_config_files.m4 | 1 + config/ompi_configure_options.m4 | 15 + ompi/Makefile.am | 58 +- ompi/attribute/Makefile.am | 2 +- ompi/class/Makefile.am | 3 +- ompi/communicator/Makefile.am | 4 +- ompi/dpm/Makefile.am | 2 +- ompi/errhandler/Makefile.am | 2 +- ompi/file/Makefile.am | 2 +- ompi/group/Makefile.am | 2 +- ompi/include/mpi.h.in | 9 +- ompi/instance/Makefile.am | 2 +- ompi/interlib/Makefile.am | 2 +- ompi/mca/bml/r2/Makefile.am | 2 +- ompi/mca/coll/basic/Makefile.am | 2 +- ompi/mca/coll/demo/Makefile.am | 2 +- ompi/mca/coll/hcoll/Makefile.am | 2 +- ompi/mca/coll/inter/Makefile.am | 2 +- ompi/mca/coll/libnbc/Makefile.am | 2 +- ompi/mca/coll/monitoring/Makefile.am | 2 +- ompi/mca/coll/portals4/Makefile.am | 2 +- ompi/mca/coll/self/Makefile.am | 2 +- ompi/mca/coll/sync/Makefile.am | 2 +- ompi/mca/coll/tuned/Makefile.am | 2 +- ompi/mca/coll/ucc/Makefile.am | 2 +- ompi/mca/common/monitoring/Makefile.am | 2 +- ompi/mca/fbtl/ime/Makefile.am | 2 +- ompi/mca/fbtl/posix/Makefile.am | 2 +- ompi/mca/fs/ime/Makefile.am | 2 +- ompi/mca/fs/lustre/Makefile.am | 2 +- ompi/mca/fs/ufs/Makefile.am | 2 +- .../hook/comm_method/hook_comm_method_fns.c | 2 + ompi/mca/mtl/ofi/Makefile.am | 2 +- ompi/mca/mtl/portals4/Makefile.am | 2 +- ompi/mca/mtl/psm2/Makefile.am | 2 +- ompi/mca/op/avx/Makefile.am | 2 +- ompi/mca/op/example/Makefile.am | 2 +- ompi/mca/osc/monitoring/Makefile.am | 2 +- ompi/mca/osc/portals4/Makefile.am | 2 +- ompi/mca/osc/rdma/Makefile.am | 2 +- ompi/mca/osc/sm/Makefile.am | 2 +- ompi/mca/osc/ucx/Makefile.am | 2 +- ompi/mca/part/persist/Makefile.am | 2 +- ompi/mca/pml/cm/Makefile.am | 2 +- ompi/mca/pml/example/Makefile.am | 2 +- ompi/mca/pml/monitoring/Makefile.am | 2 +- ompi/mca/pml/ob1/Makefile.am | 2 +- ompi/mca/pml/ucx/Makefile.am | 2 +- ompi/mca/pml/v/Makefile.am | 2 +- ompi/mca/topo/basic/Makefile.am | 2 +- ompi/mca/topo/example/Makefile.am | 2 +- ompi/mca/topo/treematch/Makefile.am | 2 +- ompi/mca/vprotocol/example/Makefile.am | 2 +- ompi/mca/vprotocol/pessimist/Makefile.am | 2 +- ompi/message/Makefile.am | 2 +- ompi/mpi/c/Makefile.am | 52 +- ompi/mpi/c/abi.py | 1278 +++++++++++++++++ ompi/mpi/c/abi_details.c | 36 + ompi/mpi/c/abi_supported.c | 28 + ompi/mpi/c/abi_version.c | 30 + ompi/mpi/c/status_c2f.c.in | 33 +- ompi/mpi/c/status_f2c.c.in | 17 +- ompi/mpi/c/wtime.c.in | 2 +- ompi/mpiext/Makefile.am | 2 +- ompi/op/Makefile.am | 2 +- ompi/peruse/Makefile.am | 2 +- ompi/proc/Makefile.am | 2 +- ompi/request/Makefile.am | 6 +- ompi/request/grequest.c | 5 +- ompi/runtime/Makefile.am | 2 +- ompi/tools/wrappers/Makefile.am | 3 +- .../wrappers/mpicc_abi-wrapper-data.txt.in | 26 + ompi/util/Makefile.am | 3 +- ompi/util/status.h | 56 + ompi/win/Makefile.am | 2 +- 76 files changed, 1648 insertions(+), 132 deletions(-) create mode 100755 ompi/mpi/c/abi.py create mode 100644 ompi/mpi/c/abi_details.c create mode 100644 ompi/mpi/c/abi_supported.c create mode 100644 ompi/mpi/c/abi_version.c create mode 100644 ompi/tools/wrappers/mpicc_abi-wrapper-data.txt.in create mode 100644 ompi/util/status.h diff --git a/.gitignore b/.gitignore index dfa2e7c86d0..fc1a3349a33 100644 --- a/.gitignore +++ b/.gitignore @@ -271,6 +271,7 @@ ompi/tools/ompi_info/ompi_info ompi/tools/wrappers/mpic++-wrapper-data.txt ompi/tools/wrappers/mpicc-wrapper-data.txt +ompi/tools/wrappers/mpicc_abi-wrapper-data.txt ompi/tools/wrappers/mpifort-wrapper-data.txt ompi/tools/wrappers/ompi_wrapper_script ompi/tools/wrappers/ompi.pc @@ -534,6 +535,10 @@ docs/man # Generated C Bindings ompi/mpi/c/*_generated*.c +ompi/mpi/c/ompi_*.c +ompi/mpi/c/standard_*.c +ompi/mpi/c/abi.h +ompi/mpi/c/standard_abi # Generated Fortran Bindings ompi/mpi/fortran/use-mpi-f08/*_generated.F90 diff --git a/config/ompi_config_files.m4 b/config/ompi_config_files.m4 index 21d1e3eb791..f378cc3ce00 100644 --- a/config/ompi_config_files.m4 +++ b/config/ompi_config_files.m4 @@ -48,6 +48,7 @@ AC_DEFUN([OMPI_CONFIG_FILES],[ ompi/tools/ompi_info/Makefile ompi/tools/wrappers/Makefile ompi/tools/wrappers/mpicc-wrapper-data.txt + ompi/tools/wrappers/mpicc_abi-wrapper-data.txt ompi/tools/wrappers/mpic++-wrapper-data.txt ompi/tools/wrappers/mpifort-wrapper-data.txt ompi/tools/wrappers/ompi.pc diff --git a/config/ompi_configure_options.m4 b/config/ompi_configure_options.m4 index c00ead8792c..83606e2c555 100644 --- a/config/ompi_configure_options.m4 +++ b/config/ompi_configure_options.m4 @@ -257,4 +257,19 @@ AC_ARG_ENABLE([deprecate-mpif-h], [AS_HELP_STRING([--enable-deprecate-mpif-h], [Mark the mpif.h bindings as deprecated (default: enabled)])]) +AC_MSG_CHECKING([if want to enable standard ABI library]) +AC_ARG_ENABLE([standard-abi], + [AS_HELP_STRING([--enable-standard-abi], + [Enable building the standard ABI library (default: disabled)])]) +if test "$enable_standard_abi" = "yes"; then + AC_MSG_RESULT([yes]) + ompi_standard_abi=1 +else + AC_MSG_RESULT([no]) + ompi_standard_abi=0 +fi +AC_DEFINE_UNQUOTED([OMPI_STANDARD_ABI],[$ompi_standard_abi], + [Whether we want to build the standard ABI library]) +AM_CONDITIONAL(OMPI_STANDARD_ABI,[test "$enable_standard_abi" = "yes"]) + ])dnl diff --git a/ompi/Makefile.am b/ompi/Makefile.am index f855492ef15..a839ab1bff4 100644 --- a/ompi/Makefile.am +++ b/ompi/Makefile.am @@ -126,36 +126,72 @@ DIST_SUBDIRS = \ $(MCA_ompi_FRAMEWORKS_SUBDIRS) \ $(MCA_ompi_FRAMEWORK_COMPONENT_ALL_SUBDIRS) -# Build the main MPI library - +noinst_LTLIBRARIES = libopen-mpi.la lib_LTLIBRARIES = lib@OMPI_LIBMPI_NAME@.la -lib@OMPI_LIBMPI_NAME@_la_SOURCES = -lib@OMPI_LIBMPI_NAME@_la_LIBADD = \ +if OMPI_STANDARD_ABI +lib_LTLIBRARIES += libmpi_abi.la +endif + +# +# ABI Refactor +# +# As required by the standard ABI, ompi must now provide libmpi_abi.la for +# ABI-specific code. Since we also want to avoid breaking the existing ompi +# ABI, the libraries in this directory are now organized as follows: +# +# +----------------------+----------------------+ +# | libmpi_abi.la | libmpi.la | +# +----------------------+----------------------+ +# | libopen-mpi.la | +# +----------------------+----------------------+ +# +# This includes a new library, libopen-mpi.la, that links in all backend code +# built in this directory or SUBDIRs of this directory. Previously everything +# was just linked directly into libmpi.la (lib@OMPI_LIBMPI_NAME@.la). +# +# libmpi_abi.la and libmpi.la both now link in libopen-mpi.la, the only +# difference between them being that one includes the standard ABI functions +# and the other the ompi-specific versions of those. +# + +# Build the Open MPI internal library +libopen_mpi_la_SOURCES = +libopen_mpi_la_LIBADD = \ datatype/libdatatype.la \ debuggers/libdebuggers.la \ + $(OMPI_TOP_BUILDDIR)/opal/lib@OPAL_LIB_NAME@.la \ + $(MCA_ompi_FRAMEWORK_LIBS) \ + $(OMPI_LIBMPI_EXTRA_LIBS) +libopen_mpi_la_DEPENDENCIES = $(libopen_mpi_la_LIBADD) + +# Build the main MPI library +lib@OMPI_LIBMPI_NAME@_la_SOURCES = +lib@OMPI_LIBMPI_NAME@_la_LIBADD = \ + libopen-mpi.la \ mpi/c/libmpi_c.la \ mpi/tool/libmpi_mpit.la \ $(c_mpi_lib) \ $(c_pmpi_lib) \ - $(mpi_fortran_base_lib) \ - $(MCA_ompi_FRAMEWORK_LIBS) \ $(OMPI_MPIEXT_C_LIBS) \ - $(OMPI_LIBMPI_EXTRA_LIBS) + $(mpi_fortran_base_lib) - -lib@OMPI_LIBMPI_NAME@_la_LIBADD += \ - $(OMPI_TOP_BUILDDIR)/opal/lib@OPAL_LIB_NAME@.la -lib@OMPI_LIBMPI_NAME@_la_DEPENDENCIES = $(lib@OMPI_LIBMPI_NAME@_la_LIBADD) lib@OMPI_LIBMPI_NAME@_la_LDFLAGS = \ -version-info $(libmpi_so_version) \ $(OMPI_LIBMPI_EXTRA_LDFLAGS) +# The MPI Standard ABI library +libmpi_abi_la_SOURCES = +libmpi_abi_la_LIBADD = \ + libopen-mpi.la \ + mpi/c/libmpi_c_abi.la + # included subdirectory Makefile.am's and appended-to variables headers = noinst_LTLIBRARIES = include_HEADERS = EXTRA_DIST = lib@OMPI_LIBMPI_NAME@_la_SOURCES += $(headers) +dist_ompidata_DATA = # Conditionally install the header files diff --git a/ompi/attribute/Makefile.am b/ompi/attribute/Makefile.am index cb1193deb2f..0418c1c0cc7 100644 --- a/ompi/attribute/Makefile.am +++ b/ompi/attribute/Makefile.am @@ -22,6 +22,6 @@ headers += \ attribute/attribute.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ attribute/attribute.c \ attribute/attribute_predefined.c diff --git a/ompi/class/Makefile.am b/ompi/class/Makefile.am index 7784da8ad69..ea755a11f3d 100644 --- a/ompi/class/Makefile.am +++ b/ompi/class/Makefile.am @@ -23,6 +23,5 @@ headers += \ class/ompi_seq_tracker.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ class/ompi_seq_tracker.c - diff --git a/ompi/communicator/Makefile.am b/ompi/communicator/Makefile.am index e1d25ad1026..8700ae88f48 100644 --- a/ompi/communicator/Makefile.am +++ b/ompi/communicator/Makefile.am @@ -29,14 +29,14 @@ headers += \ communicator/communicator.h \ communicator/comm_request.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ communicator/comm_init.c \ communicator/comm.c \ communicator/comm_cid.c \ communicator/comm_request.c if WANT_FT_MPI -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ communicator/ft/comm_ft.c communicator/ft/comm_ft_reliable_bcast.c communicator/ft/comm_ft_propagator.c communicator/ft/comm_ft_detector.c communicator/ft/comm_ft_revoke.c endif # WANT_FT_MPI diff --git a/ompi/dpm/Makefile.am b/ompi/dpm/Makefile.am index 02562525b9f..6e32c781ca5 100644 --- a/ompi/dpm/Makefile.am +++ b/ompi/dpm/Makefile.am @@ -17,5 +17,5 @@ EXTRA_DIST += dpm/help-dpm.txt headers += \ dpm/dpm.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ dpm/dpm.c diff --git a/ompi/errhandler/Makefile.am b/ompi/errhandler/Makefile.am index 9f94623a9ff..f8a84c249a1 100644 --- a/ompi/errhandler/Makefile.am +++ b/ompi/errhandler/Makefile.am @@ -30,7 +30,7 @@ headers += \ errhandler/errhandler.h \ errhandler/errhandler_predefined.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ errhandler/errhandler.c \ errhandler/errhandler_invoke.c \ errhandler/errhandler_predefined.c \ diff --git a/ompi/file/Makefile.am b/ompi/file/Makefile.am index e7d846ddde8..b78a18962e7 100644 --- a/ompi/file/Makefile.am +++ b/ompi/file/Makefile.am @@ -22,5 +22,5 @@ headers += \ file/file.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ file/file.c diff --git a/ompi/group/Makefile.am b/ompi/group/Makefile.am index f92a900da8d..850173c4d9f 100644 --- a/ompi/group/Makefile.am +++ b/ompi/group/Makefile.am @@ -25,7 +25,7 @@ headers += \ group/group.h \ group/group_dbg.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ group/group.c \ group/group_init.c \ group/group_set_rank.c \ diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index e838fe66061..dcf20db7262 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -1433,6 +1433,9 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub; /* * MPI API */ +OMPI_DECLSPEC int MPI_Abi_supported(int *flag); +OMPI_DECLSPEC int MPI_Abi_version(int *abi_major, int *abi_minor); +OMPI_DECLSPEC int MPI_Abi_details(int *buflen, char *details, MPI_Info *info); OMPI_DECLSPEC int MPI_Abort(MPI_Comm comm, int errorcode); OMPI_DECLSPEC int MPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp, int target_count, @@ -2169,8 +2172,6 @@ OMPI_DECLSPEC int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int sou int tag, MPI_Comm comm, MPI_Status *status); OMPI_DECLSPEC int MPI_Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status); -OMPI_DECLSPEC int MPI_Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source, - int tag, MPI_Comm comm, MPI_Status *status); OMPI_DECLSPEC int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm); OMPI_DECLSPEC int MPI_Reduce_c(const void *sendbuf, void *recvbuf, MPI_Count count, MPI_Datatype datatype, @@ -3328,8 +3329,6 @@ OMPI_DECLSPEC int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int so int tag, MPI_Comm comm, MPI_Status *status); OMPI_DECLSPEC int PMPI_Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status); -OMPI_DECLSPEC int PMPI_Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source, - int tag, MPI_Comm comm, MPI_Status *status); OMPI_DECLSPEC int PMPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm); OMPI_DECLSPEC int PMPI_Reduce_c(const void *sendbuf, void *recvbuf, MPI_Count count, MPI_Datatype datatype, @@ -4092,6 +4091,8 @@ OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub) #define MPI_Type_ub(...) THIS_FUNCTION_WAS_REMOVED_IN_MPI30(MPI_Type_ub, MPI_Type_get_extent) #endif +#endif /* OMPI_NO_MPI_PROTOTYPES */ + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/ompi/instance/Makefile.am b/ompi/instance/Makefile.am index 2ee7f5d59a3..73bb25273be 100644 --- a/ompi/instance/Makefile.am +++ b/ompi/instance/Makefile.am @@ -23,4 +23,4 @@ headers += instance/instance.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += instance/instance.c +libopen_mpi_la_SOURCES += instance/instance.c diff --git a/ompi/interlib/Makefile.am b/ompi/interlib/Makefile.am index 1a40fe8b260..d80d1d3d937 100644 --- a/ompi/interlib/Makefile.am +++ b/ompi/interlib/Makefile.am @@ -25,5 +25,5 @@ headers += \ interlib/interlib.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ interlib/interlib.c diff --git a/ompi/mca/bml/r2/Makefile.am b/ompi/mca/bml/r2/Makefile.am index 0fdb3e636f3..ea4e7eccc0e 100644 --- a/ompi/mca/bml/r2/Makefile.am +++ b/ompi/mca/bml/r2/Makefile.am @@ -37,7 +37,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_bml_r2_la_SOURCES = $(r2_sources) mca_bml_r2_la_LDFLAGS = -module -avoid-version -mca_bml_r2_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_bml_r2_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_bml_r2_la_SOURCES = $(r2_sources) diff --git a/ompi/mca/coll/basic/Makefile.am b/ompi/mca/coll/basic/Makefile.am index 8e1562c12f9..ad89fe227fb 100644 --- a/ompi/mca/coll/basic/Makefile.am +++ b/ompi/mca/coll/basic/Makefile.am @@ -63,7 +63,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_basic_la_SOURCES = $(sources) mca_coll_basic_la_LDFLAGS = -module -avoid-version -mca_coll_basic_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_basic_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_basic_la_SOURCES =$(sources) diff --git a/ompi/mca/coll/demo/Makefile.am b/ompi/mca/coll/demo/Makefile.am index 1246c5d4389..2ae6731cefa 100644 --- a/ompi/mca/coll/demo/Makefile.am +++ b/ompi/mca/coll/demo/Makefile.am @@ -57,7 +57,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_demo_la_SOURCES = $(sources) mca_coll_demo_la_LDFLAGS = -module -avoid-version -mca_coll_demo_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_demo_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_demo_la_SOURCES = $(sources) diff --git a/ompi/mca/coll/hcoll/Makefile.am b/ompi/mca/coll/hcoll/Makefile.am index 37ec1c96c92..254a97c9a0b 100644 --- a/ompi/mca/coll/hcoll/Makefile.am +++ b/ompi/mca/coll/hcoll/Makefile.am @@ -39,7 +39,7 @@ endif mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_hcoll_la_SOURCES = $(coll_hcoll_sources) -mca_coll_hcoll_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_coll_hcoll_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(coll_hcoll_LIBS) mca_coll_hcoll_la_LDFLAGS = -module -avoid-version $(coll_hcoll_LDFLAGS) diff --git a/ompi/mca/coll/inter/Makefile.am b/ompi/mca/coll/inter/Makefile.am index ea9188cffd4..c82b9f513b9 100644 --- a/ompi/mca/coll/inter/Makefile.am +++ b/ompi/mca/coll/inter/Makefile.am @@ -34,7 +34,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_inter_la_SOURCES = $(sources) mca_coll_inter_la_LDFLAGS = -module -avoid-version -mca_coll_inter_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_inter_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_inter_la_SOURCES = $(sources) diff --git a/ompi/mca/coll/libnbc/Makefile.am b/ompi/mca/coll/libnbc/Makefile.am index 4afa48cdd2c..09b30b4e172 100644 --- a/ompi/mca/coll/libnbc/Makefile.am +++ b/ompi/mca/coll/libnbc/Makefile.am @@ -72,7 +72,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_libnbc_la_SOURCES = $(sources) mca_coll_libnbc_la_LDFLAGS = -module -avoid-version -mca_coll_libnbc_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_libnbc_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_libnbc_la_SOURCES =$(sources) diff --git a/ompi/mca/coll/monitoring/Makefile.am b/ompi/mca/coll/monitoring/Makefile.am index 9c6e96b1c52..cb1eed8b135 100644 --- a/ompi/mca/coll/monitoring/Makefile.am +++ b/ompi/mca/coll/monitoring/Makefile.am @@ -46,7 +46,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_monitoring_la_SOURCES = $(monitoring_sources) mca_coll_monitoring_la_LDFLAGS = -module -avoid-version -mca_coll_monitoring_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_coll_monitoring_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(OMPI_TOP_BUILDDIR)/ompi/mca/common/monitoring/libmca_common_monitoring.la noinst_LTLIBRARIES = $(component_noinst) diff --git a/ompi/mca/coll/portals4/Makefile.am b/ompi/mca/coll/portals4/Makefile.am index 8f9babbd13b..7070e01f2e6 100644 --- a/ompi/mca/coll/portals4/Makefile.am +++ b/ompi/mca/coll/portals4/Makefile.am @@ -33,7 +33,7 @@ AM_CPPFLAGS = $(coll_portals4_CPPFLAGS) mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_portals4_la_SOURCES = $(local_sources) -mca_coll_portals4_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_coll_portals4_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(coll_portals4_LIBS) mca_coll_portals4_la_LDFLAGS = -module -avoid-version $(coll_portals4_LDFLAGS) diff --git a/ompi/mca/coll/self/Makefile.am b/ompi/mca/coll/self/Makefile.am index 6b06aab4028..c4e5e13dc86 100644 --- a/ompi/mca/coll/self/Makefile.am +++ b/ompi/mca/coll/self/Makefile.am @@ -55,7 +55,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_self_la_SOURCES = $(sources) mca_coll_self_la_LDFLAGS = -module -avoid-version -mca_coll_self_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_self_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_self_la_SOURCES =$(sources) diff --git a/ompi/mca/coll/sync/Makefile.am b/ompi/mca/coll/sync/Makefile.am index dad4f8f7138..d1fcfff91b5 100644 --- a/ompi/mca/coll/sync/Makefile.am +++ b/ompi/mca/coll/sync/Makefile.am @@ -46,7 +46,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_sync_la_SOURCES = $(sources) mca_coll_sync_la_LDFLAGS = -module -avoid-version -mca_coll_sync_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_sync_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_sync_la_SOURCES =$(sources) diff --git a/ompi/mca/coll/tuned/Makefile.am b/ompi/mca/coll/tuned/Makefile.am index 82be7bb72aa..73f1f22a171 100644 --- a/ompi/mca/coll/tuned/Makefile.am +++ b/ompi/mca/coll/tuned/Makefile.am @@ -61,7 +61,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_tuned_la_SOURCES = $(sources) mca_coll_tuned_la_LDFLAGS = -module -avoid-version -mca_coll_tuned_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_coll_tuned_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_coll_tuned_la_SOURCES =$(sources) diff --git a/ompi/mca/coll/ucc/Makefile.am b/ompi/mca/coll/ucc/Makefile.am index 8d2f4c7c3eb..95ec95401ac 100644 --- a/ompi/mca/coll/ucc/Makefile.am +++ b/ompi/mca/coll/ucc/Makefile.am @@ -50,7 +50,7 @@ endif mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_coll_ucc_la_SOURCES = $(coll_ucc_sources) -mca_coll_ucc_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_coll_ucc_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(coll_ucc_LIBS) mca_coll_ucc_la_LDFLAGS = -module -avoid-version $(coll_ucc_LDFLAGS) diff --git a/ompi/mca/common/monitoring/Makefile.am b/ompi/mca/common/monitoring/Makefile.am index 28f4d442d27..d0dfa439f7d 100644 --- a/ompi/mca/common/monitoring/Makefile.am +++ b/ompi/mca/common/monitoring/Makefile.am @@ -34,7 +34,7 @@ endif ompi_monitoring_prof_la_LDFLAGS= \ -module -avoid-version -shared $(WRAPPER_EXTRA_LDFLAGS) ompi_monitoring_prof_la_LIBADD = \ - $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ + $(top_builddir)/ompi/libopen-mpi.la \ $(top_builddir)/opal/lib@OPAL_LIB_NAME@.la if OPAL_INSTALL_BINARIES diff --git a/ompi/mca/fbtl/ime/Makefile.am b/ompi/mca/fbtl/ime/Makefile.am index 2dfebbcb0c0..41908982b5e 100644 --- a/ompi/mca/fbtl/ime/Makefile.am +++ b/ompi/mca/fbtl/ime/Makefile.am @@ -30,7 +30,7 @@ AM_CPPFLAGS = $(fbtl_ime_CPPFLAGS) mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_fbtl_ime_la_SOURCES = $(fbtl_ime_sources) -mca_fbtl_ime_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_fbtl_ime_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(fbtl_ime_LIBS) mca_fbtl_ime_la_LDFLAGS = -module -avoid-version $(fbtl_ime_LDFLAGS) diff --git a/ompi/mca/fbtl/posix/Makefile.am b/ompi/mca/fbtl/posix/Makefile.am index 1ce19cb09b7..37a98c30e48 100644 --- a/ompi/mca/fbtl/posix/Makefile.am +++ b/ompi/mca/fbtl/posix/Makefile.am @@ -34,7 +34,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_fbtl_posix_la_SOURCES = $(sources) mca_fbtl_posix_la_LDFLAGS = -module -avoid-version -mca_fbtl_posix_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_fbtl_posix_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(OMPI_TOP_BUILDDIR)/ompi/mca/common/ompio/libmca_common_ompio.la noinst_LTLIBRARIES = $(component_noinst) diff --git a/ompi/mca/fs/ime/Makefile.am b/ompi/mca/fs/ime/Makefile.am index db15704e732..9afbc08115a 100644 --- a/ompi/mca/fs/ime/Makefile.am +++ b/ompi/mca/fs/ime/Makefile.am @@ -37,7 +37,7 @@ AM_CPPFLAGS = $(fs_ime_CPPFLAGS) mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_fs_ime_la_SOURCES = $(fs_ime_sources) -mca_fs_ime_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_fs_ime_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(fs_ime_LIBS) mca_fs_ime_la_LDFLAGS = -module -avoid-version $(fs_ime_LDFLAGS) diff --git a/ompi/mca/fs/lustre/Makefile.am b/ompi/mca/fs/lustre/Makefile.am index bf4f487de7a..9f862506c7d 100644 --- a/ompi/mca/fs/lustre/Makefile.am +++ b/ompi/mca/fs/lustre/Makefile.am @@ -43,7 +43,7 @@ AM_CPPFLAGS = $(fs_lustre_CPPFLAGS) mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_fs_lustre_la_SOURCES = $(fs_lustre_sources) -mca_fs_lustre_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_fs_lustre_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(fs_lustre_LIBS) mca_fs_lustre_la_LDFLAGS = -module -avoid-version $(fs_lustre_LDFLAGS) diff --git a/ompi/mca/fs/ufs/Makefile.am b/ompi/mca/fs/ufs/Makefile.am index 50201a80ca2..aa2e4b728fd 100644 --- a/ompi/mca/fs/ufs/Makefile.am +++ b/ompi/mca/fs/ufs/Makefile.am @@ -34,7 +34,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_fs_ufs_la_SOURCES = $(sources) mca_fs_ufs_la_LDFLAGS = -module -avoid-version -mca_fs_ufs_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_fs_ufs_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_fs_ufs_la_SOURCES = $(sources) diff --git a/ompi/mca/hook/comm_method/hook_comm_method_fns.c b/ompi/mca/hook/comm_method/hook_comm_method_fns.c index b1ab8c200b3..303538ac15f 100644 --- a/ompi/mca/hook/comm_method/hook_comm_method_fns.c +++ b/ompi/mca/hook/comm_method/hook_comm_method_fns.c @@ -511,6 +511,7 @@ ompi_report_comm_methods(int called_from_location) free(p); } +#if 0 MPI_Datatype mydt; MPI_Op myop; MPI_Type_contiguous(sizeof(comm_method_string_conversion_t), MPI_BYTE, &mydt); @@ -521,6 +522,7 @@ ompi_report_comm_methods(int called_from_location) leader_comm->c_coll->coll_allreduce_module); MPI_Op_free(&myop); MPI_Type_free(&mydt); +#endif // Sort communication method string arrays after reduction qsort(&comm_method_string_conversion.str[1], diff --git a/ompi/mca/mtl/ofi/Makefile.am b/ompi/mca/mtl/ofi/Makefile.am index 5842abd3018..fa46bba2d56 100644 --- a/ompi/mca/mtl/ofi/Makefile.am +++ b/ompi/mca/mtl/ofi/Makefile.am @@ -80,7 +80,7 @@ mca_mtl_ofi_la_SOURCES = $(mtl_ofi_sources) mca_mtl_ofi_la_LDFLAGS = \ $(mtl_ofi_LDFLAGS) \ -module -avoid-version -mca_mtl_ofi_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_mtl_ofi_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(OPAL_TOP_BUILDDIR)/opal/mca/common/ofi/lib@OPAL_LIB_NAME@mca_common_ofi.la \ $(mtl_ofi_LIBS) diff --git a/ompi/mca/mtl/portals4/Makefile.am b/ompi/mca/mtl/portals4/Makefile.am index df3f13a5586..437b9343d24 100644 --- a/ompi/mca/mtl/portals4/Makefile.am +++ b/ompi/mca/mtl/portals4/Makefile.am @@ -60,7 +60,7 @@ endif mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_mtl_portals4_la_SOURCES = $(local_sources) -mca_mtl_portals4_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_mtl_portals4_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(mtl_portals4_LIBS) mca_mtl_portals4_la_LDFLAGS = -module -avoid-version $(mtl_portals4_LDFLAGS) diff --git a/ompi/mca/mtl/psm2/Makefile.am b/ompi/mca/mtl/psm2/Makefile.am index 8b889bf726a..af1878c4f08 100644 --- a/ompi/mca/mtl/psm2/Makefile.am +++ b/ompi/mca/mtl/psm2/Makefile.am @@ -59,7 +59,7 @@ endif mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_mtl_psm2_la_SOURCES = $(mtl_psm2_sources) -mca_mtl_psm2_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_mtl_psm2_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(mtl_psm2_LIBS) mca_mtl_psm2_la_LDFLAGS = -module -avoid-version $(mtl_psm2_LDFLAGS) diff --git a/ompi/mca/op/avx/Makefile.am b/ompi/mca/op/avx/Makefile.am index b1d84d90b33..022c2dc7da0 100644 --- a/ompi/mca/op/avx/Makefile.am +++ b/ompi/mca/op/avx/Makefile.am @@ -86,7 +86,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_op_avx_la_SOURCES = $(sources) mca_op_avx_la_LIBADD = $(specialized_op_libs) -mca_op_avx_la_LDFLAGS = -module -avoid-version $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_op_avx_la_LDFLAGS = -module -avoid-version $(top_builddir)/ompi/libopen-mpi.la # Specific information for static builds. diff --git a/ompi/mca/op/example/Makefile.am b/ompi/mca/op/example/Makefile.am index e0990e52716..5b2f80ee706 100644 --- a/ompi/mca/op/example/Makefile.am +++ b/ompi/mca/op/example/Makefile.am @@ -71,7 +71,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component) mca_op_example_la_SOURCES = $(component_sources) mca_op_example_la_LDFLAGS = -module -avoid-version -mca_op_example_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_op_example_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la # Specific information for static builds. # diff --git a/ompi/mca/osc/monitoring/Makefile.am b/ompi/mca/osc/monitoring/Makefile.am index a90ce38c6e3..2567b2a4b54 100644 --- a/ompi/mca/osc/monitoring/Makefile.am +++ b/ompi/mca/osc/monitoring/Makefile.am @@ -31,7 +31,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_osc_monitoring_la_SOURCES = $(monitoring_sources) mca_osc_monitoring_la_LDFLAGS = -module -avoid-version -mca_osc_monitoring_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_osc_monitoring_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(OMPI_TOP_BUILDDIR)/ompi/mca/common/monitoring/libmca_common_monitoring.la noinst_LTLIBRARIES = $(component_noinst) diff --git a/ompi/mca/osc/portals4/Makefile.am b/ompi/mca/osc/portals4/Makefile.am index a7f5a061254..3971fafa7ac 100644 --- a/ompi/mca/osc/portals4/Makefile.am +++ b/ompi/mca/osc/portals4/Makefile.am @@ -36,7 +36,7 @@ endif mcacomponentdir = $(pkglibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_osc_portals4_la_SOURCES = $(portals4_sources) -mca_osc_portals4_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_osc_portals4_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(osc_portals4_LIBS) mca_osc_portals4_la_LDFLAGS = -module -avoid-version $(osc_portals4_LDFLAGS) diff --git a/ompi/mca/osc/rdma/Makefile.am b/ompi/mca/osc/rdma/Makefile.am index 4757ce6aa93..0af844602c1 100644 --- a/ompi/mca/osc/rdma/Makefile.am +++ b/ompi/mca/osc/rdma/Makefile.am @@ -63,7 +63,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_osc_rdma_la_SOURCES = $(rdma_sources) mca_osc_rdma_la_LDFLAGS = -module -avoid-version -mca_osc_rdma_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_osc_rdma_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_osc_rdma_la_SOURCES = $(rdma_sources) diff --git a/ompi/mca/osc/sm/Makefile.am b/ompi/mca/osc/sm/Makefile.am index 01d230d7bf3..db6aedf13f8 100644 --- a/ompi/mca/osc/sm/Makefile.am +++ b/ompi/mca/osc/sm/Makefile.am @@ -34,7 +34,7 @@ endif mcacomponentdir = $(pkglibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_osc_sm_la_SOURCES = $(sm_sources) -mca_osc_sm_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_osc_sm_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(osc_sm_LIBS) mca_osc_sm_la_LDFLAGS = -module -avoid-version $(osc_sm_LDFLAGS) diff --git a/ompi/mca/osc/ucx/Makefile.am b/ompi/mca/osc/ucx/Makefile.am index 77184d83584..4c3fbd6da91 100644 --- a/ompi/mca/osc/ucx/Makefile.am +++ b/ompi/mca/osc/ucx/Makefile.am @@ -34,7 +34,7 @@ endif mcacomponentdir = $(pkglibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_osc_ucx_la_SOURCES = $(ucx_sources) -mca_osc_ucx_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la $(osc_ucx_LIBS) \ +mca_osc_ucx_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la $(osc_ucx_LIBS) \ $(OPAL_TOP_BUILDDIR)/opal/mca/common/ucx/lib@OPAL_LIB_NAME@mca_common_ucx.la mca_osc_ucx_la_LDFLAGS = -module -avoid-version $(osc_ucx_LDFLAGS) diff --git a/ompi/mca/part/persist/Makefile.am b/ompi/mca/part/persist/Makefile.am index fab2975e92b..910ea0a59ad 100644 --- a/ompi/mca/part/persist/Makefile.am +++ b/ompi/mca/part/persist/Makefile.am @@ -42,7 +42,7 @@ local_sources = \ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_part_persist_la_SOURCES = $(local_sources) -mca_part_persist_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_part_persist_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(part_persist_LIBS) mca_part_persist_la_LDFLAGS = -module -avoid-version $(part_persist_LDFLAGS) diff --git a/ompi/mca/pml/cm/Makefile.am b/ompi/mca/pml/cm/Makefile.am index d1a43fe8841..fa7327d6372 100644 --- a/ompi/mca/pml/cm/Makefile.am +++ b/ompi/mca/pml/cm/Makefile.am @@ -43,7 +43,7 @@ local_sources = \ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_pml_cm_la_SOURCES = $(local_sources) -mca_pml_cm_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_pml_cm_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(pml_cm_LIBS) mca_pml_cm_la_LDFLAGS = -module -avoid-version $(pml_cm_LDFLAGS) diff --git a/ompi/mca/pml/example/Makefile.am b/ompi/mca/pml/example/Makefile.am index 4c3588848a9..2ea3b1bb269 100644 --- a/ompi/mca/pml/example/Makefile.am +++ b/ompi/mca/pml/example/Makefile.am @@ -53,7 +53,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_pml_example_la_SOURCES = $(local_sources) mca_pml_example_la_LDFLAGS = -module -avoid-version -mca_pml_example_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_pml_example_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_pml_example_la_SOURCES = $(local_sources) diff --git a/ompi/mca/pml/monitoring/Makefile.am b/ompi/mca/pml/monitoring/Makefile.am index 431f5be9ba9..6e4215de807 100644 --- a/ompi/mca/pml/monitoring/Makefile.am +++ b/ompi/mca/pml/monitoring/Makefile.am @@ -32,7 +32,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_pml_monitoring_la_SOURCES = $(monitoring_sources) mca_pml_monitoring_la_LDFLAGS = -module -avoid-version -mca_pml_monitoring_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \ +mca_pml_monitoring_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la \ $(OMPI_TOP_BUILDDIR)/ompi/mca/common/monitoring/libmca_common_monitoring.la noinst_LTLIBRARIES = $(component_noinst) diff --git a/ompi/mca/pml/ob1/Makefile.am b/ompi/mca/pml/ob1/Makefile.am index 38487f5a2e6..4a84f9ec69b 100644 --- a/ompi/mca/pml/ob1/Makefile.am +++ b/ompi/mca/pml/ob1/Makefile.am @@ -72,7 +72,7 @@ mcacomponent_LTLIBRARIES = $(component_install) mca_pml_ob1_la_SOURCES = $(ob1_sources) mca_pml_ob1_la_LDFLAGS = -module -avoid-version -mca_pml_ob1_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_pml_ob1_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_pml_ob1_la_SOURCES = $(ob1_sources) diff --git a/ompi/mca/pml/ucx/Makefile.am b/ompi/mca/pml/ucx/Makefile.am index fe6c8e47c35..04ab6a445a0 100644 --- a/ompi/mca/pml/ucx/Makefile.am +++ b/ompi/mca/pml/ucx/Makefile.am @@ -37,7 +37,7 @@ endif mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_pml_ucx_la_SOURCES = $(local_sources) -mca_pml_ucx_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la $(pml_ucx_LIBS) \ +mca_pml_ucx_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la $(pml_ucx_LIBS) \ $(OPAL_TOP_BUILDDIR)/opal/mca/common/ucx/lib@OPAL_LIB_NAME@mca_common_ucx.la mca_pml_ucx_la_LDFLAGS = -module -avoid-version $(pml_ucx_LDFLAGS) diff --git a/ompi/mca/pml/v/Makefile.am b/ompi/mca/pml/v/Makefile.am index 3fd61be21df..e68c373e09a 100644 --- a/ompi/mca/pml/v/Makefile.am +++ b/ompi/mca/pml/v/Makefile.am @@ -32,7 +32,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_pml_v_la_SOURCES = $(local_sources) mca_pml_v_la_LDFLAGS = -module -avoid-version -mca_pml_v_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_pml_v_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_pml_v_la_SOURCES = $(local_sources) diff --git a/ompi/mca/topo/basic/Makefile.am b/ompi/mca/topo/basic/Makefile.am index 9ed7b26dadd..907f5ffa282 100644 --- a/ompi/mca/topo/basic/Makefile.am +++ b/ompi/mca/topo/basic/Makefile.am @@ -37,7 +37,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component) mca_topo_basic_la_SOURCES = $(component_sources) mca_topo_basic_la_LDFLAGS = -module -avoid-version -mca_topo_basic_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_topo_basic_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(lib) libmca_topo_basic_la_SOURCES = $(lib_sources) diff --git a/ompi/mca/topo/example/Makefile.am b/ompi/mca/topo/example/Makefile.am index 22acd1a360f..29e78f455a0 100644 --- a/ompi/mca/topo/example/Makefile.am +++ b/ompi/mca/topo/example/Makefile.am @@ -46,7 +46,7 @@ mcacomponentdir = $(pkglibdir) mcacomponent_LTLIBRARIES = $(component) mca_topo_example_la_SOURCES = $(component_sources) mca_topo_example_la_LDFLAGS = -module -avoid-version -mca_topo_example_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_topo_example_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(lib) libmca_topo_example_la_SOURCES = $(lib_sources) diff --git a/ompi/mca/topo/treematch/Makefile.am b/ompi/mca/topo/treematch/Makefile.am index e17d4e18085..eeb694a136f 100644 --- a/ompi/mca/topo/treematch/Makefile.am +++ b/ompi/mca/topo/treematch/Makefile.am @@ -43,7 +43,7 @@ mcacomponentdir = $(pkglibdir) mcacomponent_LTLIBRARIES = $(component) mca_topo_treematch_la_SOURCES = $(component_sources) mca_topo_treematch_la_LDFLAGS = -module -avoid-version $(topo_treematch_LDFLAGS) -mca_topo_treematch_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la $(topo_treematch_LIBS) +mca_topo_treematch_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la $(topo_treematch_LIBS) noinst_LTLIBRARIES = $(lib) libmca_topo_treematch_la_SOURCES = $(lib_sources) diff --git a/ompi/mca/vprotocol/example/Makefile.am b/ompi/mca/vprotocol/example/Makefile.am index 64ec3e4cca0..2d00dbbb1fc 100644 --- a/ompi/mca/vprotocol/example/Makefile.am +++ b/ompi/mca/vprotocol/example/Makefile.am @@ -37,7 +37,7 @@ local_sources = \ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_vprotocol_example_la_SOURCES = $(local_sources) -mca_vprotocol_example_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_vprotocol_example_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la mca_vprotocol_example_la_CFLAGS = mca_vprotocol_example_la_LDFLAGS = -module -avoid-version diff --git a/ompi/mca/vprotocol/pessimist/Makefile.am b/ompi/mca/vprotocol/pessimist/Makefile.am index f037b9f6d00..8f931fccb8e 100644 --- a/ompi/mca/vprotocol/pessimist/Makefile.am +++ b/ompi/mca/vprotocol/pessimist/Makefile.am @@ -50,7 +50,7 @@ mcacomponentdir = $(ompilibdir) mcacomponent_LTLIBRARIES = $(component_install) mca_vprotocol_pessimist_la_SOURCES = $(local_sources) mca_vprotocol_pessimist_la_LDFLAGS = -module -avoid-version -mca_vprotocol_pessimist_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la +mca_vprotocol_pessimist_la_LIBADD = $(top_builddir)/ompi/libopen-mpi.la noinst_LTLIBRARIES = $(component_noinst) libmca_vprotocol_pessimist_la_SOURCES = $(local_sources) diff --git a/ompi/message/Makefile.am b/ompi/message/Makefile.am index 8fc7c07e4cd..b5650a5f81d 100644 --- a/ompi/message/Makefile.am +++ b/ompi/message/Makefile.am @@ -24,5 +24,5 @@ headers += \ message/message.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ message/message.c diff --git a/ompi/mpi/c/Makefile.am b/ompi/mpi/c/Makefile.am index c8fad462772..425d1f22fb6 100644 --- a/ompi/mpi/c/Makefile.am +++ b/ompi/mpi/c/Makefile.am @@ -38,8 +38,11 @@ include $(top_srcdir)/Makefile.ompi-rules noinst_LTLIBRARIES = libmpi_c.la libmpi_c_profile.la +if OMPI_STANDARD_ABI +noinst_LTLIBRARIES += libmpi_c_abi.la libmpi_c_abi_profile.la +endif if BUILD_MPI_BINDINGS_LAYER -noinst_LTLIBRARIES += libmpi_c_noprofile.la +noinst_LTLIBRARIES += libmpi_c_noprofile.la libmpi_c_abi_noprofile.la endif headers = bindings.h @@ -478,18 +481,40 @@ prototype_sources = \ win_wait.c.in \ wtime.c.in -# Include template files in case someone wants to update them EXTRA_DIST = $(prototype_sources) # attr_fn.c contains attribute manipulation functions which do not # profiling implications, and so are always built. libmpi_c_la_SOURCES = \ attr_fn.c +# The MPI_Abi_* functions do not require profiling implementations. +libmpi_c_la_SOURCES += \ + abi_details.c \ + abi_supported.c \ + abi_version.c libmpi_c_la_LIBADD = libmpi_c_profile.la if BUILD_MPI_BINDINGS_LAYER libmpi_c_la_LIBADD += libmpi_c_noprofile.la endif +libmpi_c_abi_la_SOURCES = \ + abi.h \ + attr_fn.c \ + abi_details.c \ + abi_supported.c \ + abi_version.c +libmpi_c_abi_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES +libmpi_c_abi_la_LIBADD = libmpi_c_abi_profile.la +if BUILD_MPI_BINDINGS_LAYER +libmpi_c_abi_la_LIBADD += libmpi_c_abi_noprofile.la +endif + +libmpi_c_abi_profile_la_SOURCES = $(abi_interface_profile_sources) +libmpi_c_abi_profile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=1 + +libmpi_c_abi_noprofile_la_SOURCES = $(abi_interface_profile_sources) +libmpi_c_abi_noprofile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=0 + # Conditionally install the header files if WANT_INSTALL_HEADERS ompidir = $(ompiincludedir)/$(subdir) @@ -497,11 +522,12 @@ ompi_HEADERS = $(headers) endif # -# List of all C files that have profile versions (generated_*.c files were +# List of all C files that have profile versions (*_generated.c files were # generated from prototype_sources above). # # interface_profile_sources = $(prototype_sources:.c.in=_generated.c) +abi_interface_profile_sources =${interface_profile_sources:%=standard_%} # The following are special case functions where we @@ -539,7 +565,8 @@ libmpi_c_noprofile_la_SOURCES = $(interface_profile_sources) libmpi_c_noprofile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=0 # ABI generation rules -%_generated.c: %.c.in +if OMPI_GENERATE_BINDINGS +ompi_%_generated.c: %.c.in $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ --builddir $(abs_top_builddir) \ --srcdir $(abs_top_srcdir) \ @@ -549,5 +576,20 @@ libmpi_c_noprofile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=0 ompi \ $< +standard_%_generated.c: %.c.in + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + source \ + standard \ + $< +abi.h: abi.py $(prototype_sources) + $(OMPI_V_GEN) $(PYTHON) $(srcdir)/abi.py header --srcdir=$(srcdir) $(prototype_sources) > $@ +standard_abi/mpi.h: abi.py $(prototype_sources) + mkdir -p standard_abi + $(OMPI_V_GEN) $(PYTHON) $(srcdir)/abi.py header --srcdir=$(srcdir) --external $(prototype_sources) > $@ +endif # Delete generated files on maintainer-clean -MAINTAINERCLEANFILES = *_generated.c +MAINTAINERCLEANFILES = *_generated.c abi.h standard_abi/ diff --git a/ompi/mpi/c/abi.py b/ompi/mpi/c/abi.py new file mode 100755 index 00000000000..f40986ff981 --- /dev/null +++ b/ompi/mpi/c/abi.py @@ -0,0 +1,1278 @@ +#!/usr/bin/env python3 +# Copyright (c) 2023 Triad National Security, LLC. All rights reserved. +# Copyright (c) 2023 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADERS$ +# +# +"""MPI Standard ABI Generation. + +TEMPLATE SOURCE FILE ASSUMPTIONS: +* Only one function per file +* Nothing (other than blank lines) after closing '}' +* Function prototype is preceded by PROTOTYPE +* All types in the function prototype are converted to one-word capital types + as defined here (to be later converted to ompi or standard ABI types) +* Functions requiring a bigcount implementation should have type COUNT in + place of MPI_Count or int for each count parameter. Bigcount functions will + be generated automatically for any function that includes a COUNT type. +""" +from abc import ABC, abstractmethod +import argparse +import re +import sys +import os + +# C type: const int +ERROR_CLASSES = [ + 'MPI_SUCCESS', + 'MPI_ERR_BUFFER', + 'MPI_ERR_COUNT', + 'MPI_ERR_TYPE', + 'MPI_ERR_TAG', + 'MPI_ERR_COMM', + 'MPI_ERR_RANK', + 'MPI_ERR_REQUEST', + 'MPI_ERR_ROOT', + 'MPI_ERR_GROUP', + 'MPI_ERR_OP', + 'MPI_ERR_TOPOLOGY', + 'MPI_ERR_DIMS', + 'MPI_ERR_ARG', + 'MPI_ERR_UNKNOWN', + 'MPI_ERR_TRUNCATE', + 'MPI_ERR_OTHER', + 'MPI_ERR_INTERN', + 'MPI_ERR_PENDING', + 'MPI_ERR_IN_STATUS', + 'MPI_ERR_ACCESS', + 'MPI_ERR_AMODE', + 'MPI_ERR_ASSERT', + 'MPI_ERR_BAD_FILE', + 'MPI_ERR_BASE', + 'MPI_ERR_CONVERSION', + 'MPI_ERR_DISP', + 'MPI_ERR_DUP_DATAREP', + 'MPI_ERR_FILE_EXISTS', + 'MPI_ERR_FILE_IN_USE', + 'MPI_ERR_FILE', + 'MPI_ERR_INFO_KEY', + 'MPI_ERR_INFO_NOKEY', + 'MPI_ERR_INFO_VALUE', + 'MPI_ERR_INFO', + 'MPI_ERR_IO', + 'MPI_ERR_KEYVAL', + 'MPI_ERR_LOCKTYPE', + 'MPI_ERR_NAME', + 'MPI_ERR_NO_MEM', + 'MPI_ERR_NOT_SAME', + 'MPI_ERR_NO_SPACE', + 'MPI_ERR_NO_SUCH_FILE', + 'MPI_ERR_PORT', + 'MPI_ERR_PROC_ABORTED', + 'MPI_ERR_QUOTA', + 'MPI_ERR_READ_ONLY', + 'MPI_ERR_RMA_ATTACH', + 'MPI_ERR_RMA_CONFLICT', + 'MPI_ERR_RMA_RANGE', + 'MPI_ERR_RMA_SHARED', + 'MPI_ERR_RMA_SYNC', + 'MPI_ERR_RMA_FLAVOR', + 'MPI_ERR_SERVICE', + 'MPI_ERR_SESSION', + 'MPI_ERR_SIZE', + 'MPI_ERR_SPAWN', + 'MPI_ERR_UNSUPPORTED_DATAREP', + 'MPI_ERR_UNSUPPORTED_OPERATION', + 'MPI_ERR_WIN', + 'MPI_T_ERR_CANNOT_INIT', + 'MPI_T_ERR_NOT_INITIALIZED', + 'MPI_T_ERR_MEMORY', + 'MPI_T_ERR_INVALID', + 'MPI_T_ERR_INVALID_INDEX', + 'MPI_T_ERR_INVALID_ITEM', + 'MPI_T_ERR_INVALID_SESSION', + 'MPI_T_ERR_INVALID_HANDLE', + 'MPI_T_ERR_INVALID_NAME', + 'MPI_T_ERR_OUT_OF_HANDLES', + 'MPI_T_ERR_OUT_OF_SESSIONS', + 'MPI_T_ERR_CVAR_SET_NOT_NOW', + 'MPI_T_ERR_CVAR_SET_NEVER', + 'MPI_T_ERR_PVAR_NO_WRITE', + 'MPI_T_ERR_PVAR_NO_STARTSTOP', + 'MPI_T_ERR_PVAR_NO_ATOMIC', + 'MPI_ERR_LASTCODE', +] + +PREDEFINED_DATATYPES = [ + 'MPI_CHAR', + 'MPI_SHORT', + 'MPI_INT', + 'MPI_LONG', + 'MPI_LONG_LONG_INT', + 'MPI_LONG_LONG', + 'MPI_SIGNED_CHAR', + 'MPI_UNSIGNED_CHAR', + 'MPI_UNSIGNED_SHORT', + 'MPI_UNSIGNED', + 'MPI_UNSIGNED_LONG', + 'MPI_UNSIGNED_LONG_LONG', + 'MPI_FLOAT', + 'MPI_DOUBLE', + 'MPI_LONG_DOUBLE', + 'MPI_WCHAR', + 'MPI_C_BOOL', + 'MPI_INT8_T', + 'MPI_INT16_T', + 'MPI_INT32_T', + 'MPI_INT64_T', + 'MPI_UINT8_T', + 'MPI_UINT16_T', + 'MPI_UINT32_T', + 'MPI_UINT64_T', + 'MPI_AINT', + 'MPI_COUNT', + 'MPI_OFFSET', + 'MPI_C_COMPLEX', + 'MPI_C_FLOAT_COMPLEX', + 'MPI_C_DOUBLE_COMPLEX', + 'MPI_C_LONG_DOUBLE_COMPLEX', + 'MPI_BYTE', + 'MPI_PACKED', + 'MPI_CXX_BOOL', + 'MPI_CXX_FLOAT_COMPLEX', + 'MPI_CXX_DOUBLE_COMPLEX', + 'MPI_CXX_LONG_DOUBLE_COMPLEX', + 'MPI_FLOAT_INT', + 'MPI_DOUBLE_INT', + 'MPI_LONG_INT', + 'MPI_2INT', + 'MPI_SHORT_INT', + 'MPI_LONG_DOUBLE_INT', +] + +# C type: MPI_Comm +RESERVED_COMMUNICATORS = [ + 'MPI_COMM_NULL', + 'MPI_COMM_WORLD', + 'MPI_COMM_SELF', +] + +COMMUNICATOR_SPLIT_TYPES = [ + 'MPI_COMM_TYPE_SHARED', + 'MPI_COMM_TYPE_HW_UNGUIDED', + 'MPI_COMM_TYPE_HW_GUIDED', +] + +RESERVED_WINDOWS = [ + 'MPI_WIN_NULL', +] + +RESERVED_REQUESTS = [ + 'MPI_REQUEST_NULL', +] + +RESERVED_INFOS = [ + 'MPI_INFO_ENV', + 'MPI_INFO_NULL', +] + +RESERVED_FILES = [ + 'MPI_FILE_NULL', +] + +IGNORED_STATUS_HANDLES = [ + 'MPI_STATUSES_IGNORE', + 'MPI_STATUS_IGNORE', +] + +COLLECTIVE_OPERATIONS = [ + 'MPI_MAX', + 'MPI_MIN', + 'MPI_SUM', + 'MPI_PROD', + 'MPI_MAXLOC', + 'MPI_MINLOC', + 'MPI_BAND', + 'MPI_BOR', + 'MPI_BXOR', + 'MPI_LAND', + 'MPI_LOR', + 'MPI_LXOR', + 'MPI_REPLACE', + 'MPI_NO_OP', +] + +VARIOUS_CONSTANTS = { + # Just setting this to the same as ompi ABI for right now, but will need to + # match the standard ABI value when defined + 'MPI_MAX_LIBRARY_VERSION_STRING': 256, + 'MPI_MAX_PROCESSOR_NAME': 256, +} + +# Types + +C_OPAQUE_TYPES = { + 'MPI_Aint': 'intptr_t', + 'MPI_Offset': 'int64_t', + 'MPI_Count': 'size_t', + # The below type needs to be set externally depending on Fortran compiler + 'MPI_Fint': 'int64_t', +} + +C_HANDLES = [ + 'MPI_Comm', + 'MPI_Datatype', + 'MPI_Errhandler', + 'MPI_File', + 'MPI_Group', + 'MPI_Info', + 'MPI_Message', + 'MPI_Op', + 'MPI_Request', + 'MPI_Session', + 'MPI_Win', +] + + +class ConvertFuncs: + """Names of conversion functions (between standard ABI and OMPI ABI).""" + + ERROR_CLASS = 'ompi_convert_intern_error_abi_error' + COMM = 'ompi_convert_abi_comm_intern_comm' + DATATYPE = 'ompi_convert_abi_datatype_intern_datatype' + REQUEST = 'ompi_convert_abi_request_intern_request' + STATUS = 'ompi_convert_intern_status_abi_status' + OP = 'ompi_convert_abi_op_intern_op' + WIN = 'ompi_convert_abi_win_intern_win' + INFO = 'ompi_convert_abi_info_intern_info' + FILE = 'ompi_convert_abi_file_intern_file' + + +class ConvertOMPIToStandard: + """Generated function for converting from OMPI to standard ABI.""" + + COMM = 'ompi_convert_comm_ompi_to_standard' + + +# Inline function attributes +INLINE_ATTRS = '__opal_attribute_always_inline__ static inline' + + +def mpi_fn_name_from_base_fn_name(name): + """Convert from a base name to the standard 'MPI_*' name.""" + return f'MPI_{name.capitalize()}' + + +def abi_internal_name(extname): + """Convert from the ABI external name to an internal name. + + Used to avoid conflicts with existing MPI names. + """ + return f'{extname}_ABI_INTERNAL' + + +class ABIHeaderBuilder: + """ABI header builder code.""" + + def __init__(self, prototypes, external=False, file=sys.stdout): + self.file = file + self.external = external + + if external: + mangle_name = lambda name: name + else: + mangle_name = abi_internal_name + + # Build up the list of standard ABI signatures + signatures = [] + for prototype in prototypes: + base_name = mpi_fn_name_from_base_fn_name(prototype.name) + signatures.append(prototype.signature('standard', base_name, + mangle_name=mangle_name)) + # Profiling prototype + signatures.append(prototype.signature('standard', f'P{base_name}', + mangle_name=mangle_name)) + if prototype.need_bigcount: + signatures.append(prototype.signature('standard', f'{base_name}_c', + count_type='MPI_Count', + mangle_name=mangle_name)) + # Profiling prototype + signatures.append(prototype.signature('standard', f'P{base_name}_c', + count_type='MPI_Count', + mangle_name=mangle_name)) + self.signatures = signatures + + def mangle_name(self, extname): + """Mangle names, depending on whether building external or internal header.""" + if self.external: + return extname + return abi_internal_name(extname) + + def dump(self, *pargs, **kwargs): + print(*pargs, **kwargs, file=self.file) + + def dump_lines(self, lines): + lines = indent_lines(lines, 4 * ' ', start=1) + for line in lines: + self.dump(line) + + def generate_error_convert_fn(self): + self.dump(f'{INLINE_ATTRS} int {ConvertFuncs.ERROR_CLASS}(int error_class)') + self.dump('{') + lines = [] + lines.append('switch (error_class) {') + for error in ERROR_CLASSES: + lines.append(f'case {self.mangle_name(error)}:') + lines.append(f'return {error};') + lines.append('default:') + lines.append('return error_class;') + lines.append('}') + self.dump_lines(lines) + self.dump('}') + + def generic_convert(self, fn_name, param_name, type_, value_names): + intern_type = self.mangle_name(type_) + self.dump(f'{INLINE_ATTRS} {type_} {fn_name}({intern_type} {param_name})') + self.dump('{') + lines = [] + for i, value_name in enumerate(value_names): + intern_name = self.mangle_name(value_name) + if i == 0: + lines.append('if (%s == %s) {' % (intern_name, param_name)) + else: + lines.append('} else if (%s == %s) {' % (intern_name, param_name)) + lines.append(f'return {value_name};') + lines.append('}') + lines.append(f'return ({type_}) {param_name};') + self.dump_lines(lines) + self.dump('}') + + def generic_convert_reverse(self, fn_name, param_name, type_, value_names): + intern_type = self.mangle_name(type_) + self.dump(f'{INLINE_ATTRS} {intern_type} {fn_name}({type_} {param_name})') + self.dump('{') + lines = [] + for i, value_name in enumerate(value_names): + intern_name = self.mangle_name(value_name) + if i == 0: + lines.append('if (%s == %s) {' % (value_name, param_name)) + else: + lines.append('} else if (%s == %s) {' % (value_name, param_name)) + lines.append(f'return {intern_name};') + lines.append('}') + lines.append(f'return ({intern_type}) {param_name};') + self.dump_lines(lines) + self.dump('}') + + def generate_comm_convert_fn(self): + self.generic_convert(ConvertFuncs.COMM, 'comm', 'MPI_Comm', RESERVED_COMMUNICATORS) + + def generate_comm_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.COMM, 'comm', 'MPI_Comm', RESERVED_COMMUNICATORS) + + def generate_info_convert_fn(self): + self.generic_convert(ConvertFuncs.INFO, 'info', 'MPI_Info', RESERVED_INFOS) + + def generate_file_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertFuncs.FILE, 'file', 'MPI_File', RESERVED_FILES) + + def generate_datatype_convert_fn(self): + self.generic_convert(ConvertFuncs.DATATYPE, 'datatype', 'MPI_Datatype', PREDEFINED_DATATYPES) + + def generate_op_convert_fn(self): + self.generic_convert(ConvertFuncs.OP, 'op', 'MPI_Op', COLLECTIVE_OPERATIONS) + + def generate_win_convert_fn(self): + self.generic_convert(ConvertFuncs.WIN, 'win', 'MPI_Win', RESERVED_WINDOWS) + + def generate_pointer_convert_fn(self, type_, fn_name, constants): + abi_type = self.mangle_name(type_) + self.dump(f'{INLINE_ATTRS} void {fn_name}({abi_type} *ptr)') + self.dump('{') + lines = [] + for i, ompi_name in enumerate(constants): + abi_name = self.mangle_name(ompi_name) + if i == 0: + lines.append('if (%s == (%s) *ptr) {' % (ompi_name, type_)) + else: + lines.append('} else if (%s == (%s) *ptr) {' % (ompi_name, type_)) + lines.append(f'*ptr = {abi_name};') + lines.append('}') + self.dump_lines(lines) + self.dump('}') + + def generate_request_convert_fn(self): + self.generate_pointer_convert_fn('MPI_Request', ConvertFuncs.REQUEST, RESERVED_REQUESTS) + + def generate_file_convert_fn(self): + self.generate_pointer_convert_fn('MPI_File', ConvertFuncs.FILE, RESERVED_FILES) + + def generate_status_convert_fn(self): + type_ = 'MPI_Status' + abi_type = self.mangle_name(type_) + self.dump(f'{INLINE_ATTRS} void {ConvertFuncs.STATUS}({abi_type} *out, {type_} *inp)') + self.dump('{') + self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;') + self.dump(' out->MPI_TAG = inp->MPI_TAG;') + self.dump(f' out->MPI_ERROR = {ConvertFuncs.ERROR_CLASS}(inp->MPI_ERROR);') + # TODO: What to do with the private fields? + self.dump('}') + + def define(self, type_, name, value): + self.dump(f'#define {name} OMPI_CAST_CONSTANT({type_}, {value})') + + def define_all(self, type_, constants): + for i, const in enumerate(constants): + self.define(self.mangle_name(type_), self.mangle_name(const), i + 1) + self.dump() + + def dump_header(self): + header_guard = '_ABI_INTERNAL_' + self.dump(f'#ifndef {header_guard}') + self.dump(f'#define {header_guard}') + + self.dump('#include "stddef.h"') + self.dump('#include "stdint.h"') + + self.dump(""" +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif +""") + + self.dump(""" +#if defined(c_plusplus) || defined(__cplusplus) +#define OMPI_CAST_CONSTANT(type, value) (static_cast (static_cast (value))) +#else +#define OMPI_CAST_CONSTANT(type, value) ((type) ((void *) value)) +#endif +""") + + for i, err in enumerate(ERROR_CLASSES): + self.dump(f'#define {self.mangle_name(err)} {i + 1}') + self.dump() + + self.define_all('MPI_Datatype', PREDEFINED_DATATYPES) + self.define_all('MPI_Op', COLLECTIVE_OPERATIONS) + self.define_all('MPI_Comm', RESERVED_COMMUNICATORS) + self.define_all('MPI_Request', RESERVED_REQUESTS) + self.define_all('MPI_Win', RESERVED_WINDOWS) + self.define_all('MPI_Info', RESERVED_INFOS) + self.define_all('MPI_File', RESERVED_FILES) + + for name, value in VARIOUS_CONSTANTS.items(): + self.dump(f'#define {self.mangle_name(name)} {value}') + self.dump() + + status_type = self.mangle_name('MPI_Status') + for i, name in enumerate(IGNORED_STATUS_HANDLES): + self.define(f'{status_type} *', self.mangle_name(name), i + 1) + self.dump() + + for i, name in enumerate(COMMUNICATOR_SPLIT_TYPES): + self.dump(f'#define {self.mangle_name(name)} {i}') + self.dump() + + for mpi_type, c_type in C_OPAQUE_TYPES.items(): + self.dump(f'typedef {c_type} {self.mangle_name(mpi_type)};') + self.dump() + + for handle in C_HANDLES: + prefix, suffix = handle.split('_') + name = f'{prefix}_ABI_{suffix}' + self.dump(f'typedef struct {self.mangle_name(name)} *{self.mangle_name(handle)};') + self.dump() + self.dump(""" +struct MPI_Status_ABI { + int MPI_SOURCE; + int MPI_TAG; + int MPI_ERROR; + int mpi_abi_private[5]; +};""") + self.dump(f'typedef struct MPI_Status_ABI {self.mangle_name("MPI_Status")};') + self.dump() + # Function signatures + for sig in self.signatures: + self.dump(f'{sig};') + self.dump('int MPI_Abi_details(int *buflen, char *details, MPI_Info *info);') + self.dump('int MPI_Abi_supported(int *flag);') + self.dump('int MPI_Abi_version(int *abi_major, int *abi_minor);') + if not self.external: + # Now generate the conversion code + self.generate_error_convert_fn() + self.generate_comm_convert_fn() + self.generate_comm_convert_fn_intern_to_abi() + self.generate_info_convert_fn() + self.generate_file_convert_fn() + self.generate_datatype_convert_fn() + self.generate_op_convert_fn() + self.generate_win_convert_fn() + self.generate_request_convert_fn() + self.generate_status_convert_fn() + + self.dump(""" +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif +""") + self.dump(f'#endif /* {header_guard} */') + + +class Parameter: + + def __init__(self, text): + """Parse a parameter.""" + # parameter in the form "TYPE NAME" or "TYPE NAME:COUNT_VAR" + type_, namecount = text.split() + if ':' in namecount: + name, count_param = namecount.split(':') + else: + name, count_param = namecount, None + self.type_ = type_ + self.name = name + self.count_param = count_param + + def construct(self, abi_type, **kwargs): + """Construct the type parameter for the given ABI.""" + return Type.construct(abi_type, type_=self.type_, name=self.name, + count_param=self.count_param, **kwargs) + + +class ReturnType: + """Return type wrapper.""" + + def __init__(self, type_): + self.type_ = type_ + + def construct(self, abi_type, **kwargs): + """Construct the return type for the given ABI.""" + return Type.construct(abi_type, type_=self.type_, **kwargs) + + +class Type(ABC): + """Type representation.""" + + PARAMS_OMPI_ABI = {} + + PARAMS_STANDARD_ABI = {} + + def __init__(self, type_, name=None, + mangle_name=lambda name: abi_internal_name(name), + count_param=None, **kwargs): + self.type = type_ + self.name = name + self.count_param = count_param + self.mangle_name = mangle_name + + @staticmethod + def construct(abi_type, type_, **kwargs): + """Construct the parameter for the given ABI and type.""" + if abi_type == 'ompi': + return Type.PARAMS_OMPI_ABI[type_](type_, **kwargs) + elif abi_type == 'standard': + return Type.PARAMS_STANDARD_ABI[type_](type_, **kwargs) + else: + raise RuntimeError(f'invalid ABI type {abi_type}') + + @staticmethod + def add_type(type_name, abi_type=('ompi', 'standard')): + """Add a new class corresponding to a type.""" + def wrapper(class_): + if 'ompi' in abi_type: + Type.PARAMS_OMPI_ABI[type_name] = class_ + if 'standard' in abi_type: + Type.PARAMS_STANDARD_ABI[type_name] = class_ + # Parameter.TYPES[type_] = class_ + return class_ + return wrapper + + @property + def is_count(self): + """Return True if this parameter is a count (requiring bigcount API).""" + return False + + @property + def init_code(self): + """Return the initialization code needed for an ABI wrapper.""" + return [] + + @property + def final_code(self): + """Return the finalization code needed for an ABI wrapper.""" + return [] + + def return_code(self, name): + """Process a value and then build up a return statement.""" + return [f'return {name};'] + + @property + def argument(self): + """Return the argument text required for passing an argument to a function.""" + return self.name + + @abstractmethod + def type_text(self, count_type=None): + """Return the source text corresponding to a type definition.""" + + def tmp_type_text(self, count_type=None): + """Return source text corresponding to a temporary type definition before conversion.""" + return self.type_text(count_type=count_type) + + def parameter(self, count_type=None, **kwargs): + return f'{self.type_text(count_type)} {self.name}' + + +@Type.add_type('ERROR_CLASS') +class TypeErrorClass(Type): + + def type_text(self, count_type=None): + return 'int' + + def return_code(self, name): + return [f'return {ConvertFuncs.ERROR_CLASS}({name});'] + + +@Type.add_type('BUFFER') +class TypeBuffer(Type): + + def type_text(self, count_type=None): + return 'const void *' + + +@Type.add_type('BUFFER_OUT') +class TypeBufferOut(Type): + + def type_text(self, count_type=None): + return f'void *' + + +@Type.add_type('COUNT') +class TypeCount(Type): + + @property + def is_count(self): + return True + + def type_text(self, count_type=None): + return 'int' if count_type is None else count_type + + +@Type.add_type('INT') +class TypeBufferOut(Type): + + def type_text(self, count_type=None): + return 'int' + + +@Type.add_type('AINT') +class TypeBufferOut(Type): + + def type_text(self, count_type=None): + return 'MPI_Aint' + + +@Type.add_type('INT_OUT') +class TypeBufferOut(Type): + + def type_text(self, count_type=None): + return 'int *' + + def parameter(self, count_type=None, **kwargs): + if self.count_param is None: + return f'int *{self.name}' + else: + return f'int {self.name}[]' + + +@Type.add_type('DOUBLE') +class TypeDouble(Type): + + def type_text(self, count_type=None): + return 'double' + + +@Type.add_type('ARGV') +class TypeArgv(Type): + + def type_text(self, count_type=None): + return 'char ***' + + +@Type.add_type('DATATYPE', abi_type=['ompi']) +class TypeDatatype(Type): + + def type_text(self, count_type=None): + return 'MPI_Datatype' + + +class StandardABIType(Type): + + @property + def tmpname(self): + return f'{self.name}_tmp' + + @property + def argument(self): + return self.tmpname + + +@Type.add_type('DATATYPE', abi_type=['standard']) +class TypeDatatype(StandardABIType): + + @property + def init_code(self): + return [f'MPI_Datatype {self.tmpname} = {ConvertFuncs.DATATYPE}({self.name});'] + + def type_text(self, count_type=None): + return self.mangle_name('MPI_Datatype') + + +@Type.add_type('OP', abi_type=['ompi']) +class TypeDatatype(Type): + + def type_text(self, count_type=None): + return 'MPI_Op' + + +@Type.add_type('OP', abi_type=['standard']) +class TypeDatatype(StandardABIType): + + @property + def init_code(self): + return [f'MPI_Op {self.tmpname} = {ConvertFuncs.OP}({self.name});'] + + def type_text(self, count_type=None): + return self.mangle_name('MPI_Op') + + +@Type.add_type('RANK') +class TypeRank(Type): + + def type_text(self, count_type=None): + return 'int' + + +@Type.add_type('TAG') +class TypeRank(Type): + + def type_text(self, count_type=None): + return 'int' + + +@Type.add_type('COMM', abi_type=['ompi']) +class TypeCommunicator(Type): + + def type_text(self, count_type=None): + return 'MPI_Comm' + + +@Type.add_type('COMM', abi_type=['standard']) +class TypeCommunicatorStandard(StandardABIType): + + @property + def init_code(self): + return [f'MPI_Comm {self.tmpname} = {ConvertFuncs.COMM}({self.name});'] + + def tmp_type_text(self, count_type=None): + return 'MPI_Comm' + + def return_code(self, name): + return [f'return {ConvertOMPIToStandard.COMM}({name});'] + + def type_text(self, count_type=None): + return self.mangle_name('MPI_Comm') + + +@Type.add_type('COMM_OUT', abi_type=['ompi']) +class TypeCommunicator(Type): + + def type_text(self, count_type=None): + return 'MPI_Comm *' + + +@Type.add_type('COMM_OUT', abi_type=['standard']) +class TypeCommunicator(Type): + + @property + def final_code(self): + return [f'*{self.name} = {ConvertOMPIToStandard.COMM}((MPI_Comm) *{self.name});'] + + def type_text(self, count_type=None): + type_name = self.mangle_name('MPI_Comm') + return f'{type_name} *' + + @property + def argument(self): + return f'(MPI_Comm *) {self.name}' + + +@Type.add_type('WIN', abi_type=['ompi']) +class TypeWindow(Type): + + def type_text(self, count_type=None): + return 'MPI_Win' + + +@Type.add_type('WIN', abi_type=['standard']) +class TypeWindowStandard(StandardABIType): + + @property + def init_code(self): + return [f'MPI_Win {self.tmpname} = {ConvertFuncs.WIN}({self.name});'] + + def type_text(self, count_type=None): + return self.mangle_name('MPI_Win') + + +@Type.add_type('REQUEST', abi_type=['ompi']) +class TypeRequest(Type): + + def type_text(self, count_type=None): + return 'MPI_Request' + + +@Type.add_type('REQUEST', abi_type=['standard']) +class TypeRequestStandard(Type): + + def type_text(self, count_type=None): + return self.mangle_name('MPI_Request') + + @property + def argument(self): + return f'(MPI_Request) {self.name}' + + +@Type.add_type('REQUEST_INOUT', abi_type=['ompi']) +class TypeRequestInOut(Type): + + def type_text(self, count_type=None): + return 'MPI_Request *' + + +@Type.add_type('REQUEST_INOUT', abi_type=['standard']) +class TypeRequestInOutStandard(Type): + + @property + def final_code(self): + if self.count_param is None: + return [f'{ConvertFuncs.REQUEST}({self.name});'] + else: + return [ + 'for (int i = 0; i < %s; ++i) {' % (self.count_param,), + f'{ConvertFuncs.REQUEST}(&{self.name}[i]);', + '}', + ] + + @property + def argument(self): + return f'(MPI_Request *) {self.name}' + + def type_text(self, count_type=None): + type_name = self.mangle_name('MPI_Request') + return f'{type_name} *' + + def parameter(self, count_type=None, **kwargs): + type_name = self.mangle_name('MPI_Request') + if self.count_param is None: + return f'{type_name} *{self.name}' + else: + return f'{type_name} {self.name}[]' + + +@Type.add_type('STATUS_OUT', abi_type=['ompi']) +class TypeStatusOut(Type): + + def type_text(self, count_type=None): + return 'MPI_Status *' + + def parameter(self, count_type=None, **kwargs): + if self.count_param is None: + return f'MPI_Status *{self.name}' + else: + return f'MPI_Status {self.name}[]' + + +@Type.add_type('STATUS_OUT', abi_type=['standard']) +class TypeStausOutStandard(StandardABIType): + + def if_should_set_status(self): + """Generate the condition to check if the status(es) should be set.""" + condition = ' && '.join(f'{self.mangle_name(const)} != {self.name}' + for const in IGNORED_STATUS_HANDLES) + return 'if (%s) {' % (condition,) + + @property + def status_argument(self): + return f'{self.name}_arg' + + @property + def init_code(self): + code = [f'MPI_Status *{self.status_argument} = NULL;'] + if self.count_param is None: + code.append(f'MPI_Status {self.tmpname};') + else: + code.append(f'MPI_Status *{self.tmpname} = NULL;') + code.append(self.if_should_set_status()) + if self.count_param is not None: + code.append(f'{self.tmpname} = malloc({self.count_param} * sizeof(MPI_Status));') + code.append(f'{self.status_argument} = {self.tmpname};') + else: + code.append(f'{self.status_argument} = &{self.tmpname};') + code.append('} else {') + if self.count_param is not None: + code.append(f'{self.status_argument} = MPI_STATUSES_IGNORE;') + else: + code.append(f'{self.status_argument} = MPI_STATUS_IGNORE;') + code.append('}') + return code + + @property + def final_code(self): + code = [self.if_should_set_status()] + if self.count_param is None: + code.append(f'{ConvertFuncs.STATUS}({self.name}, &{self.tmpname});') + else: + code.extend([ + 'for (int i = 0; i < %s; ++i) {' % (self.count_param,), + f'{ConvertFuncs.STATUS}(&{self.name}[i], &{self.tmpname}[i]);', + '}', + f'free({self.tmpname});', + ]) + code.append('}') + return code + + @property + def argument(self): + return self.status_argument + + def type_text(self, count_type=None): + type_name = self.mangle_name('MPI_Status') + return f'{type_name} *' + + def parameter(self, count_type=None, **kwargs): + type_name = self.mangle_name('MPI_Status') + if self.count_param is None: + return f'{type_name} *{self.name}' + else: + return f'{type_name} {self.name}[]' + + +# For now this just assumes that MPI_Fint doesn't need any conversions +@Type.add_type('FINT') +class TypeFint(Type): + + def type_text(self, count_type=None): + return 'MPI_Fint' + + +@Type.add_type('STRING') +class TypeString(Type): + + def type_text(self, count_type=None): + return 'const char *' + + +@Type.add_type('STRING_OUT') +class TypeStringOut(Type): + + def type_text(self, count_type=None): + return 'char *' + + +@Type.add_type('INFO', abi_type=['ompi']) +class TypeInfo(Type): + + def type_text(self, count_type=None): + return 'MPI_Info' + + +@Type.add_type('INFO', abi_type=['standard']) +class TypeInfoStandard(StandardABIType): + + @property + def init_code(self): + return [f'MPI_Info {self.tmpname} = {ConvertFuncs.INFO}({self.name});'] + + def type_text(self, count_type=None): + return self.mangle_name('MPI_Info') + + +@Type.add_type('FILE_OUT', abi_type=['ompi']) +class TypeFileOut(Type): + + def type_text(self, count_type=None): + return 'MPI_File *' + + +@Type.add_type('FILE_OUT', abi_type=['standard']) +class TypeFileOutStandard(Type): + + @property + def argument(self): + return f'(MPI_File *) {self.name}' + + @property + def final_code(self): + return [f'{ConvertFuncs.FILE}({self.name});'] + + def type_text(self, count_type=None): + type_name = self.mangle_name('MPI_File') + return f'{type_name} *' + + +class Prototype: + """MPI function prototype.""" + + def __init__(self, name, return_type, params): + self.name = name + self.return_type = return_type + self.params = params + + def signature(self, abi_type, fn_name, count_type=None, **kwargs): + """Build a signature with the given name and count_type.""" + params = ', '.join(param.construct(abi_type, **kwargs).parameter(count_type=count_type, **kwargs) + for param in self.params) + if not params: + params = 'void' + return_type_text = self.return_type.construct(abi_type, **kwargs).type_text(count_type=count_type) + return f'{return_type_text} {fn_name}({params})' + + @property + def need_bigcount(self): + """Check if a bigcount interface is required for a prototype.""" + return any('COUNT' in param.type_ for param in self.params) + + +class TemplateParseError(Exception): + """Error raised during parsing.""" + pass + + +def validate_body(body): + """Validate the body of a template.""" + # Just do a simple bracket balance test to determine the bounds of the + # function body. All lines after the function body should be blank. There + # are cases where this will break, such as if someone puts code all on one + # line. + bracket_balance = 0 + line_count = 0 + for line in body: + line = line.strip() + if bracket_balance == 0 and line_count > 0 and line: + raise TemplateParseError('Extra code found in template; only one function body is allowed') + + update = line.count('{') - line.count('}') + bracket_balance += update + if bracket_balance != 0: + line_count += 1 + + if bracket_balance != 0: + raise TemplateParseError('Mismatched brackets found in template') + + +class SourceTemplate: + """Source template for a single API function.""" + + def __init__(self, prototype, header, body): + self.prototype = prototype + self.header = header + self.body = body + + @staticmethod + def load(fname, prefix=None): + """Load a template file and return the SourceTemplate.""" + if prefix is not None: + fname = os.path.join(prefix, fname) + with open(fname) as fp: + header = [] + prototype = [] + body = [] + + for line in fp: + line = line.rstrip() + if prototype and line.startswith('PROTOTYPE'): + raise TemplateParseError('more than one prototype found in template file') + elif ((prototype and not any(')' in s for s in prototype)) + or line.startswith('PROTOTYPE')): + prototype.append(line) + elif prototype: + # Validate bracket balance + body.append(line) + else: + header.append(line) + + if not prototype: + raise RuntimeError('missing prototype') + # Parse the prototype + prototype = ''.join(prototype) + prototype = prototype[len('PROTOTYPE'):] + i = prototype.index('(') + j = prototype.index(')') + return_type, name = prototype[:i].split() + return_type = ReturnType(return_type) + params = [param.strip() for param in prototype[i + 1:j].split(',') if param.strip()] + params = [Parameter(param) for param in params] + prototype = Prototype(name, return_type, params) + # Ensure the body contains only one function + validate_body(body) + return SourceTemplate(prototype, header, body) + + def print_header(self, file=sys.stdout): + """Print the source header.""" + for line in self.header: + print(line, file=file) + + def print_body(self, func_name, file=sys.stdout): + """Print the body.""" + for line in self.body: + # FUNC_NAME is used for error messages + line = line.replace('FUNC_NAME', f'"{func_name}"') + print(line, file=file) + + +def print_profiling_header(fn_name, file=sys.stdout): + """Print the profiling header code.""" + print('#if OMPI_BUILD_MPI_PROFILING') + print('#if OPAL_HAVE_WEAK_SYMBOLS', file=file) + print(f'#pragma weak {fn_name} = P{fn_name}', file=file) + print('#endif', file=file) + print(f'#define {fn_name} P{fn_name}', file=file) + print('#endif') + + +def ompi_abi(base_name, template): + """Generate the OMPI ABI functions.""" + template.print_header() + print_profiling_header(base_name) + print(template.prototype.signature('ompi', base_name)) + template.print_body(func_name=base_name) + # Check if we need to generate the bigcount interface + if template.prototype.need_bigcount: + base_name_c = f'{base_name}_c' + print_profiling_header(base_name_c) + print(template.prototype.signature('ompi', base_name_c, count_type='MPI_Count')) + template.print_body(func_name=base_name_c) + + +ABI_INTERNAL_HEADER = 'ompi/mpi/c/abi.h' + + +def indent_lines(lines, tab, start=0): + """Crude pretty-printing function.""" + new_lines = [] + indent_count = start + for line in lines: + # Closing bracket + if '}' in line: + indent_count -= 1 + + prefix = indent_count * tab + new_lines.append(f'{prefix}{line}') + + # Opening bracket + if '{' in line: + indent_count += 1 + return new_lines + + +def standard_abi(base_name, template): + """Generate the standard ABI functions.""" + template.print_header() + print(f'#include "{ABI_INTERNAL_HEADER}"') + + # Static internal function (add a random component to avoid conflicts) + internal_name = f'ompi_abi_{template.prototype.name}' + internal_sig = template.prototype.signature('ompi', internal_name, + count_type='MPI_Count') + print(INLINE_ATTRS, internal_sig) + template.print_body(func_name=base_name) + + def generate_function(prototype, fn_name, internal_fn, count_type='int'): + """Generate a function for the standard ABI.""" + print_profiling_header(fn_name) + + # Handle type conversions and arguments + params = [param.construct('standard') for param in prototype.params] + print(prototype.signature('standard', fn_name, count_type=count_type)) + print('{') + lines = [] + return_type = prototype.return_type.construct('standard') + lines.append(f'{return_type.tmp_type_text()} ret_value;') + for param in params: + if param.init_code: + lines.extend(param.init_code) + pass_args = ', '.join(param.argument for param in params) + lines.append(f'ret_value = {internal_fn}({pass_args});') + for param in params: + if param.final_code: + lines.extend(param.final_code) + lines.extend(return_type.return_code('ret_value')) + + # Indent the lines + lines = indent_lines(lines, 4 * ' ', start=1) + for line in lines: + print(line) + print('}') + + generate_function(template.prototype, base_name, internal_name) + if template.prototype.need_bigcount: + base_name_c = f'{base_name}_c' + generate_function(template.prototype, base_name_c, internal_name, + count_type='MPI_Count') + + +def gen_header(args): + """Generate an ABI header and conversion code.""" + prototypes = [SourceTemplate.load(file_, args.srcdir).prototype for file_ in args.file] + + builder = ABIHeaderBuilder(prototypes, external=args.external) + builder.dump_header() + + +def gen_source(args): + """Generate source file.""" + template = SourceTemplate.load(args.source_file) + + base_name = mpi_fn_name_from_base_fn_name(template.prototype.name) + if args.type == 'ompi': + ompi_abi(base_name, template) + else: + standard_abi(base_name, template) + + +def main(): + if len(sys.argv) < 2: + # Fix required for Python 3.6 + print('ERROR: missing subparser argument (see --help)') + sys.exit(1) + + parser = argparse.ArgumentParser(description='generate ABI header file and conversion code') + subparsers = parser.add_subparsers() + + parser_header = subparsers.add_parser('header') + parser_header.add_argument('file', nargs='+', help='list of template source files') + parser_header.add_argument('--external', action='store_true', help='generate external mpi.h header file') + parser_header.add_argument('--srcdir', help='source directory') + parser_header.set_defaults(func=gen_header) + + parser_gen = subparsers.add_parser('source') + # parser = argparse.ArgumentParser(description='C ABI binding generation code') + parser_gen.add_argument('type', choices=('ompi', 'standard'), + help='generate the OMPI ABI functions or the standard ABI functions') + parser_gen.add_argument('source_file', help='source template file') + parser_gen.set_defaults(func=gen_source) + + args = parser.parse_args() + + # Always add the header + print('/* THIS FILE WAS AUTOGENERATED BY ompi/mpi/c/abi.py. DO NOT EDIT BY HAND. */') + args.func(args) + + +if __name__ == '__main__': + main() diff --git a/ompi/mpi/c/abi_details.c b/ompi/mpi/c/abi_details.c new file mode 100644 index 00000000000..8dfc7b6e629 --- /dev/null +++ b/ompi/mpi/c/abi_details.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Triad National Security, LLC. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include + +#include "opal/util/show_help.h" +#include "ompi/runtime/ompi_spc.h" +#include "ompi/mpi/c/bindings.h" +#include "ompi/communicator/communicator.h" +#include "ompi/errhandler/errhandler.h" +#include "ompi/constants.h" +#ifdef OMPI_NO_MPI_PROTOTYPES +#include "ompi/mpi/c/abi.h" +#endif + +static const char ABI_DETAILS[] = "Open MPI Standard ABI 0.1"; + +int MPI_Abi_details(int *buflen, char *details, MPI_Info *info) +{ + if (*buflen >= (int) sizeof(ABI_DETAILS)) { + strcpy(details, ABI_DETAILS); + *buflen = sizeof(ABI_DETAILS); + return MPI_SUCCESS; + } else { + *buflen = 0; + return MPI_ERR_BUFFER; + } +} diff --git a/ompi/mpi/c/abi_supported.c b/ompi/mpi/c/abi_supported.c new file mode 100644 index 00000000000..b8b977962ba --- /dev/null +++ b/ompi/mpi/c/abi_supported.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Triad National Security, LLC. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include + +#include "opal/util/show_help.h" +#include "ompi/runtime/ompi_spc.h" +#include "ompi/mpi/c/bindings.h" +#include "ompi/communicator/communicator.h" +#include "ompi/errhandler/errhandler.h" +#include "ompi/constants.h" +#ifdef OMPI_NO_MPI_PROTOTYPES +#include "ompi/mpi/c/abi.h" +#endif + +int MPI_Abi_supported(int *flag) +{ + *flag = 1; + return MPI_SUCCESS; +} diff --git a/ompi/mpi/c/abi_version.c b/ompi/mpi/c/abi_version.c new file mode 100644 index 00000000000..33d32854893 --- /dev/null +++ b/ompi/mpi/c/abi_version.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Triad National Security, LLC. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include + +#include "opal/util/show_help.h" +#include "ompi/runtime/ompi_spc.h" +#include "ompi/mpi/c/bindings.h" +#include "ompi/communicator/communicator.h" +#include "ompi/errhandler/errhandler.h" +#include "ompi/constants.h" +#ifdef OMPI_NO_MPI_PROTOTYPES +#include "ompi/mpi/c/abi.h" +#endif + +int MPI_Abi_version(int *abi_major, int *abi_minor) +{ + /* 0.1 */ + *abi_major = 0; + *abi_minor = 1; + return MPI_SUCCESS; +} diff --git a/ompi/mpi/c/status_c2f.c.in b/ompi/mpi/c/status_c2f.c.in index d430bc7964f..9d4774a7cf7 100644 --- a/ompi/mpi/c/status_c2f.c.in +++ b/ompi/mpi/c/status_c2f.c.in @@ -33,11 +33,10 @@ #include "ompi/mpi/fortran/base/fint_2_int.h" #include "ompi/mpi/fortran/base/constants.h" #include "ompi/memchecker.h" +#include "ompi/util/status.h" PROTOTYPE ERROR_CLASS status_c2f(STATUS c_status, FINT_OUT f_status) { - const int *c_ints; - int i; MEMCHECKER( if(c_status != MPI_STATUSES_IGNORE) { /* @@ -61,33 +60,5 @@ PROTOTYPE ERROR_CLASS status_c2f(STATUS c_status, FINT_OUT f_status) MPI_ERR_IN_STATUS, FUNC_NAME); } } - - /* Note that MPI-2.2 16.3.5 states that even the hidden data in a - status must be converted (!). This is somewhat problematic - because the Fortran data is all INTEGERS while the C MPI_Status - contains a size_t. That being said, note 2 things: - - 1. The _ucount and _canceled members are never accessed from - Fortran. - 2. configure calculated a value of MPI_STATUS_SIZE to ensure - that the Fortran status is the Right size to hold the C - MPI_Status (including the size_t member). - - So for the purposes of this function, just copy over all the - data as if they were int's. This works because all OMPI - Fortran MPI API functions that take a status as an IN argument - first call MPI_Status_f2c on it before using it (in which case - we'll do the exact opposite copy, thereby rebuilding the size_t - value properly before it is accessed in C). - - Note that if sizeof(int) > sizeof(INTEGER), we're potentially - hosed anyway (i.e., even the public values in the status could - get truncated). But if sizeof(int) == sizeof(INTEGER) or - sizeof(int) < sizeof(INTEGER), everything should be kosher. */ - c_ints = (const int*)c_status; - for( i = 0; i < (int)(sizeof(MPI_Status) / sizeof(int)); i++ ) { - f_status[i] = OMPI_INT_2_FINT(c_ints[i]); - } - - return MPI_SUCCESS; + return ompi_status_c2f(c_status, f_status); } diff --git a/ompi/mpi/c/status_f2c.c.in b/ompi/mpi/c/status_f2c.c.in index 3216193e3e9..c7e6f7ac700 100644 --- a/ompi/mpi/c/status_f2c.c.in +++ b/ompi/mpi/c/status_f2c.c.in @@ -31,11 +31,10 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/mpi/fortran/base/fint_2_int.h" #include "ompi/mpi/fortran/base/constants.h" +#include "ompi/util/status.h" PROTOTYPE ERROR_CLASS status_f2c(FINT_CONST f_status, STATUS_OUT c_status) { - int i, *c_ints; - if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); @@ -57,17 +56,5 @@ PROTOTYPE ERROR_CLASS status_f2c(FINT_CONST f_status, STATUS_OUT c_status) } } - /* ***NOTE*** See huge comment in status_c2f.c (yes, I know - there's a size_t member in the C MPI_Status -- go - read that comment for an explanation why copying - everything as a bunch of int's is ok). - - We can't use OMPI_FINT_2_INT here because of some complications - with include files. :-( So just do the casting manually. */ - c_ints = (int*)c_status; - for( i = 0; i < (int)(sizeof(MPI_Status) / sizeof(int)); i++ ) { - c_ints[i] = (int)f_status[i]; - } - - return MPI_SUCCESS; + return ompi_status_f2c(f_status, c_status); } diff --git a/ompi/mpi/c/wtime.c.in b/ompi/mpi/c/wtime.c.in index e31db4d630e..cc22d427142 100644 --- a/ompi/mpi/c/wtime.c.in +++ b/ompi/mpi/c/wtime.c.in @@ -45,7 +45,7 @@ * and accuracy of the user visible timer. * More info: https://github.com/mpi-forum/mpi-issues/issues/77#issuecomment-369663119 */ -extern struct timespec ompi_wtime_time_origin; +extern struct timespec ompi_wtime_time_origin = {.tv_sec = 0}; PROTOTYPE DOUBLE wtime() { diff --git a/ompi/mpiext/Makefile.am b/ompi/mpiext/Makefile.am index bbbdec3531c..e23729b2e91 100644 --- a/ompi/mpiext/Makefile.am +++ b/ompi/mpiext/Makefile.am @@ -16,5 +16,5 @@ headers += \ mpiext/mpiext.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ mpiext/mpiext.c diff --git a/ompi/op/Makefile.am b/ompi/op/Makefile.am index 5599c31311b..db4e92736a2 100644 --- a/ompi/op/Makefile.am +++ b/ompi/op/Makefile.am @@ -24,4 +24,4 @@ headers += op/op.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += op/op.c +libopen_mpi_la_SOURCES += op/op.c diff --git a/ompi/peruse/Makefile.am b/ompi/peruse/Makefile.am index 9b2d043ce43..aee74cc436c 100644 --- a/ompi/peruse/Makefile.am +++ b/ompi/peruse/Makefile.am @@ -21,7 +21,7 @@ if WANT_PERUSE # do NOT want this nobase - we want the peruse stripped off... include_HEADERS += peruse/peruse.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ peruse/peruse.c \ peruse/peruse_module.c endif diff --git a/ompi/proc/Makefile.am b/ompi/proc/Makefile.am index e9ad85d6f73..b10d46e37cf 100644 --- a/ompi/proc/Makefile.am +++ b/ompi/proc/Makefile.am @@ -23,5 +23,5 @@ headers += \ proc/proc.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ proc/proc.c diff --git a/ompi/request/Makefile.am b/ompi/request/Makefile.am index ab7bf73fe80..c30da608d08 100644 --- a/ompi/request/Makefile.am +++ b/ompi/request/Makefile.am @@ -34,18 +34,18 @@ headers += \ request/grequestx.h endif -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ request/grequest.c \ request/request.c \ request/req_test.c \ request/req_wait.c if WANT_FT_MPI -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ request/req_ft.c endif # WANT_FT_MPI if OMPI_ENABLE_GREQUEST_EXTENSIONS -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ request/grequestx.c endif diff --git a/ompi/request/grequest.c b/ompi/request/grequest.c index 6125d134a9c..2338f8e0e71 100644 --- a/ompi/request/grequest.c +++ b/ompi/request/grequest.c @@ -23,6 +23,7 @@ #include "ompi/communicator/communicator.h" #include "ompi/request/grequest.h" #include "ompi/mpi/fortran/base/fint_2_int.h" +#include "ompi/util/status.h" /** * Internal function to specialize the call to the user provided free_fn @@ -262,9 +263,9 @@ int ompi_grequest_invoke_query(ompi_request_t *request, */ MPI_Fint ierr; MPI_Fint fstatus[sizeof(MPI_Status) / sizeof(int)]; - MPI_Status_c2f(status, fstatus); + ompi_status_c2f(status, fstatus); g->greq_query.f_query((MPI_Aint*)g->greq_state, fstatus, &ierr); - MPI_Status_f2c(fstatus, status); + ompi_status_f2c(fstatus, status); rc = OMPI_FINT_2_INT(ierr); } } diff --git a/ompi/runtime/Makefile.am b/ompi/runtime/Makefile.am index 957045ed116..225284b6066 100644 --- a/ompi/runtime/Makefile.am +++ b/ompi/runtime/Makefile.am @@ -31,7 +31,7 @@ headers += \ runtime/ompi_spc.h \ runtime/ompi_rte.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ runtime/ompi_mpi_init.c \ runtime/ompi_mpi_abort.c \ runtime/ompi_mpi_dynamics.c \ diff --git a/ompi/tools/wrappers/Makefile.am b/ompi/tools/wrappers/Makefile.am index 1d5b24a9372..f1482ff4164 100644 --- a/ompi/tools/wrappers/Makefile.am +++ b/ompi/tools/wrappers/Makefile.am @@ -89,7 +89,7 @@ if OMPI_WANT_JAVA_BINDINGS bin_SCRIPTS = mpijavac.pl endif -nodist_ompidata_DATA = mpicc-wrapper-data.txt +nodist_ompidata_DATA = mpicc-wrapper-data.txt mpicc_abi-wrapper-data.txt if OMPI_HAVE_CXX_COMPILER nodist_ompidata_DATA += mpic++-wrapper-data.txt @@ -102,6 +102,7 @@ endif install-exec-hook-always: test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" (cd $(DESTDIR)$(bindir); rm -f mpicc$(EXEEXT); $(LN_S) opal_wrapper$(EXEEXT) mpicc$(EXEEXT)) + (cd $(DESTDIR)$(bindir); rm -f mpicc_abi$(EXEEXT); $(LN_S) opal_wrapper$(EXEEXT) mpicc_abi$(EXEEXT)) if OMPI_HAVE_CXX_COMPILER (cd $(DESTDIR)$(bindir); rm -f mpic++$(EXEEXT); $(LN_S) opal_wrapper$(EXEEXT) mpic++$(EXEEXT)) (cd $(DESTDIR)$(bindir); rm -f mpicxx$(EXEEXT); $(LN_S) opal_wrapper$(EXEEXT) mpicxx$(EXEEXT)) diff --git a/ompi/tools/wrappers/mpicc_abi-wrapper-data.txt.in b/ompi/tools/wrappers/mpicc_abi-wrapper-data.txt.in new file mode 100644 index 00000000000..916036f931e --- /dev/null +++ b/ompi/tools/wrappers/mpicc_abi-wrapper-data.txt.in @@ -0,0 +1,26 @@ +# There can be multiple blocks of configuration data, chosen by +# compiler flags (using the compiler_args key to chose which block +# should be activated. This can be useful for multilib builds. See the +# multilib page at: +# https://github.com/open-mpi/ompi/wiki/compilerwrapper3264 +# for more information. + +project=Open MPI +project_short=OMPI +version=@OMPI_VERSION@ +language=C +compiler_env=CC +compiler_flags_env=CFLAGS +compiler=@WRAPPER_CC@ +preprocessor_flags=-I${includedir}/standard_abi +compiler_flags_prefix=@OMPI_WRAPPER_CFLAGS_PREFIX@ +compiler_flags=@OMPI_WRAPPER_CFLAGS@ +linker_flags=@OMPI_WRAPPER_LDFLAGS@ +linker_flags_static=@OMPI_WRAPPER_LDFLAGS_STATIC@ +libs=-lmpi_abi +libs_static= +dyn_lib_file=libmpi_abi.@OPAL_DYN_LIB_SUFFIX@ +static_lib_file=libmpi_abi.a +required_file= +includedir=${includedir} +libdir=${libdir} diff --git a/ompi/util/Makefile.am b/ompi/util/Makefile.am index 53a89a074eb..70df3bed6a3 100644 --- a/ompi/util/Makefile.am +++ b/ompi/util/Makefile.am @@ -11,4 +11,5 @@ # Source code files headers += \ util/timings.h \ - util/count_disp_array.h + util/count_disp_array.h \ + util/status.h diff --git a/ompi/util/status.h b/ompi/util/status.h new file mode 100644 index 00000000000..c1089df5f5c --- /dev/null +++ b/ompi/util/status.h @@ -0,0 +1,56 @@ +#include "ompi/mpi/fortran/base/fint_2_int.h" +#include "ompi/mpi/fortran/base/constants.h" + +static inline int ompi_status_c2f(const MPI_Status *c_status, MPI_Fint *f_status) +{ + const int *c_ints; + int i; + + /* Note that MPI-2.2 16.3.5 states that even the hidden data in a + status must be converted (!). This is somewhat problematic + because the Fortran data is all INTEGERS while the C MPI_Status + contains a size_t. That being said, note 2 things: + + 1. The _ucount and _canceled members are never accessed from + Fortran. + 2. configure calculated a value of MPI_STATUS_SIZE to ensure + that the Fortran status is the Right size to hold the C + MPI_Status (including the size_t member). + + So for the purposes of this function, just copy over all the + data as if they were int's. This works because all OMPI + Fortran MPI API functions that take a status as an IN argument + first call MPI_Status_f2c on it before using it (in which case + we'll do the exact opposite copy, thereby rebuilding the size_t + value properly before it is accessed in C). + + Note that if sizeof(int) > sizeof(INTEGER), we're potentially + hosed anyway (i.e., even the public values in the status could + get truncated). But if sizeof(int) == sizeof(INTEGER) or + sizeof(int) < sizeof(INTEGER), everything should be kosher. */ + c_ints = (const int*)c_status; + for( i = 0; i < (int)(sizeof(MPI_Status) / sizeof(int)); i++ ) { + f_status[i] = OMPI_INT_2_FINT(c_ints[i]); + } + + return MPI_SUCCESS; +} + +static inline int ompi_status_f2c(const MPI_Fint *f_status, MPI_Status *c_status) +{ + int i, *c_ints; + + /* ***NOTE*** See huge comment in status_c2f.c (yes, I know + there's a size_t member in the C MPI_Status -- go + read that comment for an explanation why copying + everything as a bunch of int's is ok). + + We can't use OMPI_FINT_2_INT here because of some complications + with include files. :-( So just do the casting manually. */ + c_ints = (int*)c_status; + for( i = 0; i < (int)(sizeof(MPI_Status) / sizeof(int)); i++ ) { + c_ints[i] = (int)f_status[i]; + } + + return MPI_SUCCESS; +} diff --git a/ompi/win/Makefile.am b/ompi/win/Makefile.am index 67126c71ec0..8675e77b63e 100644 --- a/ompi/win/Makefile.am +++ b/ompi/win/Makefile.am @@ -23,5 +23,5 @@ headers += \ win/win.h -lib@OMPI_LIBMPI_NAME@_la_SOURCES += \ +libopen_mpi_la_SOURCES += \ win/win.c From 991457e741a915fa822432813af513546db30502 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Sat, 10 May 2025 16:06:15 -0600 Subject: [PATCH 2/6] Move ABI support into big count binding code Implement lots of missing functionality in the original api.py script. The functionality is now part of the bindings generation framework used for Big Count. Number of todos still to do, in particular provide support for wrapping user supplied callback functions. Also, the sendrecv_replace, etc. code needs to be refactored to work with the bindings framework. Signed-off-by: Howard Pritchard --- config/ompi_configure_options.m4 | 6 + ompi/Makefile.am | 14 +- ompi/include/mpi.h.in | 2 + ompi/mpi/bindings/ompi_bindings/c.py | 118 +++++++- ompi/mpi/bindings/ompi_bindings/c_type.py | 346 ++++++++++++++++++---- ompi/mpi/bindings/ompi_bindings/consts.py | 41 ++- ompi/mpi/bindings/ompi_bindings/parser.py | 3 + ompi/mpi/c/Makefile.am | 76 +++-- ompi/mpi/c/comm_spawn_multiple.c.in | 2 +- ompi/mpi/c/file_close.c.in | 2 +- ompi/mpi/c/isendrecv_replace.c.in | 10 +- ompi/mpi/c/session_finalize.c.in | 2 +- ompi/mpi/c/type_create_struct.c.in | 2 +- ompi/mpi/c/win_create_errhandler.c.in | 2 +- ompi/mpi/c/{win_f2c.c => win_f2c.c.in} | 11 +- ompi/mpi/c/wtime.c.in | 2 +- 16 files changed, 503 insertions(+), 136 deletions(-) rename ompi/mpi/c/{win_f2c.c => win_f2c.c.in} (88%) diff --git a/config/ompi_configure_options.m4 b/config/ompi_configure_options.m4 index 83606e2c555..72a84353394 100644 --- a/config/ompi_configure_options.m4 +++ b/config/ompi_configure_options.m4 @@ -256,6 +256,12 @@ AM_CONDITIONAL(OMPI_OMPIO_SUPPORT, test "$ompi_want_ompio" = "1") AC_ARG_ENABLE([deprecate-mpif-h], [AS_HELP_STRING([--enable-deprecate-mpif-h], [Mark the mpif.h bindings as deprecated (default: enabled)])]) +# If the binding source files don't exist, then we need Python to generate them +AM_PATH_PYTHON([3.6],,[:]) +binding_file="${srcdir}/ompi/mpi/c/ompi_send_generated.c" +AS_IF([! test -e "$binding_file" && test "$PYTHON" = ":"], + [AC_MSG_ERROR([Open MPI requires Python >=3.6 for generating the bindings. Aborting])]) +AM_CONDITIONAL(OMPI_GENERATE_BINDINGS,[test "$PYTHON" != ":"]) AC_MSG_CHECKING([if want to enable standard ABI library]) AC_ARG_ENABLE([standard-abi], diff --git a/ompi/Makefile.am b/ompi/Makefile.am index a839ab1bff4..14857566c9b 100644 --- a/ompi/Makefile.am +++ b/ompi/Makefile.am @@ -126,7 +126,7 @@ DIST_SUBDIRS = \ $(MCA_ompi_FRAMEWORKS_SUBDIRS) \ $(MCA_ompi_FRAMEWORK_COMPONENT_ALL_SUBDIRS) -noinst_LTLIBRARIES = libopen-mpi.la +noinst_LTLIBRARIES = libopen_mpi.la lib_LTLIBRARIES = lib@OMPI_LIBMPI_NAME@.la if OMPI_STANDARD_ABI lib_LTLIBRARIES += libmpi_abi.la @@ -142,14 +142,14 @@ endif # +----------------------+----------------------+ # | libmpi_abi.la | libmpi.la | # +----------------------+----------------------+ -# | libopen-mpi.la | +# | libopen_mpi.la | # +----------------------+----------------------+ # -# This includes a new library, libopen-mpi.la, that links in all backend code +# This includes a new library, libopen_mpi.la, that links in all backend code # built in this directory or SUBDIRs of this directory. Previously everything # was just linked directly into libmpi.la (lib@OMPI_LIBMPI_NAME@.la). # -# libmpi_abi.la and libmpi.la both now link in libopen-mpi.la, the only +# libmpi_abi.la and libmpi.la both now link in libopen_mpi.la, the only # difference between them being that one includes the standard ABI functions # and the other the ompi-specific versions of those. # @@ -167,7 +167,7 @@ libopen_mpi_la_DEPENDENCIES = $(libopen_mpi_la_LIBADD) # Build the main MPI library lib@OMPI_LIBMPI_NAME@_la_SOURCES = lib@OMPI_LIBMPI_NAME@_la_LIBADD = \ - libopen-mpi.la \ + libopen_mpi.la \ mpi/c/libmpi_c.la \ mpi/tool/libmpi_mpit.la \ $(c_mpi_lib) \ @@ -182,16 +182,16 @@ lib@OMPI_LIBMPI_NAME@_la_LDFLAGS = \ # The MPI Standard ABI library libmpi_abi_la_SOURCES = libmpi_abi_la_LIBADD = \ - libopen-mpi.la \ + libopen_mpi.la \ mpi/c/libmpi_c_abi.la # included subdirectory Makefile.am's and appended-to variables headers = -noinst_LTLIBRARIES = include_HEADERS = EXTRA_DIST = lib@OMPI_LIBMPI_NAME@_la_SOURCES += $(headers) dist_ompidata_DATA = +libopen_mpi_la_SOURCES += $(headers) # Conditionally install the header files diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index dcf20db7262..f9ded080d7c 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -1433,6 +1433,7 @@ OMPI_DECLSPEC extern struct ompi_predefined_datatype_t ompi_mpi_ub; /* * MPI API */ +#ifndef OMPI_NO_MPI_PROTOTYPES OMPI_DECLSPEC int MPI_Abi_supported(int *flag); OMPI_DECLSPEC int MPI_Abi_version(int *abi_major, int *abi_minor); OMPI_DECLSPEC int MPI_Abi_details(int *buflen, char *details, MPI_Info *info); @@ -4093,6 +4094,7 @@ OMPI_DECLSPEC int PMPI_Type_ub(MPI_Datatype mtype, MPI_Aint *ub) #endif /* OMPI_NO_MPI_PROTOTYPES */ + #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/ompi/mpi/bindings/ompi_bindings/c.py b/ompi/mpi/bindings/ompi_bindings/c.py index 362f481d11b..bc515fd21b5 100644 --- a/ompi/mpi/bindings/ompi_bindings/c.py +++ b/ompi/mpi/bindings/ompi_bindings/c.py @@ -137,18 +137,57 @@ def generate_comm_convert_fn_intern_to_abi(self): def generate_info_convert_fn(self): self.generic_convert(ConvertFuncs.INFO, 'info', 'MPI_Info', consts.RESERVED_INFOS) + def generate_info_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.INFO, 'info', 'MPI_Info', consts.RESERVED_INFOS) + + def generate_file_convert_fn(self): + self.generic_convert(ConvertFuncs.FILE, 'file', 'MPI_File', consts.RESERVED_FILES) + def generate_file_convert_fn_intern_to_abi(self): - self.generic_convert_reverse(ConvertFuncs.FILE, 'file', 'MPI_File', consts.RESERVED_FILES) + self.generic_convert_reverse(ConvertOMPIToStandard.FILE, 'file', 'MPI_File', consts.RESERVED_FILES) def generate_datatype_convert_fn(self): self.generic_convert(ConvertFuncs.DATATYPE, 'datatype', 'MPI_Datatype', consts.PREDEFINED_DATATYPES) + def generate_datatype_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.DATATYPE, 'datatype', 'MPI_Datatype', consts.PREDEFINED_DATATYPES) + + def generate_errhandler_convert_fn(self): + self.generic_convert(ConvertFuncs.ERRHANDLER, 'errorhandler', 'MPI_Errhandler', consts.RESERVED_ERRHANDLERS) + + def generate_errhandler_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.ERRHANDLER, 'errorhandler', 'MPI_Errhandler', consts.RESERVED_ERRHANDLERS) + + def generate_group_convert_fn(self): + self.generic_convert(ConvertFuncs.GROUP, 'group', 'MPI_Group', consts.RESERVED_GROUPS) + + def generate_group_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.GROUP, 'group', 'MPI_Group', consts.RESERVED_GROUPS) + + def generate_message_convert_fn(self): + self.generic_convert(ConvertFuncs.MESSAGE, 'message', 'MPI_Message', consts.RESERVED_MESSAGES) + + def generate_message_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.MESSAGE, 'message', 'MPI_Message', consts.RESERVED_MESSAGES) + def generate_op_convert_fn(self): self.generic_convert(ConvertFuncs.OP, 'op', 'MPI_Op', consts.COLLECTIVE_OPERATIONS) + def generate_op_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.OP, 'op', 'MPI_Op', consts.RESERVED_OPS) + + def generate_session_convert_fn(self): + self.generic_convert(ConvertFuncs.SESSION, 'session', 'MPI_Session', consts.RESERVED_SESSIONS) + + def generate_session_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.SESSION, 'session', 'MPI_Session', consts.RESERVED_SESSIONS) + def generate_win_convert_fn(self): self.generic_convert(ConvertFuncs.WIN, 'win', 'MPI_Win', consts.RESERVED_WINDOWS) + def generate_win_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.WIN, 'win', 'MPI_Win', consts.RESERVED_WINDOWS) + def generate_pointer_convert_fn(self, type_, fn_name, constants): abi_type = self.mangle_name(type_) self.dump(f'{consts.INLINE_ATTRS} void {fn_name}({abi_type} *ptr)') @@ -168,13 +207,16 @@ def generate_pointer_convert_fn(self, type_, fn_name, constants): def generate_request_convert_fn(self): self.generate_pointer_convert_fn('MPI_Request', ConvertFuncs.REQUEST, consts.RESERVED_REQUESTS) - def generate_file_convert_fn(self): - self.generate_pointer_convert_fn('MPI_File', ConvertFuncs.FILE, consts.RESERVED_FILES) + def generate_request_convert_fn_intern_to_abi(self): + self.generic_convert_reverse(ConvertOMPIToStandard.REQUEST, 'request', 'MPI_Request', consts.RESERVED_REQUESTS) + +# def generate_file_convert_fn(self): +# self.generate_pointer_convert_fn('MPI_File', ConvertFuncs.FILE, consts.RESERVED_FILES) def generate_status_convert_fn(self): type_ = 'MPI_Status' abi_type = self.mangle_name(type_) - self.dump(f'{consts.INLINE_ATTRS} void {ConvertFuncs.STATUS}({abi_type} *out, {type_} *inp)') + self.dump(f'{consts.INLINE_ATTRS} void {ConvertFuncs.STATUS}({type_} *out, {abi_type} *inp)') self.dump('{') self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;') self.dump(' out->MPI_TAG = inp->MPI_TAG;') @@ -182,6 +224,17 @@ def generate_status_convert_fn(self): # Ignoring the private fields for now self.dump('}') + def generate_status_convert_fn_intern_to_abi(self): + type_ = 'MPI_Status' + abi_type = self.mangle_name(type_) + self.dump(f'{consts.INLINE_ATTRS} void {ConvertOMPIToStandard.STATUS}({abi_type} *out, {type_} *inp)') + self.dump('{') + self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;') + self.dump(' out->MPI_TAG = inp->MPI_TAG;') +# self.dump(f' out->MPI_ERROR = {ConvertOMPIToStandard.ERROR_CLASS}(inp->MPI_ERROR);') + # Ignoring the private fields for now + self.dump('}') + def define(self, type_, name, value): self.dump(f'#define {name} OMPI_CAST_CONSTANT({type_}, {value})') @@ -217,12 +270,17 @@ def dump_header(self): self.dump() self.define_all('MPI_Datatype', consts.PREDEFINED_DATATYPES) - self.define_all('MPI_Op', COLLECTIVE_OPERATIONS) + self.define_all('MPI_Op', consts.COLLECTIVE_OPERATIONS) + self.define_all('MPI_Op', consts.RESERVED_OPS) self.define_all('MPI_Comm', consts.RESERVED_COMMUNICATORS) + self.define_all('MPI_Errhandler', consts.RESERVED_ERRHANDLERS) + self.define_all('MPI_Group', consts.RESERVED_GROUPS) self.define_all('MPI_Request', consts.RESERVED_REQUESTS) + self.define_all('MPI_Session', consts.RESERVED_SESSIONS) self.define_all('MPI_Win', consts.RESERVED_WINDOWS) self.define_all('MPI_Info', consts.RESERVED_INFOS) self.define_all('MPI_File', consts.RESERVED_FILES) + self.define_all('MPI_Message', consts.RESERVED_MESSAGES) for name, value in consts.VARIOUS_CONSTANTS.items(): self.dump(f'#define {self.mangle_name(name)} {value}') @@ -255,9 +313,13 @@ def dump_header(self): };""") self.dump(f'typedef struct MPI_Status_ABI {self.mangle_name("MPI_Status")};') self.dump() + # user functions + self.dump('typedef int (MPI_Copy_function)(MPI_Comm_ABI_INTERNAL, int, void *, void *, void *, int *);') + self.dump('typedef int (MPI_Delete_function)(MPI_Comm_ABI_INTERNAL, int, void *, void *);') # Function signatures for sig in self.signatures: self.dump(f'{sig};') +# print("Working on signature " + str(sig)) self.dump('int MPI_Abi_details(int *buflen, char *details, MPI_Info *info);') self.dump('int MPI_Abi_supported(int *flag);') self.dump('int MPI_Abi_version(int *abi_major, int *abi_minor);') @@ -267,12 +329,27 @@ def dump_header(self): self.generate_comm_convert_fn() self.generate_comm_convert_fn_intern_to_abi() self.generate_info_convert_fn() + self.generate_info_convert_fn_intern_to_abi() self.generate_file_convert_fn() + self.generate_file_convert_fn_intern_to_abi() + self.generate_group_convert_fn() + self.generate_group_convert_fn_intern_to_abi() self.generate_datatype_convert_fn() + self.generate_datatype_convert_fn_intern_to_abi() + self.generate_errhandler_convert_fn() + self.generate_errhandler_convert_fn_intern_to_abi() + self.generate_message_convert_fn() + self.generate_message_convert_fn_intern_to_abi() self.generate_op_convert_fn() + self.generate_op_convert_fn_intern_to_abi() + self.generate_session_convert_fn() + self.generate_session_convert_fn_intern_to_abi() self.generate_win_convert_fn() + self.generate_win_convert_fn_intern_to_abi() self.generate_request_convert_fn() + self.generate_request_convert_fn_intern_to_abi() self.generate_status_convert_fn() + self.generate_status_convert_fn_intern_to_abi() self.dump(""" #if defined(c_plusplus) || defined(__cplusplus) @@ -292,7 +369,7 @@ def print_profiling_header(fn_name, out): out.dump('#endif') -def print_cdefs_for_bigcount(fn_name, out, enable_count=False): +def print_cdefs_for_bigcount(out, enable_count=False): if enable_count: out.dump('#undef OMPI_BIGCOUNT_SRC') out.dump('#define OMPI_BIGCOUNT_SRC 1') @@ -304,14 +381,14 @@ def ompi_abi(base_name, template, out): """Generate the OMPI ABI functions.""" template.print_header(out) print_profiling_header(base_name, out) - print_cdefs_for_bigcount(base_name, out) + print_cdefs_for_bigcount(out) out.dump(template.prototype.signature(base_name, abi_type='ompi')) template.print_body(func_name=base_name, out=out) # Check if we need to generate the bigcount interface if util.prototype_has_bigcount(template.prototype): base_name_c = f'{base_name}_c' print_profiling_header(base_name_c, out) - print_cdefs_for_bigcount(base_name_c, out, enable_count=True) + print_cdefs_for_bigcount(out, enable_count=True) out.dump(template.prototype.signature(base_name_c, abi_type='ompi', enable_count=True)) template.print_body(func_name=base_name_c, out=out) @@ -326,15 +403,23 @@ def standard_abi(base_name, template, out): # Static internal function (add a random component to avoid conflicts) internal_name = f'ompi_abi_{template.prototype.name}' + print_cdefs_for_bigcount(out) internal_sig = template.prototype.signature(internal_name, abi_type='ompi', - enable_count=True) + enable_count=False) out.dump(consts.INLINE_ATTRS, internal_sig) template.print_body(func_name=base_name, out=out) - - def generate_function(prototype, fn_name, internal_fn, enable_count=False): + if util.prototype_has_bigcount(template.prototype): + internal_name = f'ompi_abi_{template.prototype.name}_c' + print_cdefs_for_bigcount(out, enable_count=True) + internal_sig = template.prototype.signature(internal_name, abi_type='ompi', + enable_count=True) + out.dump(consts.INLINE_ATTRS, internal_sig) + template.print_body(func_name=base_name, out=out) + + def generate_function(prototype, fn_name, internal_fn, out, enable_count=False): """Generate a function for the standard ABI.""" - print_profiling_header(fn_name) - print_cdefs_for_bigcount(fn_name,enable_count) + print_profiling_header(fn_name,out) +# print_cdefs_for_bigcount(out, enable_count) # Handle type conversions and arguments params = [param.construct(abi_type='standard') for param in prototype.params] @@ -344,6 +429,7 @@ def generate_function(prototype, fn_name, internal_fn, enable_count=False): return_type = prototype.return_type.construct(abi_type='standard') lines.append(f'{return_type.tmp_type_text()} ret_value;') for param in params: +# print("param = " + str(param) + " " + str(param.argument)) if param.init_code: lines.extend(param.init_code) pass_args = ', '.join(param.argument for param in params) @@ -359,10 +445,12 @@ def generate_function(prototype, fn_name, internal_fn, enable_count=False): out.dump(line) out.dump('}') - generate_function(template.prototype, base_name, internal_name) + internal_name = f'ompi_abi_{template.prototype.name}' + generate_function(template.prototype, base_name, internal_name, out) if util.prototype_has_bigcount(template.prototype): base_name_c = f'{base_name}_c' - generate_function(template.prototype, base_name_c, internal_name, + internal_name = f'ompi_abi_{template.prototype.name}_c' + generate_function(template.prototype, base_name_c, internal_name, out, enable_count=True) diff --git a/ompi/mpi/bindings/ompi_bindings/c_type.py b/ompi/mpi/bindings/ompi_bindings/c_type.py index 532dfb88e37..b9c059f2772 100644 --- a/ompi/mpi/bindings/ompi_bindings/c_type.py +++ b/ompi/mpi/bindings/ompi_bindings/c_type.py @@ -8,8 +8,8 @@ # $HEADER$ """C type definitions.""" from abc import ABC, abstractmethod -from ompi_bindings.consts import ConvertFuncs, ConvertOMPIToStandard - +from ompi_bindings.consts import ConvertFuncs, ConvertOMPIToStandard, IGNORED_STATUS_HANDLES +from ompi_bindings import util class Type(ABC): """Type representation.""" @@ -24,7 +24,7 @@ def __init__(self, type_name, name=None, self.type = type_name self.name = name self.count_param = count_param - self.mangle_name = mangle_name + self.mangle_name = util.abi_internal_name @staticmethod def construct(abi_type, type_name, **kwargs): @@ -32,6 +32,7 @@ def construct(abi_type, type_name, **kwargs): if abi_type == 'ompi': return Type.PARAMS_OMPI_ABI[type_name](type_name, **kwargs) elif abi_type == 'standard': +# print("Checkint oug type " + str(type_name)) return Type.PARAMS_STANDARD_ABI[type_name](type_name, **kwargs) else: raise RuntimeError(f'invalid ABI type {abi_type}') @@ -43,6 +44,7 @@ def wrapper(class_): if 'ompi' in abi_type: Type.PARAMS_OMPI_ABI[type_name] = class_ if 'standard' in abi_type: +# print("Adding type " + str(type_name) + " to PARAMS_STANDARD_ABI") Type.PARAMS_STANDARD_ABI[type_name] = class_ return class_ return wrapper @@ -340,6 +342,12 @@ class TypeDatatype(Type): def type_text(self, enable_count=False): return 'MPI_Datatype' +@Type.add_type('DATATYPE_OUT', abi_type=['ompi']) +class TypeDatatypeOut(Type): + + def type_text(self, enable_count=False): + return 'MPI_Datatype *' + @Type.add_type('DATATYPE_ARRAY', abi_type=['ompi']) class TypeDatatypeArray(Type): @@ -369,19 +377,18 @@ class TypeDatatypeStandard(StandardABIType): def init_code(self): return [f'MPI_Datatype {self.tmpname} = {ConvertFuncs.DATATYPE}({self.name});'] - def type_text(self, enable_count=False): - return self.mangle_name('MPI_Datatype') - + def tmp_type_text(self, enable_count=False): + return 'MPI_Datatype' -@Type.add_type('DATATYPE_OUT', abi_type=['ompi']) -class TypeDatatypeOut(Type): + def return_code(self, name): + return [f'return {ConvertOMPIToStandard.DATATYPE}({name});'] def type_text(self, enable_count=False): - return 'MPI_Datatype *' + return self.mangle_name('MPI_Datatype') @Type.add_type('DATATYPE_OUT', abi_type=['standard']) -class TypeDatatypeStandard(Type): +class TypeDatatypeOutStandard(StandardABIType): @property def final_code(self): @@ -395,6 +402,43 @@ def type_text(self, enable_count=False): def argument(self): return f'(MPI_Datatype *) {self.name}' +# +# TODO THIS IS NOT COMPLETE +# +@Type.add_type('DATATYPE_ARRAY', abi_type=['standard']) +class TypeDatatypeArrayStandard(StandardABIType): + + @property + def init_code(self): + if self.count_param is None: + code = [f'MPI_Comm comm_{self.tmpname} = {ConvertFuncs.COMM}(comm);'] + code.append(f'int size_{self.tmpname} = OMPI_COMM_IS_INTER(comm_{self.tmpname})?ompi_comm_remote_size(comm_{self.tmpname}):ompi_comm_size(comm_{self.tmpname});') + else: + code = [f'int size_{self.tmpname} = {self.count_param};'] + code.append(f'MPI_Datatype *{self.tmpname} = (MPI_Datatype *)malloc(sizeof(MPI_Datatype) * size_{self.tmpname});') + code.append(f'for(int i=0;i $@ -standard_abi/mpi.h: abi.py $(prototype_sources) +abi.h: $(prototype_sources) + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + header \ + --srcdir $(srcdir) \ + $(prototype_sources) +standard_abi/mpi.h: $(prototype_sources) mkdir -p standard_abi - $(OMPI_V_GEN) $(PYTHON) $(srcdir)/abi.py header --srcdir=$(srcdir) --external $(prototype_sources) > $@ + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + header \ + --srcdir $(srcdir) \ + --external \ + $(prototype_sources) endif # Delete generated files on maintainer-clean MAINTAINERCLEANFILES = *_generated.c abi.h standard_abi/ diff --git a/ompi/mpi/c/comm_spawn_multiple.c.in b/ompi/mpi/c/comm_spawn_multiple.c.in index a729df6dfd0..72b43a2dbc3 100644 --- a/ompi/mpi/c/comm_spawn_multiple.c.in +++ b/ompi/mpi/c/comm_spawn_multiple.c.in @@ -42,7 +42,7 @@ #include "ompi/memchecker.h" PROTOTYPE ERROR_CLASS comm_spawn_multiple(INT count, STRING_ARRAY array_of_commands, ARGV array_of_argv, - INT_ARRAY array_of_maxprocs, INFO_ARRAY array_of_info, + INT_ARRAY array_of_maxprocs, INFO_ARRAY array_of_info:count, INT root, COMM comm, COMM_OUT intercomm, INT_OUT array_of_errcodes) { diff --git a/ompi/mpi/c/file_close.c.in b/ompi/mpi/c/file_close.c.in index 4111c6a3026..19b844be21a 100644 --- a/ompi/mpi/c/file_close.c.in +++ b/ompi/mpi/c/file_close.c.in @@ -27,7 +27,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/file/file.h" -PROTOTYPE ERROR_CLASS file_close(FILE_OUT fh) +PROTOTYPE ERROR_CLASS file_close(FILE_INOUT fh) { int rc; diff --git a/ompi/mpi/c/isendrecv_replace.c.in b/ompi/mpi/c/isendrecv_replace.c.in index 2dad8a3078e..0d3dd307b8b 100644 --- a/ompi/mpi/c/isendrecv_replace.c.in +++ b/ompi/mpi/c/isendrecv_replace.c.in @@ -34,6 +34,10 @@ #include "ompi/proc/proc.h" #include "ompi/memchecker.h" #include "ompi/runtime/ompi_spc.h" +#include "opal/mca/mpool/mpool.h" +#ifdef OMPI_NO_MPI_PROTOTYPES +#include "ompi/mpi/c/abi.h" +#endif struct ompi_isendrecv_replace_context_t { opal_object_t super; @@ -58,7 +62,7 @@ static void ompi_isendrecv_context_constructor(ompi_isendrecv_replace_context_t static void ompi_isendrecv_context_destructor(ompi_isendrecv_replace_context_t *context) { if (context->packed_size > sizeof(context->packed_data)) { - PMPI_Free_mem(context->iov.iov_base); + mca_mpool_base_free(context->iov.iov_base); } OBJ_DESTRUCT(&context->convertor); } @@ -181,8 +185,8 @@ PROTOTYPE ERROR_CLASS isendrecv_replace(BUFFER_OUT buf, COUNT count, DATATYPE da /* setup a buffer for recv */ opal_convertor_get_packed_size( &context->convertor, &context->packed_size ); if( context->packed_size > sizeof(context->packed_data) ) { - rc = PMPI_Alloc_mem(context->packed_size, MPI_INFO_NULL, &context->iov.iov_base); - if(OMPI_SUCCESS != rc) { + context->iov.iov_base = (void *)mca_mpool_base_alloc ((size_t)context->packed_size, NULL, NULL); + if(NULL == context->iov.iov_base) { OBJ_RELEASE(context); ompi_comm_request_return (crequest); OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); diff --git a/ompi/mpi/c/session_finalize.c.in b/ompi/mpi/c/session_finalize.c.in index 44e67abeb8e..90075d5a4c1 100644 --- a/ompi/mpi/c/session_finalize.c.in +++ b/ompi/mpi/c/session_finalize.c.in @@ -17,7 +17,7 @@ #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS session_finalize (SESSION_OUT session) +PROTOTYPE ERROR_CLASS session_finalize (SESSION_INOUT session) { int rc; diff --git a/ompi/mpi/c/type_create_struct.c.in b/ompi/mpi/c/type_create_struct.c.in index accea45f603..98e31f567a6 100644 --- a/ompi/mpi/c/type_create_struct.c.in +++ b/ompi/mpi/c/type_create_struct.c.in @@ -40,7 +40,7 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count, COUNT_ARRAY array_of_blocklengths, AINT_COUNT_ARRAY array_of_displacements, - DATATYPE_ARRAY array_of_types, + DATATYPE_ARRAY array_of_types:count, DATATYPE_OUT newtype) { int i, rc, icount = (int)count; diff --git a/ompi/mpi/c/win_create_errhandler.c.in b/ompi/mpi/c/win_create_errhandler.c.in index 27a48e33aa4..3391c643524 100644 --- a/ompi/mpi/c/win_create_errhandler.c.in +++ b/ompi/mpi/c/win_create_errhandler.c.in @@ -30,7 +30,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/win/win.h" -PROTOTYPE ERROR_CLASS win_create_errhandler(WIN_ERRHANLDER_FUNCTION function, +PROTOTYPE ERROR_CLASS win_create_errhandler(WIN_ERRHANDLER_FUNCTION function, ERRHANDLER_OUT errhandler) { int err = MPI_SUCCESS; diff --git a/ompi/mpi/c/win_f2c.c b/ompi/mpi/c/win_f2c.c.in similarity index 88% rename from ompi/mpi/c/win_f2c.c rename to ompi/mpi/c/win_f2c.c.in index 82bf2b9cc71..f7b979d80aa 100644 --- a/ompi/mpi/c/win_f2c.c +++ b/ompi/mpi/c/win_f2c.c.in @@ -27,16 +27,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/mpi/fortran/base/fint_2_int.h" -#if OMPI_BUILD_MPI_PROFILING -#if OPAL_HAVE_WEAK_SYMBOLS -#pragma weak MPI_Win_f2c = PMPI_Win_f2c -#endif -#define MPI_Win_f2c PMPI_Win_f2c -#endif - -static const char FUNC_NAME[] = "MPI_Win_f2c"; - -MPI_Win MPI_Win_f2c(MPI_Fint win) +PROTOTYPE WIN win_f2c(FINT win) { int o_index= OMPI_FINT_2_INT(win); diff --git a/ompi/mpi/c/wtime.c.in b/ompi/mpi/c/wtime.c.in index cc22d427142..e31db4d630e 100644 --- a/ompi/mpi/c/wtime.c.in +++ b/ompi/mpi/c/wtime.c.in @@ -45,7 +45,7 @@ * and accuracy of the user visible timer. * More info: https://github.com/mpi-forum/mpi-issues/issues/77#issuecomment-369663119 */ -extern struct timespec ompi_wtime_time_origin = {.tv_sec = 0}; +extern struct timespec ompi_wtime_time_origin; PROTOTYPE DOUBLE wtime() { From 49f042cd9a6761a49fce9c76a698506993b13833 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Wed, 28 May 2025 15:17:26 -0600 Subject: [PATCH 3/6] bindings: fix up makefile for c interfaces to heed the --enable-abi-standard config option Signed-off-by: Howard Pritchard --- ompi/mpi/c/Makefile.am | 62 ++-------------------- ompi/mpi/c/Makefile_abi.include | 94 +++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 58 deletions(-) create mode 100644 ompi/mpi/c/Makefile_abi.include diff --git a/ompi/mpi/c/Makefile.am b/ompi/mpi/c/Makefile.am index bd8c67b3cb8..b7832126750 100644 --- a/ompi/mpi/c/Makefile.am +++ b/ompi/mpi/c/Makefile.am @@ -38,11 +38,8 @@ include $(top_srcdir)/Makefile.ompi-rules noinst_LTLIBRARIES = libmpi_c.la libmpi_c_profile.la -if OMPI_STANDARD_ABI -noinst_LTLIBRARIES += libmpi_c_abi.la libmpi_c_abi_profile.la -endif if BUILD_MPI_BINDINGS_LAYER -noinst_LTLIBRARIES += libmpi_c_noprofile.la libmpi_c_abi_noprofile.la +noinst_LTLIBRARIES += libmpi_c_noprofile.la endif headers = bindings.h @@ -483,7 +480,6 @@ prototype_sources = \ wtime.c.in EXTRA_DIST = $(prototype_sources) -BUILT_SOURCES = abi.h standard_abi/mpi.h # attr_fn.c contains attribute manipulation functions which do not # profiling implications, and so are always built. @@ -501,25 +497,12 @@ if BUILD_MPI_BINDINGS_LAYER libmpi_c_la_LIBADD += libmpi_c_noprofile.la endif -libmpi_c_abi_la_SOURCES = \ - attr_fn.c \ - abi_details.c \ - abi_supported.c \ - abi_version.c - -libmpi_c_abi_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -libmpi_c_abi_la_LIBADD = libmpi_c_abi_profile.la -if BUILD_MPI_BINDINGS_LAYER -libmpi_c_abi_la_LIBADD += libmpi_c_abi_noprofile.la -endif - # # List of all C files that have profile versions (*_generated.c files were # generated from prototype_sources above). # # interface_profile_sources = $(prototype_sources:.c.in=_ompi_generated.c) -abi_interface_profile_sources = $(prototype_sources:.c.in=_abi_generated.c) # Conditionally install the header files @@ -561,15 +544,6 @@ libmpi_c_profile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=1 libmpi_c_noprofile_la_SOURCES = $(interface_profile_sources) $(extra_interface_profile_sources) $(deprecated_interface_profile_sources) libmpi_c_noprofile_la_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=0 -libmpi_c_abi_profile_la_SOURCES = $(abi_interface_profile_sources) -libmpi_c_abi_profile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=1 - -libmpi_c_abi_noprofile_la_SOURCES = $(abi_interface_profile_sources) -libmpi_c_abi_noprofile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=0 - -nobase_include_HEADERS = standard_abi/mpi.h - -# ABI generation rules if OMPI_GENERATE_BINDINGS %_ompi_generated.c: %.c.in $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ @@ -580,36 +554,8 @@ if OMPI_GENERATE_BINDINGS source \ ompi \ $< +endif -%_abi_generated.c: %.c.in - $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ - --builddir $(abs_top_builddir) \ - --srcdir $(abs_top_srcdir) \ - --output $@ \ - c \ - source \ - standard \ - $< -abi.h: $(prototype_sources) - $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ - --builddir $(abs_top_builddir) \ - --srcdir $(abs_top_srcdir) \ - --output $@ \ - c \ - header \ - --srcdir $(srcdir) \ - $(prototype_sources) -standard_abi/mpi.h: $(prototype_sources) - mkdir -p standard_abi - $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ - --builddir $(abs_top_builddir) \ - --srcdir $(abs_top_srcdir) \ - --output $@ \ - c \ - header \ - --srcdir $(srcdir) \ - --external \ - $(prototype_sources) +if OMPI_STANDARD_ABI +include Makefile_abi.include endif -# Delete generated files on maintainer-clean -MAINTAINERCLEANFILES = *_generated.c abi.h standard_abi/ diff --git a/ompi/mpi/c/Makefile_abi.include b/ompi/mpi/c/Makefile_abi.include new file mode 100644 index 00000000000..4a2e38d07be --- /dev/null +++ b/ompi/mpi/c/Makefile_abi.include @@ -0,0 +1,94 @@ +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2013 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 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) 2009-2021 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2011 Sandia National Laboratories. All rights reserved. +# Copyright (c) 2012 Oak Rigde National Laboratory. All rights reserved. +# Copyright (c) 2012-2013 Inria. All rights reserved. +# Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights +# reserved. +# Copyright (c) 2015-2020 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights +# reserved. +# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# ABI specific make components + +noinst_LTLIBRARIES += libmpi_c_abi.la libmpi_c_abi_profile.la +if BUILD_MPI_BINDINGS_LAYER +noinst_LTLIBRARIES += libmpi_c_abi_noprofile.la +endif + +BUILT_SOURCES = abi.h standard_abi/mpi.h + + +libmpi_c_abi_la_SOURCES = \ + attr_fn.c \ + abi_details.c \ + abi_supported.c \ + abi_version.c + +libmpi_c_abi_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES +libmpi_c_abi_la_LIBADD = libmpi_c_abi_profile.la +if BUILD_MPI_BINDINGS_LAYER +libmpi_c_abi_la_LIBADD += libmpi_c_abi_noprofile.la +endif + +abi_interface_profile_sources = $(prototype_sources:.c.in=_abi_generated.c) + +libmpi_c_abi_profile_la_SOURCES = $(abi_interface_profile_sources) +libmpi_c_abi_profile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=1 + +libmpi_c_abi_noprofile_la_SOURCES = $(abi_interface_profile_sources) +libmpi_c_abi_noprofile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=0 + +nobase_include_HEADERS = abi.h standard_abi/mpi.h + +if OMPI_GENERATE_BINDINGS +%_abi_generated.c: %.c.in + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + source \ + standard \ + $< +abi.h: $(prototype_sources) + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + header \ + --srcdir $(srcdir) \ + $(prototype_sources) +standard_abi/mpi.h: $(prototype_sources) + mkdir -p standard_abi + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + header \ + --srcdir $(srcdir) \ + --external \ + $(prototype_sources) +endif +# Delete generated files on maintainer-clean +MAINTAINERCLEANFILES = *_generated.c abi.h standard_abi/ From 29b1a2fdcb8abf0b86d97846cbe61b755b4237ae Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Thu, 29 May 2025 11:39:37 -0600 Subject: [PATCH 4/6] makefile fixes Signed-off-by: Howard Pritchard --- ompi/mpi/c/Makefile.am | 32 ++++++++++++++++++++++++++++ ompi/mpi/c/Makefile_abi.include | 37 ++------------------------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/ompi/mpi/c/Makefile.am b/ompi/mpi/c/Makefile.am index b7832126750..3ae12d53654 100644 --- a/ompi/mpi/c/Makefile.am +++ b/ompi/mpi/c/Makefile.am @@ -497,6 +497,8 @@ if BUILD_MPI_BINDINGS_LAYER libmpi_c_la_LIBADD += libmpi_c_noprofile.la endif +nobase_include_HEADERS = abi.h standard_abi/mpi.h + # # List of all C files that have profile versions (*_generated.c files were # generated from prototype_sources above). @@ -554,8 +556,38 @@ if OMPI_GENERATE_BINDINGS source \ ompi \ $< +abi.h: $(prototype_sources) + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + header \ + --srcdir $(srcdir) \ + $(prototype_sources) +standard_abi/mpi.h: $(prototype_sources) + mkdir -p standard_abi + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + header \ + --srcdir $(srcdir) \ + --external \ + $(prototype_sources) +%_abi_generated.c: %.c.in + $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ + --builddir $(abs_top_builddir) \ + --srcdir $(abs_top_srcdir) \ + --output $@ \ + c \ + source \ + standard \ + $< endif +MAINTAINERCLEANFILES = *_generated.c abi.h if OMPI_STANDARD_ABI include Makefile_abi.include endif diff --git a/ompi/mpi/c/Makefile_abi.include b/ompi/mpi/c/Makefile_abi.include index 4a2e38d07be..c082b84e1c0 100644 --- a/ompi/mpi/c/Makefile_abi.include +++ b/ompi/mpi/c/Makefile_abi.include @@ -29,6 +29,8 @@ # ABI specific make components +if OMPI_STANDARD_ABI + noinst_LTLIBRARIES += libmpi_c_abi.la libmpi_c_abi_profile.la if BUILD_MPI_BINDINGS_LAYER noinst_LTLIBRARIES += libmpi_c_abi_noprofile.la @@ -36,7 +38,6 @@ endif BUILT_SOURCES = abi.h standard_abi/mpi.h - libmpi_c_abi_la_SOURCES = \ attr_fn.c \ abi_details.c \ @@ -57,38 +58,4 @@ libmpi_c_abi_profile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PRO libmpi_c_abi_noprofile_la_SOURCES = $(abi_interface_profile_sources) libmpi_c_abi_noprofile_la_CPPFLAGS = -DOMPI_NO_MPI_PROTOTYPES -DOMPI_BUILD_MPI_PROFILING=0 -nobase_include_HEADERS = abi.h standard_abi/mpi.h - -if OMPI_GENERATE_BINDINGS -%_abi_generated.c: %.c.in - $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ - --builddir $(abs_top_builddir) \ - --srcdir $(abs_top_srcdir) \ - --output $@ \ - c \ - source \ - standard \ - $< -abi.h: $(prototype_sources) - $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ - --builddir $(abs_top_builddir) \ - --srcdir $(abs_top_srcdir) \ - --output $@ \ - c \ - header \ - --srcdir $(srcdir) \ - $(prototype_sources) -standard_abi/mpi.h: $(prototype_sources) - mkdir -p standard_abi - $(OMPI_V_GEN) $(PYTHON) $(top_srcdir)/ompi/mpi/bindings/bindings.py \ - --builddir $(abs_top_builddir) \ - --srcdir $(abs_top_srcdir) \ - --output $@ \ - c \ - header \ - --srcdir $(srcdir) \ - --external \ - $(prototype_sources) endif -# Delete generated files on maintainer-clean -MAINTAINERCLEANFILES = *_generated.c abi.h standard_abi/ From 8a7407f0f739349502cc530c40c2b84d45331b08 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Mon, 2 Jun 2025 15:50:19 -0600 Subject: [PATCH 5/6] checkpoint Signed-off-by: Howard Pritchard --- .gitignore | 1 - ompi/mpi/bindings/ompi_bindings/c.py | 8 +- ompi/mpi/bindings/ompi_bindings/c_type.py | 60 +++++++ ompi/mpi/c/Makefile.am | 8 +- ompi/mpi/c/bindings.h | 5 + ompi/mpi/c/isendrecv.c.in | 105 +------------ ompi/mpi/c/isendrecv_replace.c.in | 2 +- .../c/{keyval_create.c.in => keyval_create.c} | 19 ++- .../mpi/c/{keyval_free.c.in => keyval_free.c} | 13 +- ompi/mpi/c/ompi_isendrecv.c | 147 ++++++++++++++++++ ompi/mpi/c/ompi_sendrecv.c | 97 ++++++++++++ ompi/mpi/c/sendrecv.c.in | 54 +------ ompi/mpi/c/sendrecv_replace.c.in | 9 +- ompi/mpi/c/status_set_cancelled.c.in | 2 +- ompi/mpi/c/status_set_elements.c.in | 2 +- ompi/mpi/c/status_set_elements_x.c.in | 2 +- ompi/mpi/c/status_set_error.c.in | 2 +- ompi/mpi/c/status_set_source.c.in | 2 +- ompi/mpi/c/status_set_tag.c.in | 2 +- 19 files changed, 358 insertions(+), 182 deletions(-) rename ompi/mpi/c/{keyval_create.c.in => keyval_create.c} (76%) rename ompi/mpi/c/{keyval_free.c.in => keyval_free.c} (78%) create mode 100644 ompi/mpi/c/ompi_isendrecv.c create mode 100644 ompi/mpi/c/ompi_sendrecv.c diff --git a/.gitignore b/.gitignore index fc1a3349a33..d31d774b831 100644 --- a/.gitignore +++ b/.gitignore @@ -535,7 +535,6 @@ docs/man # Generated C Bindings ompi/mpi/c/*_generated*.c -ompi/mpi/c/ompi_*.c ompi/mpi/c/standard_*.c ompi/mpi/c/abi.h ompi/mpi/c/standard_abi diff --git a/ompi/mpi/bindings/ompi_bindings/c.py b/ompi/mpi/bindings/ompi_bindings/c.py index bc515fd21b5..9957c56ad7b 100644 --- a/ompi/mpi/bindings/ompi_bindings/c.py +++ b/ompi/mpi/bindings/ompi_bindings/c.py @@ -218,8 +218,11 @@ def generate_status_convert_fn(self): abi_type = self.mangle_name(type_) self.dump(f'{consts.INLINE_ATTRS} void {ConvertFuncs.STATUS}({type_} *out, {abi_type} *inp)') self.dump('{') + self.dump(' void *ptr = &out->_ucount;') self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;') self.dump(' out->MPI_TAG = inp->MPI_TAG;') + self.dump(' out->_cancelled = inp->MPI_Internal[0];') + self.dump(' memcpy(ptr, &inp->MPI_Internal[1],sizeof(out->_ucount));') self.dump(f' out->MPI_ERROR = {ConvertFuncs.ERROR_CLASS}(inp->MPI_ERROR);') # Ignoring the private fields for now self.dump('}') @@ -229,8 +232,11 @@ def generate_status_convert_fn_intern_to_abi(self): abi_type = self.mangle_name(type_) self.dump(f'{consts.INLINE_ATTRS} void {ConvertOMPIToStandard.STATUS}({abi_type} *out, {type_} *inp)') self.dump('{') + self.dump(' void *ptr = &out->MPI_Internal[1];') self.dump(' out->MPI_SOURCE = inp->MPI_SOURCE;') self.dump(' out->MPI_TAG = inp->MPI_TAG;') + self.dump(' out->MPI_Internal[0] =inp->_cancelled;') + self.dump(' memcpy(ptr, &inp->_ucount,sizeof(inp->_ucount));') # self.dump(f' out->MPI_ERROR = {ConvertOMPIToStandard.ERROR_CLASS}(inp->MPI_ERROR);') # Ignoring the private fields for now self.dump('}') @@ -309,7 +315,7 @@ def dump_header(self): int MPI_SOURCE; int MPI_TAG; int MPI_ERROR; - int mpi_abi_private[5]; + int MPI_Internal[5]; };""") self.dump(f'typedef struct MPI_Status_ABI {self.mangle_name("MPI_Status")};') self.dump() diff --git a/ompi/mpi/bindings/ompi_bindings/c_type.py b/ompi/mpi/bindings/ompi_bindings/c_type.py index b9c059f2772..1c403c2f571 100644 --- a/ompi/mpi/bindings/ompi_bindings/c_type.py +++ b/ompi/mpi/bindings/ompi_bindings/c_type.py @@ -757,6 +757,66 @@ def parameter(self, enable_count=False, **kwargs): else: return f'{type_name} {self.name}[]' +@Type.add_type('STATUS_INOUT', abi_type=['ompi']) +class TypeStatusInOut(Type): + + def type_text(self, enable_count=False): + return 'MPI_Status *' + + def parameter(self, enable_count=False, **kwargs): + if self.count_param is None: + return f'MPI_Status *{self.name}' + else: + return f'MPI_Status {self.name}[]' + +# +# so far there are no vectors of statuses for inout in the the standard +# +@Type.add_type('STATUS_INOUT', abi_type=['standard']) +class TypeStausInOutStandard(StandardABIType): + + def if_should_set_status(self): + """Generate the condition to check if the status(es) should be set.""" + condition = ' && '.join(f'{self.mangle_name(const)} != {self.name}' + for const in IGNORED_STATUS_HANDLES) + return 'if (%s) {' % (condition,) + + @property + def status_argument(self): + return f'{self.name}_arg' + + @property + def init_code(self): + mangle_type = self.mangle_name('MPI_Status') + code = [f'MPI_Status *{self.status_argument} = NULL;'] + code.append(f'MPI_Status {self.tmpname};') + code.append(f'{ConvertFuncs.STATUS}(&{self.tmpname}, ({mangle_type} *){self.name});') + code.append(self.if_should_set_status()) + code.append(f'{self.status_argument} = &{self.tmpname};') + code.append('} else {') + code.append(f'{self.status_argument} = MPI_STATUS_IGNORE;') + code.append('}') + return code + + @property + def final_code(self): + code = [self.if_should_set_status()] + code.append(f'{ConvertOMPIToStandard.STATUS}({self.name}, &{self.tmpname});') + code.append('}') + return code + + @property + def argument(self): + return self.status_argument + + def type_text(self, enable_count=False): + type_name = self.mangle_name('MPI_Status') + return f'{type_name} *' + + def parameter(self, enable_count=False, **kwargs): + type_name = self.mangle_name('MPI_Status') + return f'{type_name} *{self.name}' + @Type.add_type('F08_STATUS') class TypeF08Status(Type): diff --git a/ompi/mpi/c/Makefile.am b/ompi/mpi/c/Makefile.am index 3ae12d53654..7d396f098c5 100644 --- a/ompi/mpi/c/Makefile.am +++ b/ompi/mpi/c/Makefile.am @@ -293,8 +293,6 @@ prototype_sources = \ isendrecv_replace.c.in \ issend.c.in \ is_thread_main.c.in \ - keyval_create.c.in \ - keyval_free.c.in \ lookup_name.c.in \ message_c2f.c.in \ message_f2c.c.in \ @@ -490,7 +488,9 @@ libmpi_c_la_SOURCES = \ libmpi_c_la_SOURCES += \ abi_details.c \ abi_supported.c \ - abi_version.c + abi_version.c \ + ompi_isendrecv.c \ + ompi_sendrecv.c libmpi_c_la_LIBADD = libmpi_c_profile.la if BUILD_MPI_BINDINGS_LAYER @@ -533,6 +533,8 @@ deprecated_interface_profile_sources = \ errhandler_create.c \ errhandler_get.c \ errhandler_set.c \ + keyval_create.c \ + keyval_free.c \ type_extent.c \ type_hindexed.c \ type_hvector.c \ diff --git a/ompi/mpi/c/bindings.h b/ompi/mpi/c/bindings.h index 2a849feea8d..717fe79287f 100644 --- a/ompi/mpi/c/bindings.h +++ b/ompi/mpi/c/bindings.h @@ -116,6 +116,11 @@ BEGIN_C_DECLS } while (0) +int ompi_sendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag, + void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status); +int ompi_isendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag, + void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Request * request); + END_C_DECLS #endif /* OMPI_C_BINDINGS_H */ diff --git a/ompi/mpi/c/isendrecv.c.in b/ompi/mpi/c/isendrecv.c.in index 39f410b6796..8bd8a75afa6 100644 --- a/ompi/mpi/c/isendrecv.c.in +++ b/ompi/mpi/c/isendrecv.c.in @@ -37,60 +37,12 @@ #include "ompi/runtime/ompi_spc.h" -struct ompi_isendrecv_context_t { - opal_object_t super; - int nreqs; - int source; - ompi_request_t *subreq[2]; -}; - -typedef struct ompi_isendrecv_context_t ompi_isendrecv_context_t; -#if OMPI_BUILD_MPI_PROFILING -OBJ_CLASS_INSTANCE(ompi_isendrecv_context_t, opal_object_t, NULL, NULL); -#else -OBJ_CLASS_DECLARATION(ompi_isendrecv_context_t); -#endif /* OMPI_BUILD_MPI_PROFILING */ - -static int ompi_isendrecv_complete_func (ompi_comm_request_t *request) -{ - ompi_isendrecv_context_t *context = - (ompi_isendrecv_context_t *) request->context; - - /* - * Copy the status from the receive side of the sendrecv request? - * But what if the send failed? - * - * Probably need to bring up in the MPI forum. - */ - - if (MPI_PROC_NULL != context->source) { - OMPI_COPY_STATUS(&request->super.req_status, - context->subreq[0]->req_status, false); - } else { - OMPI_COPY_STATUS(&request->super.req_status, - ompi_request_empty.req_status, false); - } - - if(NULL != context->subreq[0]) { - ompi_request_free(&context->subreq[0]); - } - if(NULL != context->subreq[1]) { - ompi_request_free(&context->subreq[1]); - } - - return OMPI_SUCCESS; -} - PROTOTYPE ERROR_CLASS isendrecv(BUFFER sendbuf, COUNT sendcount, DATATYPE sendtype, INT dest, INT sendtag, BUFFER_OUT recvbuf, COUNT recvcount, DATATYPE recvtype, INT source, INT recvtag, COMM comm, REQUEST_INOUT request) { - ompi_isendrecv_context_t *context = NULL; - ompi_comm_request_t *crequest; int rc = MPI_SUCCESS; - int nreqs = 0; - uint32_t flags; SPC_RECORD(OMPI_SPC_ISENDRECV, 1); @@ -125,64 +77,9 @@ PROTOTYPE ERROR_CLASS isendrecv(BUFFER sendbuf, COUNT sendcount, DATATYPE sendty OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } - crequest = ompi_comm_request_get (); - if (NULL == crequest) { - return OMPI_ERR_OUT_OF_RESOURCE; - } - - context = OBJ_NEW(ompi_isendrecv_context_t); - if (NULL == context) { - ompi_comm_request_return (crequest); - return OMPI_ERR_OUT_OF_RESOURCE; - } - - crequest->context = &context->super; - context->subreq[0] = MPI_REQUEST_NULL; - context->subreq[1] = MPI_REQUEST_NULL; - context->source = source; - - if (source != MPI_PROC_NULL) { /* post recv */ - rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype, - source, recvtag, comm, &context->subreq[nreqs++])); - if (MPI_SUCCESS != rc) { - OBJ_RELEASE(context); - ompi_comm_request_return (crequest); - } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); - } - - if (dest != MPI_PROC_NULL) { /* send */ - rc = MCA_PML_CALL(isend(sendbuf, sendcount, sendtype, dest, - sendtag, MCA_PML_BASE_SEND_STANDARD, comm, &context->subreq[nreqs++])); - if (MPI_SUCCESS != rc) { - OBJ_RELEASE(context); - ompi_comm_request_return (crequest); - } - OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); - } - - /* - * schedule the operation - */ - - context->nreqs = nreqs; - assert(nreqs <= 2); - - flags = OMPI_COMM_REQ_FLAG_RETAIN_SUBREQ; - - rc = ompi_comm_request_schedule_append_w_flags(crequest, ompi_isendrecv_complete_func, - context->subreq, nreqs, flags); - if (MPI_SUCCESS != rc) { - OBJ_RELEASE(context); - ompi_comm_request_return (crequest); - } + rc = ompi_isendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, request); OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); - /* kick off the request */ - - ompi_comm_request_start (crequest); - *request = &crequest->super; - return rc; } diff --git a/ompi/mpi/c/isendrecv_replace.c.in b/ompi/mpi/c/isendrecv_replace.c.in index 0d3dd307b8b..34077e25603 100644 --- a/ompi/mpi/c/isendrecv_replace.c.in +++ b/ompi/mpi/c/isendrecv_replace.c.in @@ -148,7 +148,7 @@ PROTOTYPE ERROR_CLASS isendrecv_replace(BUFFER_OUT buf, COUNT count, DATATYPE da /* simple case */ if ( source == MPI_PROC_NULL || dest == MPI_PROC_NULL || count == 0 ) { - rc = PMPI_Isendrecv(buf, count, datatype, dest, sendtag, buf, count, datatype, source, recvtag, comm, request); + rc = ompi_isendrecv(buf, count, datatype, dest, sendtag, buf, count, datatype, source, recvtag, comm, request); return rc; } diff --git a/ompi/mpi/c/keyval_create.c.in b/ompi/mpi/c/keyval_create.c similarity index 76% rename from ompi/mpi/c/keyval_create.c.in rename to ompi/mpi/c/keyval_create.c index 8a318ad4da3..d802c257dc9 100644 --- a/ompi/mpi/c/keyval_create.c.in +++ b/ompi/mpi/c/keyval_create.c @@ -1,3 +1,4 @@ +/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND. */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology @@ -31,22 +32,26 @@ #include "ompi/attribute/attribute.h" #include "ompi/communicator/communicator.h" -PROTOTYPE ERROR_CLASS keyval_create(COPY_FUNCTION copy_attr_fn, - DELETE_FUNCTION delete_attr_fn, - INT_OUT keyval, BUFFER_OUT extra_state) +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS +#pragma weak MPI_Keyval_create = PMPI_Keyval_create +#endif +#define MPI_Keyval_create PMPI_Keyval_create +#endif +int MPI_Keyval_create(MPI_Copy_function * copy_attr_fn, MPI_Delete_function * delete_attr_fn, int *keyval, void * extra_state) { int ret; ompi_attribute_fn_ptr_union_t copy_fn; ompi_attribute_fn_ptr_union_t del_fn; if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + OMPI_ERR_INIT_FINALIZE("MPI_Keyval_create"); if (NULL == keyval) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_KEYVAL, - FUNC_NAME); + "MPI_Keyval_create"); } else if ((NULL == copy_attr_fn) || (NULL == delete_attr_fn)) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, - FUNC_NAME); + "MPI_Keyval_create"); } } @@ -55,5 +60,5 @@ PROTOTYPE ERROR_CLASS keyval_create(COPY_FUNCTION copy_attr_fn, ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn, del_fn, keyval, extra_state, 0, NULL); - OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, FUNC_NAME); + OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, "MPI_Keyval_create"); } diff --git a/ompi/mpi/c/keyval_free.c.in b/ompi/mpi/c/keyval_free.c similarity index 78% rename from ompi/mpi/c/keyval_free.c.in rename to ompi/mpi/c/keyval_free.c index 8705ada7a10..6b6ffa06b8a 100644 --- a/ompi/mpi/c/keyval_free.c.in +++ b/ompi/mpi/c/keyval_free.c @@ -1,3 +1,4 @@ +/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND. */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology @@ -28,7 +29,13 @@ #include "ompi/attribute/attribute.h" #include "ompi/communicator/communicator.h" -PROTOTYPE ERROR_CLASS keyval_free(INT_OUT keyval) +#if OMPI_BUILD_MPI_PROFILING +#if OPAL_HAVE_WEAK_SYMBOLS +#pragma weak MPI_Keyval_free = PMPI_Keyval_free +#endif +#define MPI_Keyval_free PMPI_Keyval_free +#endif +int MPI_Keyval_free(int *keyval) { int ret; @@ -36,10 +43,10 @@ PROTOTYPE ERROR_CLASS keyval_free(INT_OUT keyval) if (MPI_PARAM_CHECK) { if (NULL == keyval) { return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_KEYVAL, - FUNC_NAME); + "MPI_Keyval_free"); } } ret = ompi_attr_free_keyval(COMM_ATTR, keyval, 0); - OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, FUNC_NAME); + OMPI_ERRHANDLER_NOHANDLE_RETURN(ret, MPI_ERR_OTHER, "MPI_Keyval_free"); } diff --git a/ompi/mpi/c/ompi_isendrecv.c b/ompi/mpi/c/ompi_isendrecv.c new file mode 100644 index 00000000000..13ce4ef631c --- /dev/null +++ b/ompi/mpi/c/ompi_isendrecv.c @@ -0,0 +1,147 @@ +/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND. */ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2022 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) 2010-2012 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. + * Copyright (c) 2021-2024 Triad National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include "ompi_config.h" + +#include "ompi/mpi/c/bindings.h" +#include "ompi/runtime/params.h" +#include "ompi/communicator/communicator.h" +#include "ompi/communicator/comm_request.h" +#include "ompi/errhandler/errhandler.h" +#include "ompi/mca/pml/pml.h" +#include "ompi/request/request.h" +#include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" + + +struct ompi_isendrecv_context_t { + opal_object_t super; + int nreqs; + int source; + ompi_request_t *subreq[2]; +}; + +typedef struct ompi_isendrecv_context_t ompi_isendrecv_context_t; +OBJ_CLASS_INSTANCE(ompi_isendrecv_context_t, opal_object_t, NULL, NULL); + +static int ompi_isendrecv_complete_func (ompi_comm_request_t *request) +{ + ompi_isendrecv_context_t *context = + (ompi_isendrecv_context_t *) request->context; + + /* + * Copy the status from the receive side of the sendrecv request? + * But what if the send failed? + * + * Probably need to bring up in the MPI forum. + */ + + if (MPI_PROC_NULL != context->source) { + OMPI_COPY_STATUS(&request->super.req_status, + context->subreq[0]->req_status, false); + } else { + OMPI_COPY_STATUS(&request->super.req_status, + ompi_request_empty.req_status, false); + } + + if(NULL != context->subreq[0]) { + ompi_request_free(&context->subreq[0]); + } + if(NULL != context->subreq[1]) { + ompi_request_free(&context->subreq[1]); + } + + return OMPI_SUCCESS; +} + +int ompi_isendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag, void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Request * request) +{ + ompi_isendrecv_context_t *context = NULL; + ompi_comm_request_t *crequest; + int rc = MPI_SUCCESS; + int nreqs = 0; + uint32_t flags; + + crequest = ompi_comm_request_get (); + if (NULL == crequest) { + return OMPI_ERR_OUT_OF_RESOURCE; + } + + context = OBJ_NEW(ompi_isendrecv_context_t); + if (NULL == context) { + ompi_comm_request_return (crequest); + return OMPI_ERR_OUT_OF_RESOURCE; + } + + crequest->context = &context->super; + context->subreq[0] = MPI_REQUEST_NULL; + context->subreq[1] = MPI_REQUEST_NULL; + context->source = source; + + if (source != MPI_PROC_NULL) { /* post recv */ + rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype, + source, recvtag, comm, &context->subreq[nreqs++])); + if (MPI_SUCCESS != rc) { + OBJ_RELEASE(context); + ompi_comm_request_return (crequest); + } + OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Isendrecv"); + } + + if (dest != MPI_PROC_NULL) { /* send */ + rc = MCA_PML_CALL(isend(sendbuf, sendcount, sendtype, dest, + sendtag, MCA_PML_BASE_SEND_STANDARD, comm, &context->subreq[nreqs++])); + if (MPI_SUCCESS != rc) { + OBJ_RELEASE(context); + ompi_comm_request_return (crequest); + } + OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Isendrecv"); + } + + /* + * schedule the operation + */ + + context->nreqs = nreqs; + assert(nreqs <= 2); + + flags = OMPI_COMM_REQ_FLAG_RETAIN_SUBREQ; + + rc = ompi_comm_request_schedule_append_w_flags(crequest, ompi_isendrecv_complete_func, + context->subreq, nreqs, flags); + if (MPI_SUCCESS != rc) { + OBJ_RELEASE(context); + ompi_comm_request_return (crequest); + } + + /* kick off the request */ + + ompi_comm_request_start (crequest); + *request = &crequest->super; + + return rc; +} diff --git a/ompi/mpi/c/ompi_sendrecv.c b/ompi/mpi/c/ompi_sendrecv.c new file mode 100644 index 00000000000..0bcdc5ecce3 --- /dev/null +++ b/ompi/mpi/c/ompi_sendrecv.c @@ -0,0 +1,97 @@ +/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND. */ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2021 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) 2010-2012 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2013 Los Alamos National Security, LLC. All rights + * reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2021 Nanook Consulting. All rights reserved. + * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. + * Copyright (c) 2024 Triad National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include "ompi_config.h" + +#include "ompi/mpi/c/bindings.h" +#include "ompi/runtime/params.h" +#include "ompi/communicator/communicator.h" +#include "ompi/errhandler/errhandler.h" +#include "ompi/mca/pml/pml.h" +#include "ompi/request/request.h" +#include "ompi/memchecker.h" +#include "ompi/runtime/ompi_spc.h" + +int ompi_sendrecv(const void * sendbuf, size_t sendcount, MPI_Datatype sendtype, int dest, int sendtag, void * recvbuf, size_t recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status) +{ + ompi_request_t* req = MPI_REQUEST_NULL; + int rc = MPI_SUCCESS; + int rcs = MPI_SUCCESS; + + if (source != MPI_PROC_NULL) { /* post recv */ + rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype, + source, recvtag, comm, &req)); + OMPI_ERRHANDLER_CHECK(rc, comm, rc, "MPI_Sendrecv"); + } + + if (dest != MPI_PROC_NULL) { /* send */ + rc = MCA_PML_CALL(send(sendbuf, sendcount, sendtype, dest, + sendtag, MCA_PML_BASE_SEND_STANDARD, comm)); + if (OPAL_UNLIKELY(MPI_SUCCESS != rc)) { + rcs = rc; +#if OPAL_ENABLE_FT_MPI + /* If this is a PROC_FAILED error, we still need to proceed with + * the receive, so that we do not propagate errors to the sender in + * the case src != dst, and only dst is dead. In this case the + * recv is guaranteed to complete (either in error if the source is + * dead, or successfully if the source is live). */ + if (OPAL_UNLIKELY(MPI_ERR_PROC_FAILED != rc)) + /* if intentionally spills outside ifdef */ +#endif + ompi_request_cancel(req); + } + } + + if (source != MPI_PROC_NULL) { /* wait for recv */ + rc = ompi_request_wait(&req, status); +#if OPAL_ENABLE_FT_MPI + /* Sendrecv never returns ERR_PROC_FAILED_PENDING because it is + * blocking. Lets cancel that irecv to complete it NOW and promote + * the error to ERR_PROC_FAILED */ + if( OPAL_UNLIKELY(MPI_ERR_PROC_FAILED_PENDING == rc) ) { + ompi_request_cancel(req); + ompi_request_wait(&req, MPI_STATUS_IGNORE); + rc = MPI_ERR_PROC_FAILED; + } +#endif + } else { + if (MPI_STATUS_IGNORE != status) { + OMPI_COPY_STATUS(status, ompi_request_empty.req_status, false); + /* + * Per MPI-1, the MPI_ERROR field is not defined for single-completion calls + */ + MEMCHECKER( + opal_memchecker_base_mem_undefined(&status->MPI_ERROR, sizeof(int)); + ); + } + rc = MPI_SUCCESS; + } + if( OPAL_UNLIKELY(MPI_SUCCESS != rcs && MPI_SUCCESS == rc) ) { + rc = rcs; + } +} diff --git a/ompi/mpi/c/sendrecv.c.in b/ompi/mpi/c/sendrecv.c.in index d6a30102a50..25167d2d857 100644 --- a/ompi/mpi/c/sendrecv.c.in +++ b/ompi/mpi/c/sendrecv.c.in @@ -41,9 +41,7 @@ PROTOTYPE ERROR_CLASS sendrecv(BUFFER sendbuf, COUNT sendcount, DATATYPE sendtyp DATATYPE recvtype, INT source, INT recvtag, COMM comm, STATUS_OUT status) { - ompi_request_t* req = MPI_REQUEST_NULL; int rc = MPI_SUCCESS; - int rcs = MPI_SUCCESS; SPC_RECORD(OMPI_SPC_SENDRECV, 1); @@ -75,57 +73,9 @@ PROTOTYPE ERROR_CLASS sendrecv(BUFFER sendbuf, COUNT sendcount, DATATYPE sendtyp OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); } - if (source != MPI_PROC_NULL) { /* post recv */ - rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype, - source, recvtag, comm, &req)); - OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); - } - - if (dest != MPI_PROC_NULL) { /* send */ - rc = MCA_PML_CALL(send(sendbuf, sendcount, sendtype, dest, - sendtag, MCA_PML_BASE_SEND_STANDARD, comm)); - if (OPAL_UNLIKELY(MPI_SUCCESS != rc)) { - rcs = rc; -#if OPAL_ENABLE_FT_MPI - /* If this is a PROC_FAILED error, we still need to proceed with - * the receive, so that we do not propagate errors to the sender in - * the case src != dst, and only dst is dead. In this case the - * recv is guaranteed to complete (either in error if the source is - * dead, or successfully if the source is live). */ - if (OPAL_UNLIKELY(MPI_ERR_PROC_FAILED != rc)) - /* if intentionally spills outside ifdef */ -#endif - ompi_request_cancel(req); - } - } + rc = ompi_sendrecv(sendbuf, sendcount, sendtype, dest, sendtag, + recvbuf, recvcount, recvtype, source, recvtag, comm, status); - if (source != MPI_PROC_NULL) { /* wait for recv */ - rc = ompi_request_wait(&req, status); -#if OPAL_ENABLE_FT_MPI - /* Sendrecv never returns ERR_PROC_FAILED_PENDING because it is - * blocking. Lets cancel that irecv to complete it NOW and promote - * the error to ERR_PROC_FAILED */ - if( OPAL_UNLIKELY(MPI_ERR_PROC_FAILED_PENDING == rc) ) { - ompi_request_cancel(req); - ompi_request_wait(&req, MPI_STATUS_IGNORE); - rc = MPI_ERR_PROC_FAILED; - } -#endif - } else { - if (MPI_STATUS_IGNORE != status) { - OMPI_COPY_STATUS(status, ompi_request_empty.req_status, false); - /* - * Per MPI-1, the MPI_ERROR field is not defined for single-completion calls - */ - MEMCHECKER( - opal_memchecker_base_mem_undefined(&status->MPI_ERROR, sizeof(int)); - ); - } - rc = MPI_SUCCESS; - } - if( OPAL_UNLIKELY(MPI_SUCCESS != rcs && MPI_SUCCESS == rc) ) { - rc = rcs; - } OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME); } diff --git a/ompi/mpi/c/sendrecv_replace.c.in b/ompi/mpi/c/sendrecv_replace.c.in index 76aadb3ab30..7c8dba56a17 100644 --- a/ompi/mpi/c/sendrecv_replace.c.in +++ b/ompi/mpi/c/sendrecv_replace.c.in @@ -29,6 +29,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/datatype/ompi_datatype.h" #include "opal/datatype/opal_convertor.h" +#include "opal/mca/mpool/mpool.h" #include "ompi/mca/pml/pml.h" #include "ompi/proc/proc.h" #include "ompi/memchecker.h" @@ -80,7 +81,7 @@ PROTOTYPE ERROR_CLASS sendrecv_replace(BUFFER_OUT buf, COUNT count, DATATYPE dat /* simple case */ if ( source == MPI_PROC_NULL || dest == MPI_PROC_NULL || count == 0 ) { - rc = PMPI_Sendrecv(buf, count, datatype, dest, sendtag, buf, count, datatype, source, recvtag, comm, status); + rc = ompi_sendrecv(buf, count, datatype, dest, sendtag, buf, count, datatype, source, recvtag, comm, status); return rc; } @@ -113,8 +114,8 @@ PROTOTYPE ERROR_CLASS sendrecv_replace(BUFFER_OUT buf, COUNT count, DATATYPE dat /* setup a temporary buffer to send */ opal_convertor_get_packed_size( &convertor, &packed_size ); if( packed_size > sizeof(packed_data) ) { - rc = PMPI_Alloc_mem(packed_size, MPI_INFO_NULL, &iov.iov_base); - if(OMPI_SUCCESS != rc) { + iov.iov_base = (void *)mca_mpool_base_alloc (packed_size, NULL, NULL); + if(NULL == iov.iov_base) { rc = OMPI_ERR_OUT_OF_RESOURCE; goto cleanup_and_return; } @@ -166,7 +167,7 @@ PROTOTYPE ERROR_CLASS sendrecv_replace(BUFFER_OUT buf, COUNT count, DATATYPE dat /* release resources */ if(packed_size > sizeof(packed_data)) { - PMPI_Free_mem(iov.iov_base); + mca_mpool_base_free(iov.iov_base); } OBJ_DESTRUCT(&convertor); diff --git a/ompi/mpi/c/status_set_cancelled.c.in b/ompi/mpi/c/status_set_cancelled.c.in index 3c47560527c..960154e2d5a 100644 --- a/ompi/mpi/c/status_set_cancelled.c.in +++ b/ompi/mpi/c/status_set_cancelled.c.in @@ -28,7 +28,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS status_set_cancelled(STATUS_OUT status, INT flag) +PROTOTYPE ERROR_CLASS status_set_cancelled(STATUS_INOUT status, INT flag) { MEMCHECKER( if(status != MPI_STATUSES_IGNORE) { diff --git a/ompi/mpi/c/status_set_elements.c.in b/ompi/mpi/c/status_set_elements.c.in index 953a7aef7d0..da3c85053e1 100644 --- a/ompi/mpi/c/status_set_elements.c.in +++ b/ompi/mpi/c/status_set_elements.c.in @@ -32,7 +32,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS status_set_elements(STATUS_OUT status, DATATYPE datatype, COUNT count) +PROTOTYPE ERROR_CLASS status_set_elements(STATUS_INOUT status, DATATYPE datatype, COUNT count) { int rc = MPI_SUCCESS; size_t size; diff --git a/ompi/mpi/c/status_set_elements_x.c.in b/ompi/mpi/c/status_set_elements_x.c.in index c24b24f9c55..584035e8d53 100644 --- a/ompi/mpi/c/status_set_elements_x.c.in +++ b/ompi/mpi/c/status_set_elements_x.c.in @@ -32,7 +32,7 @@ #include "ompi/datatype/ompi_datatype.h" #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS status_set_elements_x(STATUS_OUT status, DATATYPE datatype, PARTITIONED_COUNT count) +PROTOTYPE ERROR_CLASS status_set_elements_x(STATUS_INOUT status, DATATYPE datatype, PARTITIONED_COUNT count) { int rc = MPI_SUCCESS; size_t size; diff --git a/ompi/mpi/c/status_set_error.c.in b/ompi/mpi/c/status_set_error.c.in index 30a667cd5a5..31eccfee732 100644 --- a/ompi/mpi/c/status_set_error.c.in +++ b/ompi/mpi/c/status_set_error.c.in @@ -17,7 +17,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS status_set_error(STATUS_OUT status, INT error) +PROTOTYPE ERROR_CLASS status_set_error(STATUS_INOUT status, INT error) { MEMCHECKER( if(status != MPI_STATUSES_IGNORE) { diff --git a/ompi/mpi/c/status_set_source.c.in b/ompi/mpi/c/status_set_source.c.in index 46e1959bb85..b723a6bb3e6 100644 --- a/ompi/mpi/c/status_set_source.c.in +++ b/ompi/mpi/c/status_set_source.c.in @@ -17,7 +17,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS status_set_source(STATUS_OUT status, INT source) +PROTOTYPE ERROR_CLASS status_set_source(STATUS_INOUT status, INT source) { MEMCHECKER( if(status != MPI_STATUSES_IGNORE) { diff --git a/ompi/mpi/c/status_set_tag.c.in b/ompi/mpi/c/status_set_tag.c.in index 2a85c3cb62f..beca885583b 100644 --- a/ompi/mpi/c/status_set_tag.c.in +++ b/ompi/mpi/c/status_set_tag.c.in @@ -18,7 +18,7 @@ #include "ompi/errhandler/errhandler.h" #include "ompi/memchecker.h" -PROTOTYPE ERROR_CLASS status_set_tag(STATUS_OUT status, INT tag) +PROTOTYPE ERROR_CLASS status_set_tag(STATUS_INOUT status, INT tag) { MEMCHECKER( if(status != MPI_STATUSES_IGNORE) { From da515d492134b51c7489f5d045371edbdf056423 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Wed, 4 Jun 2025 15:03:47 -0600 Subject: [PATCH 6/6] temporary commit Signed-off-by: Howard Pritchard --- ompi/mpi/bindings/ompi_bindings/c_type.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ompi/mpi/bindings/ompi_bindings/c_type.py b/ompi/mpi/bindings/ompi_bindings/c_type.py index 1c403c2f571..825e275417d 100644 --- a/ompi/mpi/bindings/ompi_bindings/c_type.py +++ b/ompi/mpi/bindings/ompi_bindings/c_type.py @@ -1152,7 +1152,8 @@ class TypeCommCopyAttrFunctionStandard(Type): # pass def type_text(self, enable_count=False): - return 'MPI_Comm_copy_attr_function *' + type_name = self.mangle_name('MPI_Comm_copy_attr_function') + return f'{type_name} *' @Type.add_type('COMM_DELETE_ATTR_FUNCTION', abi_type=['ompi']) class TypeCommDeleteAttrFunction(Type): @@ -1167,7 +1168,8 @@ class TypeCommDeleteAttrFunctionStandard(Type): # pass def type_text(self, enable_count=False): - return 'MPI_Comm_delete_attr_function *' + type_name = self.mangle_name('MPI_Comm_delete_attr_function') + return f'{type_name} *' @Type.add_type('GREQUEST_QUERY_FUNCTION', abi_type=['ompi']) class TypeGrequestQueryFunction(Type):