MPI_File_iread_at(3)
β¨ MPI_File_iread_at(3) β bestie edition β¨
okay so this is page 3 of the MPI manual, and today we're talking about MPI_File_iread_at π nonblocking read, but make it explicit offset. no hidden file pointer, we're saying exactly where we want the bytes from. iconic behavior fr fr.
πΈ NAME πΈ
MPI_File_iread_at β Nonblocking read using explicit offset
π SYNOPSIS π
int MPI_File_iread_at(MPI_File fh, MPI_Offset offset, void *buf, int count,
MPI_Datatype datatype, MPI_Request *request)
int MPI_File_iread_at_c(MPI_File fh, MPI_Offset offset, void *buf,
MPI_Count count, MPI_Datatype datatype,
MPI_Request *request)
two flavors, same vibe π
the _c one is just out here with the bigger MPI_Count for count, living its best life.
π«Ά INPUT PARAMETERS π«Ά
fhβ the file handle (handle). your lil ticket to the file, bestie.offsetβ file offset (integer). this is the "read from right here" energy. explicit, no guessing.countβ number of elements in buffer (integer). how many of the things are we grabbing.datatypeβ datatype of each buffer element (handle). what kind of thing each element is.
π OUTPUT PARAMETERS π
bufβ initial address of buffer (choice). where the good stuff lands.requestβ request object (handle). your receipt π§Ύ hold onto it, you'll need it to check on the read later.
π THREAD AND INTERRUPT SAFETY π
this routine is thread-safe, no cap β¨ which means multiple threads can use it safely without you having to bring your own thread locks. you don't gotta do anything extra, she handles it.
but she is not interrupt safe π and that's usually because of memory allocation routines like malloc, or other non-MPICH runtime routines β those ones aren't interrupt-safe themselves, so they drag the whole vibe down.
π¦ NOTES FOR FORTRAN π¦
okay Fortran besties, listen up π£ every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK, they're the β¨ exceptions β¨) gets an extra argument ierr tacked on at the end of the argument list. ierr is an integer and it means the exact same thing as the return value of the routine in C. just translated, iykyk.
and in Fortran, MPI routines are subroutines, and you invoke them with the call statement. that's the whole thing.
also, all MPI objects (like MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. periodt π
π ERRORS π
so like, every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines as the value of the function, Fortran routines in that last argument we just talked about. and before the value comes back, the current MPI error handler is called. by default, that error handler aborts the MPI job π dramatic but true.
you can swap the error handler with:
MPI_Comm_set_errhandlerβ for communicatorsMPI_File_set_errhandlerβ for filesMPI_Win_set_errhandlerβ for RMA windows
and there's the old MPI-1 routine MPI_Errhandler_set, but using it is deprecated π so maybe don't.
there's also a predefined error handler MPI_ERRORS_RETURN you can use to make error values actually get returned to you instead of the whole thing exploding.
β οΈ and note: MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like... sometimes she recovers, sometimes she doesn't, no promises π«
here's the error menu:
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 uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call.MPI_ERR_OTHERβ Other error; useMPI_Error_stringto get more information about this error code.
okay that's the whole page bestie, you're basically an MPI file I/O main character now πβ¨ this was the MPI manual, section 3, dated 4/10/2026 β mwah, go read some bytes nonblockingly, ily ππ
π¦ where this page comes from
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms