MPIX_Grequest_class_create(3)

๐Ÿ’– MPIX_Grequest_class_create(3) ๐Ÿ’–

okay bestie, welcome to the MPI manual, section 3, and today's main character is MPIX_Grequest_class_create. yes it's a whole mouthful, no i will not be pronouncing it, we're just gonna vibe with it ๐Ÿซถ


โœจ NAME โœจ

MPIX_Grequest_class_create โ€” [short description]


๐ŸŒธ SYNOPSIS ๐ŸŒธ

int MPIX_Grequest_class_create(MPI_Grequest_query_function *query_fn,
                               MPI_Grequest_free_function *free_fn,
                               MPI_Grequest_cancel_function *cancel_fn,
                               MPIX_Grequest_poll_function *poll_fn,
                               MPIX_Grequest_wait_function *wait_fn,
                               MPIX_Grequest_class *greq_class)

๐ŸŽ€ INPUT PARAMETERS ๐ŸŽ€

so you're handing it a little squad of callback functions, each one a function. here's the lineup:

  • query_fn โ€” the callback that gets invoked when the request status is queried (function) ๐Ÿ‘€
  • free_fn โ€” the callback that gets invoked when the request is freed (function) ๐Ÿ•Š๏ธ
  • cancel_fn โ€” the callback that gets invoked when the request is cancelled (function) ๐Ÿ™…
  • poll_fn โ€” the callback that gets invoked when request completion is tested (function) โณ
  • wait_fn โ€” the callback that gets invoked when the request is waited on (function) ๐Ÿง˜

๐Ÿ’… OUTPUT PARAMETERS ๐Ÿ’…

  • greq_class โ€” generalized request class (None) โœจ there it is, the thing you came for

๐Ÿ”ฅ THREAD AND INTERRUPT SAFETY ๐Ÿ”ฅ

good news: this routine is thread-safe. that means you can literally let multiple threads use it at the same time, and you do not need to bring your own thread locks. no gatekeeping, no drama, it just works ๐Ÿ’…

but โ€” and this is the part where i hold your hand โ€” it is not interrupt safe. typically that's because it uses memory allocation routines like malloc, or other non-MPICH runtime routines, that are themselves not interrupt-safe. so like, thread safe: yes. interrupt safe: absolutely not, bestie ๐Ÿ˜ญ


๐ŸŒˆ NOTES FOR FORTRAN ๐ŸŒˆ

  • every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has an extra argument ierr tacked on the end of the argument list. ierr is an integer and means the exact same thing as the return value of the routine in C. also, in Fortran, MPI routines are subroutines and you invoke them with the call statement ๐Ÿ“ž
  • all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran ๐Ÿงฎ

๐Ÿ’€ ERRORS ๐Ÿ’€

okay so every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value โ€” C routines give it back as the value of the function, and Fortran routines put it in that last argument. before that value comes back, the current MPI error handler gets called. and by default? that error handler aborts the MPI job. like, whole thing, gone, bye ๐Ÿ˜ญ

you can swap the error handler out:

  • MPI_Comm_set_errhandler โ€” for communicators
  • MPI_File_set_errhandler โ€” for files
  • MPI_Win_set_errhandler โ€” for RMA windows

and yeah, the MPI-1 routine MPI_Errhandler_set may be used, but heads up: its use is deprecated. old news, don't do it ๐Ÿšซ

you can also use the predefined error handler MPI_ERRORS_RETURN to make error values actually get returned to you instead. and note this: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible ๐Ÿซถ

here's the error codes, no cap:

  • MPI_SUCCESS โ€” no error; the MPI routine completed successfully ๐ŸŽ‰
  • MPI_ERR_ARG โ€” invalid argument. some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK) ๐Ÿ™ˆ
  • MPI_ERR_OTHER โ€” other error; use MPI_Error_string to get more information about this error code ๐Ÿง

ngl bestie, if you got MPI_ERR_ARG it's not giving "mystery", it's giving "check your arguments" ๐Ÿ’€

and that's the whole page, you ate it, periodt ๐Ÿ‘‘

this was the MPI manual, section 3 โ€” MPIX_Grequest_class_create(3) โ€” dated 4/10/2026. take care of your generalized requests and they'll take care of you ๐Ÿ’–โœจ๐ŸŽ€๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from