MPI_QUERY_THREAD(3)
π MPI_Query_thread: returns the current level of thread support π
hiii bestie, welcome to the Open MPI manual π this one's a lil cutie β it's all about asking MPI "hey, how threaded are we actually allowed to be rn?" no cap, it's a vibe check for your thread support level β¨
πΈ SYNTAX πΈ
π C Syntax
#include <mpi.h>
int MPI_Query_thread(int *provided)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_QUERY_THREAD(PROVIDED, IERROR)
INTEGER PROVIDED, IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_Query_thread(provided, ierror)
INTEGER, INTENT(OUT) :: provided
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π¦ OUTPUT PARAMETERS π¦
providedβ C/Fortran only π«Ά this is where the level of thread support lands. it's an integer, bestie.ierrorβ Fortran only π the error status, also an integer.
β¨ DESCRIPTION β¨
okay so this routine returns, in provided, the current level of thread support. simple as that π
and here's the tea: if MPI was initialized by a call to MPI_Init_thread, then provided will have the exact same value that MPI_Init_thread returned. periodt. no surprises, no plot twists π
the possible values of provided are these lil icons:
MPI_THREAD_SINGLEβ only one thread may execute. it's giving solo era πMPI_THREAD_FUNNELEDβ if the process is multithreaded, only the thread that calledMPI_Init[_thread]may make MPI calls. one main character only πMPI_THREAD_SERIALIZEDβ if the process is multithreaded, only one thread may make MPI library calls at one time. take turns, besties, we're not animals πMPI_THREAD_MULTIPLEβ if the process is multithreaded, multiple threads may call MPI at once with no restrictions. absolute chaos, slay π₯
π NOTES π
so in Open MPI, here's the lowkey important bit: provided is always MPI_THREAD_SINGLE β unless your program has been linked with the multithreaded library, in which case provided is MPI_THREAD_MULTIPLE. that's it, that's the whole spectrum. iykyk π€·ββοΈ
π ERRORS π
almost all MPI routines return an error value, bestie. C routines give it back as the return result of the function, and Fortran routines put it in the last argument. β¨
before that error value comes back, the current MPI error handler associated with the communication object (like a communicator, window, or file, you know the vibe) gets called. if no communication object is associated with the MPI call, then the call is treated as attached to MPI_COMM_SELF and it'll call the associated MPI error handler instead. π«Ά
and when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively) β the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. π
if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. π
Open MPI includes three predefined error handlers that can be used:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic, but make it fatal πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if called on a window or file, it acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. if called on a session, it aborts only the local process. πMPI_ERRORS_RETURNβ returns an error code to the application. polite, respectful, iconic β¨
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
no cap, note that MPI does not guarantee that an MPI program can continue past an error. π so don't be out here assuming you can just keep vibing after one.
see the MPI man page for a full list of MPI error codes. π
see the Error Handling section of the MPI-3.1 standard for more information. π
See also:
MPI_InitMPI_Init_thread
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, bestie π«Ά this lil manual page came from the Open MPI crew, dated Sep 10, 2026, and yeah β MPI_QUERY_THREAD(3). now go forth and thread responsibly π
β¨πΈ
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms