From 96e458a0733c14ca80156db7ed0e39aa37fe2da1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Wed, 7 Dec 2022 15:42:17 -0800 Subject: [PATCH] Override MPI_Aint_add and MPI_Aint_diff for OpenMPI --- src/common/override.c | 19 +++++++++++++++++++ src/interface/header/_OMPI/app_mpi.h | 4 ++++ src/interface/interface_utils/include/mpi.h | 3 +++ src/preload/header/INTEL_OMPI/app_mpi.h | 3 +++ src/preload/header/MPICH_OMPI/app_mpi.h | 3 +++ 5 files changed, 32 insertions(+) diff --git a/src/common/override.c b/src/common/override.c index c12c59b..2a0d912 100644 --- a/src/common/override.c +++ b/src/common/override.c @@ -336,3 +336,22 @@ int A_MPI_Testsome(int incount, A_MPI_Request array_of_requests[], return error_code_conv_r2a(ret_tmp); } #endif + +#ifdef MPI_AINT_ADD_OVERRIDE +A_MPI_Aint A_MPI_Aint_add(A_MPI_Aint lhs, A_MPI_Aint rhs) { + // The MPI 3.1 addition MPI_Aint_add is defined in MPICH as a symbol by the + // library, but is compiled as a macro by OpenMPI. This leads to an unresolved + // symbol crash when running MPICH-compiled binaries with OpenMPI. + // + // This function is meant to override the default ASM symbol chooser and + // reimplement the OpenMPI macro when running with OpenMPI as the R_MPI. + + return lhs + rhs; +} +#endif + +#ifdef MPI_AINT_DIFF_OVERRIDE +A_MPI_Aint A_MPI_Aint_diff(A_MPI_Aint lhs, A_MPI_Aint rhs) { // Same as above + return lhs - rhs; +} +#endif diff --git a/src/interface/header/_OMPI/app_mpi.h b/src/interface/header/_OMPI/app_mpi.h index 973e812..fb07496 100644 --- a/src/interface/header/_OMPI/app_mpi.h +++ b/src/interface/header/_OMPI/app_mpi.h @@ -5,6 +5,10 @@ #define A_MPI_ MPI_ #define A_PMPI_ PMPI_ #endif + +#define MPI_AINT_ADD_OVERRIDE +#define MPI_AINT_DIFF_OVERRIDE + typedef unsigned long size_t; typedef size_t A_MPI_Aint; typedef size_t A_MPI_Offset; diff --git a/src/interface/interface_utils/include/mpi.h b/src/interface/interface_utils/include/mpi.h index 036258b..f196558 100644 --- a/src/interface/interface_utils/include/mpi.h +++ b/src/interface/interface_utils/include/mpi.h @@ -1258,6 +1258,9 @@ enum { double MPI_Wtick(void); double MPI_Wtime(void); + MPI_Aint MPI_Aint_add(MPI_Aint, MPI_Aint); + MPI_Aint MPI_Aint_diff(MPI_Aint, MPI_Aint); + /* * Profiling MPI API */ diff --git a/src/preload/header/INTEL_OMPI/app_mpi.h b/src/preload/header/INTEL_OMPI/app_mpi.h index 9a33cc1..7a64d98 100644 --- a/src/preload/header/INTEL_OMPI/app_mpi.h +++ b/src/preload/header/INTEL_OMPI/app_mpi.h @@ -56,6 +56,9 @@ #ifndef A_MPI_INCLUDED #define A_MPI_INCLUDED +#define MPI_AINT_ADD_OVERRIDE +#define MPI_AINT_DIFF_OVERRIDE + /* user include file for MPI programs */ #if !defined(_WIN32) && !defined(_WIN64) /* Linux only */ # include /* for __WORDSIZE definition */ diff --git a/src/preload/header/MPICH_OMPI/app_mpi.h b/src/preload/header/MPICH_OMPI/app_mpi.h index 9a33cc1..7a64d98 100644 --- a/src/preload/header/MPICH_OMPI/app_mpi.h +++ b/src/preload/header/MPICH_OMPI/app_mpi.h @@ -56,6 +56,9 @@ #ifndef A_MPI_INCLUDED #define A_MPI_INCLUDED +#define MPI_AINT_ADD_OVERRIDE +#define MPI_AINT_DIFF_OVERRIDE + /* user include file for MPI programs */ #if !defined(_WIN32) && !defined(_WIN64) /* Linux only */ # include /* for __WORDSIZE definition */