Skip to content

Commit 05a5924

Browse files
jtrongehppritcha
authored andcommitted
Bigcount: Update docs and address other comments
Signed-off-by: Jake Tronge <[email protected]>
1 parent ff4352c commit 05a5924

File tree

4 files changed

+44
-59
lines changed

4 files changed

+44
-59
lines changed

config/ompi_setup_mpi_fortran.m4

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,6 @@ end type test_mpi_handle],
653653
AS_IF([test $OMPI_MIN_REQUIRED_FORTRAN_BINDINGS -gt $OMPI_BUILD_FORTRAN_BINDINGS],
654654
[AC_MSG_ERROR([Cannot build requested Fortran bindings, aborting])])
655655

656-
dnl AC_CONFIG_FILES([ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h])
657-
658656
# -------------------
659657
# mpif.h final setup
660658
# -------------------

docs/developers/bindings.rst

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ C and Fortran Bindings
22
======================
33

44
The C and Fortran (mpi_f08) bindings are generated from Python code in
5-
``ompi/mpi/bindings``. The C code is generated based on a template file for
6-
each function, with a header and a body containing error-checking and
7-
conversion code; the mpi_f08 Fortran bindings are generated from a single
8-
file ``ompi/mpi/fortran/use-mpi-f08/interface.in``.
5+
``ompi/mpi/bindings``. Both the language bindings are generated from
6+
template files for each function. In the C case, each template file corresponds
7+
to a single generated C file, while in the Fortran case there are three major
8+
files generated for all functions.
99

1010
The Python code depends on special prototype lines used with both the C and
1111
Fortran bindings. These "prototypes" are designed to be easy to parse and use
@@ -69,66 +69,32 @@ generated file name must be of the form ``generated_${basename}.c``, where
6969
Fortran Bindings
7070
----------------
7171

72-
To add a new Fortran binding, or update an existing one, one will need to
73-
modify the ``ompi/mpi/fortran/use-mpi-f08/interface.json`` file; this JSON file
74-
contains a list of prototype objects, including information about their name
75-
and each parameter passed. Below is an example for ``MPI_Waitall``:
72+
Adding new Fortran bindings follows a similar process to the C version above.
73+
All new interfaces are actually based on a single C-template file following the
74+
same format as the C interface templates. However, the C file generated will
75+
use Fortran-specific arguments, including ``CFI_*`` arguments, when TS 29113 is
76+
enabled, ``MPI_Fint *`` arguments in other cases, and others specific to how
77+
the Fortran MPI types are defined. Most of these files perform Fortran-specific
78+
error handling, Fortran-to-C type conversion, and other necessary steps before
79+
calling the actually C bindings with the proper arguments.
7680

77-
.. code-block::
78-
79-
{
80-
"name": "waitall",
81-
"parameters": [
82-
{
83-
"type": "SHORTCUT_COUNT",
84-
"name": "count"
85-
},
86-
{
87-
"type": "REQUEST_ARRAY",
88-
"name": "array_of_requests",
89-
"dep_params": {
90-
"count": "count"
91-
}
92-
},
93-
{
94-
"type": "STATUS_ARRAY",
95-
"name": "array_of_statuses",
96-
"dep_params": {
97-
"count": "count"
98-
}
99-
}
100-
]
101-
}
102-
103-
This object includes two properties: the ``name`` property holding the
104-
subroutine name, converted to lowercase and the ``mpi_`` prefix removed; and
105-
the ``parameters`` property describing all parameters, their types and
106-
dependencies. Some parameters may depend on other types and this is listed in
107-
the ``dep_params`` field. An example of this can be seen with
108-
``array_of_requests`` above, in which ``dep_params`` holds a key-value pair
109-
``"count": "count"``, where the key ``count`` corresponds to a key required by
110-
the ``REQUEST_ARRAY`` type and the value ``count`` to the name of another
111-
parameter. These parameter dependencies are specific to the types used and are
112-
validated by the binding scripts.
113-
114-
The Fortran binding code not only generates Fortran, but also additional
115-
wrapping C code that calls into the C bindings, making conversions and checking
116-
for Fortran-specific error conditions as necessary. The following files will be
117-
generated by the script:
81+
These templates are used not only to generate a C backing file for the Fortran
82+
code, but also the Fortran interface definitions and the Fortran subroutines
83+
corresponding to the generated C file. These are output in three separate files:
11884

11985
* ``ompi/mpi/fortran/use-mpi-f08/api_f08_generated.F90``
12086
* ``ompi/mpi/fortran/use-mpi-f08/base/api_f08_generated.c``
121-
* ``ompi/mpi/fortran/use-mpi-f08/base/api_f08_ts_generated.c``
12287
* ``ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces-generated.h``
12388

12489
The Fortran file ``api_f08_generated.F90`` contains all the internal subroutine
125-
definitions, each of which makes a call into corresponding C functions. Two
126-
different C files are generated: ``api_f08_ts_generated.c`` contains support
127-
for compilers with TS 29113 support, allowing the use of ``CFI_cdesc_t`` types
128-
(see `Fortran 2018`_ for more details); and ``api_f08_generated.c`` for
129-
compilers without TS 29113 support. The internal subroutine names are mapped to
130-
the external interface, including multiple interfaces for the bigcount version
131-
of functions, in ``mpi-f08-interfaces-generated.h``.
90+
definitions, each of which makes a call into corresponding C functions. The
91+
internal subroutine names are mapped to the external interface, including
92+
multiple interfaces for the bigcount version of functions, in
93+
``mpi-f08-interfaces-generated.h``. The C file ``api_f08_generated.c``
94+
basically contains a concatenation of all fully expanded C templates.
95+
These files contain preprocessing directives to ensure they can support
96+
compilers with and without TS 29113 support, allowing use of
97+
``CFI_cdesc_t`` types when available (see `Fortran 2018`_ for more details).
13298

13399
.. _Fortran 2018: https://fortranwiki.org/fortran/show/Fortran+2018
134100

docs/developers/prerequisites.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ build them manually, see the :ref:`how to build and install GNU
4747
Autotools section <developers-installing-autotools-label>` for much
4848
more detail.
4949

50+
Python
51+
------
52+
53+
Python >= v3.6 is required for generating the Fortran bindings, which
54+
is necessary if you build Open MPI from a Git clone.
55+
56+
Python is also required for running Sphinx to generate the docs, too
57+
(:ref:`see below <developers-requirements-sphinx-label>`).
58+
5059
Perl
5160
----
5261

@@ -88,6 +97,8 @@ MacPorts on MacOS), see `the Flex Github repository
8897
<https://github.com/westes/flex>`_.
8998

9099

100+
.. _developers-requirements-sphinx-label:
101+
91102
Sphinx (and therefore Python)
92103
-----------------------------
93104

ompi/mpi/fortran/use-mpi-f08/base/bigcount.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Triad National Security, LLC. All rights
3+
* reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
111
/*
212
* Bigcount array conversion macros for Fortran templates.
313
*/

0 commit comments

Comments
 (0)