MPIX_QUERY_CUDA_SUPPORT(3)

πŸ’… MPIX_QUERY_CUDA_SUPPORT(3) πŸ’…

okay so bestie, this page lives in the Open MPI manual, and it's about one tiny little function that tells you whether your CUDA vibes are immaculate or not. Let's get into it 🫢


✨ NAME ✨

MPIX_Query_cuda_support β€” returns 1 if there is CUDA-aware support and 0 if there is not. That's it. That's the whole personality. πŸŽ€


πŸ¦‹ SYNTAX πŸ¦‹

πŸ’œ C Syntax

#include <mpi.h>
#include <mpi-ext.h>

int MPIX_Query_cuda_support(void)

πŸ’œ Fortran Syntax

There is no Fortran binding for this function. sorry Fortran girlies, not today 😭

πŸ’œ C++ Syntax

There is no C++ binding for this function either. nope, not you either πŸ’€


🌸 DESCRIPTION 🌸

So this function? It's part of an Open MPI extension β€” meaning it is not part of standard MPI. it's giving "special edition, not the base game" ✨

This routine returns 1 if both the MPI library was built with the NVIDIA CUDA library and the runtime supports CUDA buffers. Otherwise, it returns 0. Literally an all-or-nothing situation, no in-between πŸ’…

⚠️ Important: this routine must be called after MPI is initialized, e.g., by a call to MPI_Init(3) or MPI_Init_thread(3). do NOT call it before, that's not the vibe.

Including the Open MPI-specific file <mpi-ext.h> will define the C preprocessor macro OMPI_HAVE_MPI_EXT to 1. Otherwise, it will be undefined. This macro can be used by applications as a sentinel to know whether <mpi-ext.h> has been included or not. it's like a little "yes i was here" note πŸŽ€

The Open MPI CUDA extension is built by default (regardless of whether or not Open MPI was built with CUDA support), but could have been disabled by an administrative action. so like... it usually exists, but an admin can absolutely take it away from you πŸ™ˆ

It is therefore safest for applications to check that the preprocessor macro OMPI_HAVE_MPI_EXT_CUDA is defined and is set to 1 to know whether the MPIX_Query_CUDA_support() function is available. Checking for this macro also protects the use of this function when compiling the application with older versions of Open MPI or other MPI implementations that do not have this function. very "protect yourself at all times" of you, honestly πŸ‘‘

πŸ“ EXAMPLES πŸ“

here's the whole thing in action, copy-paste energy, exact characters, no cap:

#include <stdio.h>
#include <mpi.h>
#include <mpi-ext.h> /* Needed for CUDA-aware check */

int main(int argc, char *argv[])
{
    MPI_Init(&argc, &argv);

    bool happy = false;
#if defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA
    happy = (bool) MPIX_Query_cuda_support();
#endif

    if (happy) {
        printf("This Open MPI installation has CUDA-aware support.\n");
    } else {
        printf("This Open MPI installation does not have CUDA-aware support.\n");
    }

    MPI_Finalize();
    return 0;
}

see how happy is the variable name? iconic honestly. main character energy 😌


πŸ‘€ SEE ALSO πŸ‘€

  • MPIX_Query_rocm_support β€” the AMD-flavored cousin, go say hi 🧚

2003-2026, The Open MPI Community


and that's the whole page bestie, you ate that πŸ«ΆπŸ’…βœ¨

little sign-off: this came from the Open MPI manual, dated Sep 11, 2026 β€” go forth and query your CUDA support responsibly, ily, bye πŸ’œπŸŒˆ
πŸ“¦ where this page comes from