Skip to content

Commit 56aa633

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 56aa633

File tree

3 files changed

+74
-28
lines changed

3 files changed

+74
-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: 36 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,55 @@ 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. If
45+
Open MPI was built with the CUDA extenion, this function is declared
46+
in ``mpi-ext.h``.
47+
48+
Including the file ``<mpi-ext.h>`` will define the C preprocessor
49+
macro ``OMPI_HAVE_MPI_EXT`` to ``1``. Otherwise, it will be
50+
undefined. This macro can be used by applications as a sentinel to
51+
know whether ``<mpi-ext.h>`` has been included or not.
52+
53+
If the Open MPI CUDA extension is available (and therefore the
54+
``MPIX_Query_cuda_support()`` function is available), the C
55+
preprocessor macro ``OMPI_HAVE_MPI_EXT_CUDA`` will be defined to
56+
``1`` in ``<mpi-ext.h>``. Otherwise, it will be undefined.
57+
58+
This routine return 1 if both the MPI library was built with NVIDIA
59+
CUDA library and the runtime supports CUDA buffers. Otherwise, it
60+
returns 0. This routine must be called after MPI is initialized,
61+
e.g., by a call to :ref:`MPI_Init(3) <MPI_Init>` or
62+
:ref:`MPI_Init_thread(3) <MPI_Init_thread>`.
4663

4764

4865
Examples
4966
^^^^^^^^
5067

51-
::
52-
68+
.. code-block:: c
5369
5470
#include <stdio.h>
55-
#include "mpi.h"
56-
57-
#include "mpi-ext.h" /* Needed for CUDA-aware check */
71+
#include <mpi.h>
72+
#include <mpi-ext.h> /* Needed for CUDA-aware check */
5873
5974
int main(int argc, char *argv[])
6075
{
61-
6276
MPI_Init(&argc, &argv);
6377
64-
if (MPIX_Query_cuda_support()) {
65-
printf("This MPI library has CUDA-aware support.);
78+
bool happy = false;
79+
#if defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA
80+
happy = (bool) MPIX_Query_cuda_support();
81+
#endif
82+
83+
if (happy) {
84+
printf("This Open MPI installation has CUDA-aware support.\n");
6685
} else {
67-
printf("This MPI library does not have CUDA-aware support.);
86+
printf("This Open MPI installation does not have CUDA-aware support.\n");
6887
}
69-
MPI_Finalize();
7088
89+
MPI_Finalize();
7190
return 0;
7291
}
92+
93+
.. seealso::
94+
:ref:`MPIX_Query_rocm_support`

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

Lines changed: 36 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,55 @@ 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. If
45+
Open MPI was built with the ROCm extenion, this function is declared
46+
in ``<mpi-ext.h>``.
47+
48+
Including the file ``<mpi-ext.h>`` will define the C preprocessor
49+
macro ``OMPI_HAVE_MPI_EXT`` to ``1``. Otherwise, it will be
50+
undefined. This macro can be used by applications as a sentinel to
51+
know whether ``<mpi-ext.h>`` has been included or not.
52+
53+
If the Open MPI CUDA extension is available (and therefore the
54+
``MPIX_Query_rocm_support()`` function is available), the C
55+
preprocessor macro ``OMPI_HAVE_MPI_EXT_ROCM`` will be defined to
56+
``1`` in ``<mpi-ext.h>``. Otherwise, it will be undefined.
57+
58+
This routine return 1 if both the MPI library was built with the AMD
59+
ROCm library and the runtime supports ROCm buffers. Otherwise, it
60+
returns 0. This routine must be called after MPI is initialized,
61+
e.g., by a call to :ref:`MPI_Init(3) <MPI_Init>` or
62+
:ref:`MPI_Init_thread(3) <MPI_Init_thread>`.
4663

4764

4865
Examples
4966
^^^^^^^^
5067

51-
::
52-
68+
.. code-block:: c
5369
5470
#include <stdio.h>
55-
#include "mpi.h"
56-
57-
#include "mpi-ext.h" /* Needed for ROCm-aware check */
71+
#include <mpi.h>
72+
#include <mpi-ext.h> /* Needed for ROCm-aware check */
5873
5974
int main(int argc, char *argv[])
6075
{
61-
6276
MPI_Init(&argc, &argv);
6377
64-
if (MPIX_Query_rocm_support()) {
65-
printf("This MPI library has ROCm-aware support.);
78+
bool happy = false;
79+
#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
80+
happy = (bool) MPIX_Query_rocm_support();
81+
#endif
82+
83+
if (happy) {
84+
printf("This Open MPI installation has ROCm-aware support.\n");
6685
} else {
67-
printf("This MPI library does not have ROCm-aware support.);
86+
printf("This Open MPI installation does not have ROCm-aware support.\n");
6887
}
69-
MPI_Finalize();
7088
89+
MPI_Finalize();
7190
return 0;
7291
}
92+
93+
.. seealso::
94+
:ref:`MPIX_Query_cuda_support`

0 commit comments

Comments
 (0)