5.2.1.1. Affinity extension
5.2.1.1.1. Overview
The affinity extension provides a single Open MPI-specific
function, OMPI_Affinity_str(3). Given a
format selector, it fills in three human-readable strings describing:
where Open MPI bound the calling process at launch time (or that it was not bound);
where the process is currently bound (or that it is unbound); and
which processors exist on the local host.
The strings can be requested either as resource descriptions (for
example, socket 0, core 0) or as an ASCII-art layout of the
machine (for example, [. B][. .]). This is an Open
MPI-specific convenience API for applications that want to introspect
their own binding; it is not part of the MPI standard.
5.2.1.1.2. When it is built
The affinity extension has no build-time prerequisites, so it is
built by default on every platform. Like all extensions, it can be
excluded by configuring with --disable-mpi-ext, or by naming an
explicit list that omits it (for example,
--enable-mpi-ext=cuda,rocm). See the extensions overview for the full set of
--enable-mpi-ext / --disable-mpi-ext options.
5.2.1.1.3. Availability at run time
Because the extension has no external dependencies, it is available at
run time whenever it was compiled in. Applications should still guard
their use of it with the preprocessor macro
OMPI_HAVE_MPI_EXT_AFFINITY, which <mpi-ext.h> defines to 1
when the extension is present. This keeps application code portable
across Open MPI builds that omitted the extension and across other MPI
implementations.