Skip to content

Commit

Permalink
Override MPI_Aint_add and MPI_Aint_diff for OpenMPI
Browse files Browse the repository at this point in the history
  • Loading branch information
spoutn1k committed Dec 8, 2022
1 parent 01e64ea commit 96e458a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/common/override.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/interface/header/_OMPI/app_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/interface/interface_utils/include/mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions src/preload/header/INTEL_OMPI/app_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h> /* for __WORDSIZE definition */
Expand Down
3 changes: 3 additions & 0 deletions src/preload/header/MPICH_OMPI/app_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h> /* for __WORDSIZE definition */
Expand Down

0 comments on commit 96e458a

Please sign in to comment.