Skip to content

Commit 91f4346

Browse files
committed
docs: Minor updates to MPIX man pages
Add some formulaic text to the MPIX man pages: * Indicated that these functions are only present if the corresponding extenion was built * Described the available preprocessor macros * Added a link to the Open MPI Extensions section * Fixed string errors in the example code * Used proper #if conditionals in the example * Added a See Also section Signed-off-by: Jeff Squyres <[email protected]>
1 parent 0a180c1 commit 91f4346

File tree

3 files changed

+80
-28
lines changed

3 files changed

+80
-28
lines changed

docs/features/extensions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _ompi-features-extentions-label:
2+
13
Open MPI extensions
24
===================
35

docs/man-openmpi/man3/MPIX_Query_cuda_support.3.rst

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MPIX_Query_cuda_support
66

77
.. include_body
88
9-
**MPIX_Query_cuda_support** - Returns 1 if there is CUDA aware support
9+
**MPIX_Query_cuda_support** - Returns 1 if there is CUDA-aware support
1010
and 0 if there is not.
1111

1212

@@ -40,33 +40,58 @@ There is no C++ binding for this function.
4040
DESCRIPTION
4141
-----------
4242

43-
This routine return 1 if MPI library is build with CUDA and runtime
44-
supports CUDA buffers. This routine must be called after MPI is
45-
initialized by a call to :ref:`MPI_Init` or :ref:`MPI_Init_thread`.
43+
This function is part of an :ref:`Open MPI extension
44+
<ompi-features-extentions-label>`; it is not part of standard MPI.
45+
46+
This routine returns 1 if both the MPI library was built with the
47+
NVIDIA CUDA library and the runtime supports CUDA buffers. Otherwise,
48+
it returns 0. This routine must be called after MPI is initialized,
49+
e.g., by a call to :ref:`MPI_Init(3) <MPI_Init>` or
50+
:ref:`MPI_Init_thread(3) <MPI_Init_thread>`.
51+
52+
Including the Open MPI-specific file ``<mpi-ext.h>`` will define the C
53+
preprocessor macro ``OMPI_HAVE_MPI_EXT`` to ``1``. Otherwise, it will
54+
be undefined. This macro can be used by applications as a sentinel to
55+
know whether ``<mpi-ext.h>`` has been included or not.
56+
57+
The Open MPI CUDA extension is built by default (regardless of whether
58+
or not Open MPI was built with CUDA support), but *could* have been
59+
disabled by an administrative action. It is therefore safest for
60+
applications to check that the preprocessor macro
61+
``OMPI_HAVE_MPI_EXT_CUDA`` is defined and is set to 1 to know whether
62+
the ``MPIX_Query_CUDA_support()`` function is available. Checking for
63+
this macro also protects the use of this function when compiling the
64+
application with older versions of Open MPI or other MPI
65+
implementations that do not have this function.
4666

4767

4868
Examples
4969
^^^^^^^^
5070

51-
::
52-
71+
.. code-block:: c
5372
5473
#include <stdio.h>
55-
#include "mpi.h"
56-
57-
#include "mpi-ext.h" /* Needed for CUDA-aware check */
74+
#include <mpi.h>
75+
#include <mpi-ext.h> /* Needed for CUDA-aware check */
5876
5977
int main(int argc, char *argv[])
6078
{
61-
6279
MPI_Init(&argc, &argv);
6380
64-
if (MPIX_Query_cuda_support()) {
65-
printf("This MPI library has CUDA-aware support.);
81+
bool happy = false;
82+
#if defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA
83+
happy = (bool) MPIX_Query_cuda_support();
84+
#endif
85+
86+
if (happy) {
87+
printf("This Open MPI installation has CUDA-aware support.\n");
6688
} else {
67-
printf("This MPI library does not have CUDA-aware support.);
89+
printf("This Open MPI installation does not have CUDA-aware support.\n");
6890
}
69-
MPI_Finalize();
7091
92+
MPI_Finalize();
7193
return 0;
7294
}
95+
96+
.. seealso::
97+
:ref:`MPIX_Query_rocm_support`

docs/man-openmpi/man3/MPIX_Query_rocm_support.3.rst

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MPIX_Query_rocm_support
66

77
.. include_body
88
9-
**MPIX_Query_rocm_support** - Returns 1 if there is AMD ROCm aware support
9+
**MPIX_Query_rocm_support** - Returns 1 if there is AMD ROCm-aware support
1010
and 0 if there is not.
1111

1212

@@ -40,33 +40,58 @@ There is no C++ binding for this function.
4040
DESCRIPTION
4141
-----------
4242

43-
This routine return 1 if MPI library is build with ROCm and runtime
44-
supports ROCm buffers. This routine must be called after MPI is
45-
initialized by a call to :ref:`MPI_Init` or :ref:`MPI_Init_thread`.
43+
This function is part of an :ref:`Open MPI extension
44+
<ompi-features-extentions-label>`; it is not part of standard MPI.
45+
46+
This routine returns 1 if both the MPI library was built with the AMD
47+
ROCm library and the runtime supports ROCm buffers. Otherwise, it
48+
returns 0. This routine must be called after MPI is initialized,
49+
e.g., by a call to :ref:`MPI_Init(3) <MPI_Init>` or
50+
:ref:`MPI_Init_thread(3) <MPI_Init_thread>`.
51+
52+
Including the Open MPI-specific file ``<mpi-ext.h>`` will define the C
53+
preprocessor macro ``OMPI_HAVE_MPI_EXT`` to ``1``. Otherwise, it will
54+
be undefined. This macro can be used by applications as a sentinel to
55+
know whether ``<mpi-ext.h>`` has been included or not.
56+
57+
The Open MPI ROCm extension is built by default (regardless of whether
58+
or not Open MPI was built with ROCm support), but *could* have been
59+
disabled by an administrative action. It is therefore safest for
60+
applications to check that the preprocessor macro
61+
``OMPI_HAVE_MPI_EXT_ROCM`` is defined and is set to 1 to know whether
62+
the ``MPIX_Query_rocm_support()`` function is available. Checking for
63+
this macro also protects the use of this function when compiling the
64+
application with older versions of Open MPI or other MPI
65+
implementations that do not have this function.
4666

4767

4868
Examples
4969
^^^^^^^^
5070

51-
::
52-
71+
.. code-block:: c
5372
5473
#include <stdio.h>
55-
#include "mpi.h"
56-
57-
#include "mpi-ext.h" /* Needed for ROCm-aware check */
74+
#include <mpi.h>
75+
#include <mpi-ext.h> /* Needed for ROCm-aware check */
5876
5977
int main(int argc, char *argv[])
6078
{
61-
6279
MPI_Init(&argc, &argv);
6380
64-
if (MPIX_Query_rocm_support()) {
65-
printf("This MPI library has ROCm-aware support.);
81+
bool happy = false;
82+
#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
83+
happy = (bool) MPIX_Query_rocm_support();
84+
#endif
85+
86+
if (happy) {
87+
printf("This Open MPI installation has ROCm-aware support.\n");
6688
} else {
67-
printf("This MPI library does not have ROCm-aware support.);
89+
printf("This Open MPI installation does not have ROCm-aware support.\n");
6890
}
69-
MPI_Finalize();
7091
92+
MPI_Finalize();
7193
return 0;
7294
}
95+
96+
.. seealso::
97+
:ref:`MPIX_Query_cuda_support`

0 commit comments

Comments
 (0)