Skip to content

Commit 43a3314

Browse files
committed
add a readme about the MPI ABI support
Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 6f61c18 commit 43a3314

File tree

1 file changed

+182
-0
lines changed

1 file changed

+182
-0
lines changed

ompi/mpi/README_ABI.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# MPI-5 ABI support
2+
3+
Last updated: November 2025
4+
5+
This README describes the current approach to supporting the MPI-5
6+
Application Binary Interface (ABI). The MPI ABI is described in
7+
Chapter 21 of the MPI-5 standard. The standardizes values for
8+
constants, etc. are presented in Appendix A of that document.
9+
10+
At this time, Open MPI is only supporting the 'c' ABI functionality
11+
although the Fortran related query methods presented in Chapter 21
12+
are supported.
13+
14+
## What does having a defined ABI mean to applications?
15+
16+
By supporting a standardized ABI, an MPI application can be built
17+
against one implementation of MPI (e.g.) MPICH, but at runtime
18+
can use the ABI compatible Open MPI implementation of the library.
19+
This only applies to dynamically linked applications.
20+
21+
In principle a single mpi.h include file can be used, for example
22+
the one provided at https://github.com/mpi-forum/mpi-abi-stubs.
23+
24+
Chapter 21 specifies the shared library name (soname) of the ABI MPI
25+
library and its file name (libmpi\_abi). The major and minor versions
26+
of the library are specified in this chapter as well. The name of
27+
the compiler wrapper - mpicc\_abi - is also specified.
28+
29+
## Refactor of Open MPI to support the MPI ABI
30+
31+
Relatively few changes were made to the internal components of Open MPI
32+
to support the ABI, but the way in which it is structured in terms of
33+
internal libraries has been changed.
34+
35+
There are now two top level libraries, one to support the OMPI ABI,
36+
and the other the MPI ABI. The internal components of Open MPI are now
37+
placed in separate library, against which both of the ABI specific
38+
libraries are linked. The structure is depicted below:
39+
40+
MPI ABI OMPI ABI
41+
+----------------------+----------------------+
42+
| libmpi\_abi.la | libmpi.la |
43+
+----------------------+----------------------+
44+
| libopen\_mpi.la |
45+
+----------------------+----------------------+
46+
47+
Note the ability to change the name of the OMPI ABI library (libmpi.la)
48+
is still supported, so in the code base Makefiles this library actually
49+
appears as lib@OMPI\_LIBMPI\_NAME@.la).
50+
51+
Since the Fortran ABI is not currently supported, the Fortran libraries
52+
are only linked against libmpi.so.0.
53+
54+
## Installation considerations
55+
56+
The MPI and OMPI libraries are installed in the same <install-path>/lib
57+
folder. They have different file names so this presents no problems.
58+
The OMPI ABI include files are installed in <install-path>/include as usual.
59+
The MPI ABI include file is installed in <install-path>/include/standard\_abi.
60+
The mpicc\_abi compiler wrapper points the c compiler to the correct mpi.h and
61+
links the the executable/shared library against libmpi\_abi.
62+
63+
## Generating the ABI compliant mpi.h
64+
65+
Rather than use the mpi.h at https://github.com/mpi-forum/mpi-abi-stubs,
66+
it was decided to develop infrastructure for building it from the latex
67+
content of the MPI standard. It turns out that this was the better route
68+
as bugs were found both in the standard itself and the mpi-abi-stubs
69+
mpi.h while developing this infrastructure.
70+
71+
Generation of the mpi.h (and a shadow abi.h) include files involves four
72+
components:
73+
74+
1. pympistandard at https://github.com/mpi-forum/pympistandard. This
75+
is now included in the 3rd-party folder.
76+
77+
2. two json files: mpi-standard-apis.json and mpi-standard-abi.json.
78+
The former is generated as part of the build process for the MPI standard.
79+
The later is generated via a tool (not yet incorporated in the upstream
80+
mpi-standard code base). The tool converts the values embedded in the
81+
appendix A latex file into a json file specifying the values for MPI
82+
constants, e.g. value of MPI\_COMM\_WORLD. These json files reside in
83+
the top level docs folder. Note the first json file is also used to
84+
generate makefile content.
85+
86+
3. A tool - c\_header.py was written to parse the two json files
87+
described above and generate the MPI ABI compliant mpi.h and a name mangled
88+
version - abi.h. Eventually this tool will be incorporated into the
89+
binding infrastructure. More on the binding infrastructure below.
90+
The tool uses methods from pympistandard.
91+
92+
4. The c\_header.py tool uses a template file - abi.h.in located in
93+
the ompi/mpi/c folder to generate the MPI ABI mpi.h and the name
94+
mangled version - abi.h. The tool uses methods from pympistandard.
95+
96+
## Generating the MPI ABI compliant c bindings
97+
98+
The ABI compliant c bindings are generated using the binding infrastructure
99+
originally developed to support big count. The infrastructure was significantly
100+
enhanced to support generation of the MPI ABI bindings.
101+
102+
This infrastructure uses templates (*.c.in) files to generate up to four
103+
variants: OMPI ABI int count, OMPI ABI big count, MPI ABI int count,
104+
MPI ABI big count. There are a small set of functions which have
105+
only int count or big count. The templates for these files have
106+
suffixes of (*.c.in\_obc for big count only and *.c.in\_nbc for int
107+
count only).
108+
109+
Note a number of procedures (e.g. all the _f2c/_c2f) are not present in
110+
the MPI ABI. Likewise there are restrictions as to which deprecated
111+
procedures are include in the MPI ABI. These restrictions are managed
112+
via the ompi/mpi/c/Makefile.am and ompi/mpi/c/Makefile_abi.include make
113+
files.
114+
115+
Generation of the OMPI ABI sources files only involves the code changes
116+
that were done to support big count.
117+
118+
The MPI ABI source file generation is more complex. The source files
119+
generated include both the OMPI ABI mpi.h and the name
120+
mangled MPI ABI abi.h include files. Thus the generated source files
121+
have two definitions of MPI predefined constants. As an example
122+
in a MPI ABI source file there are two world communicator values defined:
123+
MPI\_COMM\_WORLD, and MPI\_COMM\_WORLD\_ABI\_INTERNAL. The former
124+
is the OMPI ABI defintion of the world communicator(address of a
125+
global variable) , the later the MPI ABI value for this constant (an integer).
126+
127+
The bindings framework parses the input argument types to the function
128+
and generates calls to appropriate converter methods to convert any MPI ABI
129+
constants in the arguments to OMPI ABI ones. A wrapped version
130+
of the original function code is then called. Any output arguments
131+
are converted from the OMPI ABI values back to MPI ABI ones.
132+
This includes fields in MPI_Status objects which require conversion
133+
(in particular error values) and error return values from the wrapped code.
134+
135+
The bindings framework also generates two helper files - abi\_converter.h
136+
and abi\_converter.c in addition to the generatedd OMPI and MPI ABI
137+
source files.
138+
139+
There are several implications of this approach.
140+
141+
First very few changes have to made to the internal Open MPI source code.
142+
143+
A second is that top level MPI ABI c entry points are expecting
144+
argument values using MPI ABI constants. Thus calling top
145+
level MPI functions from within libompi\_mpi will not work
146+
properly.
147+
148+
A third is there are a few places in non-blocking/persistent
149+
methods where arrays of converted values need to be allocated,
150+
and freed upon completion of the non-blocking collective or release
151+
of the persistent request.
152+
153+
## Handling user defined functions
154+
155+
The standard specifies a number of user defined functions
156+
157+
1. attribute copy and delete functions
158+
2. operator functions (for reduction operations)
159+
3. errhandler functions
160+
4. generalized request related functions
161+
5. datarep functions
162+
6. MPI_T event callback functions.
163+
164+
The MPI ABI support for these functions varies. For attribute related
165+
functions, a wrapper generation approach is taken. The wrapper converts
166+
OMPI ABI constants to MPI ABI ones as needed. No changes are needed
167+
to OMPI internal functions to support these.
168+
169+
Operator functions are handled by extending the internal support for
170+
ops functions to allow for invocation of a translation routine to
171+
convert the datatype argument from the OMPI ABI to MPI ABI values
172+
as appropriate. A similar approach is taken for errhandlers.
173+
174+
Generalized requests don't need speial support as the MPI Status
175+
structure for both MPI and OMPI ABIs are similar enough as to not
176+
require conversion.
177+
178+
OMPI doesn't really support datarep functions so currently there
179+
is no need for any argument conversion operations.
180+
181+
The MPI_T event implementation is just a set of stubs so there's
182+
no need for special support for MPI_T_event callback functions.

0 commit comments

Comments
 (0)