MPI_File_iread_all(3)

๐Ÿ’– MPI_File_iread_all โ€” bestie, let's do a collective read โœจ

okay so this is a page from the MPI manual, and today's main character is MPI_File_iread_all. basically: a nonblocking collective read using the individual file pointer. no cap. ๐Ÿฆ‹


๐ŸŒธ NAME ๐ŸŒธ

MPI_File_iread_all โ€” Nonblocking collective read using individual file pointer ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

int MPI_File_iread_all(MPI_File fh, void *buf, int count, MPI_Datatype datatype,
MPI_Request *request)

int MPI_File_iread_all_c(MPI_File fh, void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Request *request)

two versions, bestie โ€” the classic one and the big-count one with MPI_Count. pick your fighter โœจ


๐Ÿ“ฅ INPUT PARAMETERS ๐Ÿ“ฅ

girlies, these are the things you hand to the function:

  • fh โ€” file handle (handle). it's givingโ€ฆ the file, obviously ๐Ÿ’€
  • count โ€” number of elements in buffer (integer). literally how many elements.
  • datatype โ€” datatype of each buffer element (handle). each element's type, go off ๐Ÿ‘‘

๐Ÿ“ค OUTPUT PARAMETERS ๐Ÿ“ค

and these are the things you get back:

  • buf โ€” initial address of buffer (choice). yes bestie, it said "output" up top, we're not questioning the manual's choices ๐Ÿ™ˆ
  • request โ€” request object (handle). hold onto this, you'll need it to check on the read later ๐Ÿซถ

๐Ÿงต THREAD AND INTERRUPT SAFETY ๐Ÿงต

okay so this routine is thread-safe. that means you can literally use it from multiple threads at the same time, and you do not need to bring your own thread locks. slay.

BUT. (there's always a but ๐Ÿ˜ญ) it is not interrupt safe. the usual reason: it uses memory allocation routines like malloc, or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so likeโ€ฆ thread-safe, yes. interrupt-safe, absolutely not. periodt.


๐Ÿ”ฎ NOTES FOR FORTRAN ๐Ÿ”ฎ

  • every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has one extra argument at the end: ierr. ierr is an integer and means the exact same thing as the return value of the routine in C. ๐Ÿงš
  • in Fortran, MPI routines are subroutines, and you invoke them with the call statement. iconic.
  • 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 hand it back as the function's value, Fortran routines put it in that last argument.

before the value comes back, the current MPI error handler gets called. by default, this error handler aborts the MPI job. yeah. no chill. ๐Ÿ’€

you can change the handler with:

  • MPI_Comm_set_errhandler (for communicators)
  • MPI_File_set_errhandler (for files)
  • MPI_Win_set_errhandler (for RMA windows)

the MPI-1 routine MPI_Errhandler_set may be used, but its use is deprecated โ€” so like, maybe don't, bestie.

you can also use the predefined error handler MPI_ERRORS_RETURN to make error values get returned instead.

and like, heads up: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. soโ€ฆ best effort ๐Ÿซถ

here's the full error squad:

  • MPI_SUCCESS โ€” No error; MPI routine completed successfully. we love to see it โœจ
  • 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_BUFFER โ€” Invalid buffer pointer. Usually a null buffer where one is not valid.
  • MPI_ERR_COUNT โ€” Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.
  • MPI_ERR_TYPE โ€” Invalid datatype argument. Additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call.
  • MPI_ERR_OTHER โ€” Other error; use MPI_Error_string to get more information about this error code.

reminder bestie: that default error handler aborts the whole job. if you want the error value handed back to you instead of everything exploding, set MPI_ERRORS_RETURN. iykyk ๐Ÿ’…

and that's the whole page, babe ๐ŸŽ€ that was MPI_File_iread_all(3) from the MPI manual, dated 4/10/2026 โ€” thanks for reading, you ate that fr fr ๐Ÿ‘‘๐Ÿ’–

๐Ÿ“ฆ where this page comes from