MPI_File_read_at_all_begin(3)
π NAME π
MPI_File_read_at_all_begin β ok so bestie, this is the one that begins a split collective read using explicit offset. Periodt. β¨
π¦ SYNOPSIS π¦
int MPI_File_read_at_all_begin(MPI_File fh, MPI_Offset offset, void *buf,
int count, MPI_Datatype datatype)
int MPI_File_read_at_all_begin_c(MPI_File fh, MPI_Offset offset, void *buf,
MPI_Count count, MPI_Datatype datatype)
Two flavors, same vibe β the _c one just takes an MPI_Count for count instead of an int. Choose your fighter. π
πΈ INPUT PARAMETERS πΈ
fhβ the file handle, aka which file we're being nosy about (handle)offsetβ file offset, like where in the file we're starting (integer)countβ how many elements are chillin' in the buffer (integer)datatypeβ the datatype of each buffer element, so it knows what it's actually reading (handle)
π OUTPUT PARAMETERS π
bufβ initial address of the buffer, the spot where the goods get dropped off (choice)
β¨ THREAD AND INTERRUPT SAFETY β¨
Ok so the good news first: this routine is thread-safe. That means multiple threads can use it at the same time and you do not need to bring your own thread locks. No cap. π«Ά
But β and this is important bestie β it is NOT interrupt safe. π Why? Typically because of memory allocation routines in there, like malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. So don't come for it with signals, it's not built like that.
π NOTES FOR FORTRAN π
Every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK, they're the exceptions, iykyk) gets an extra argument ierr tacked on at the end of the argument list. ierr is an integer and it means exactly the same thing as the return value of the routine does in C. π―
Also in Fortran, MPI routines are subroutines, so you invoke them with the call statement. That's just how it is.
And one more: all MPI objects β like MPI_Datatype, MPI_Comm β are of type INTEGER in Fortran. Slay.
π ERRORS π
Every single MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value. In C routines that's the return value of the function; in Fortran routines it's in that last argument. Before the value comes back to you, the current MPI error handler gets called. And by default? That error handler aborts the entire MPI job. Like, full shutdown, no survivors. π¨
You can change the error handler with:
MPI_Comm_set_errhandlerβ for communicatorsMPI_File_set_errhandlerβ for filesMPI_Win_set_errhandlerβ for RMA windows
The MPI-1 routine MPI_Errhandler_set may also be used, but heads up: its use is deprecated. π
If you'd rather get error values back instead of getting your whole job ended, the predefined error handler MPI_ERRORS_RETURN is the one that does that.
Also note that MPI does not guarantee an MPI program can continue past an error. That said, MPI implementations will attempt to continue whenever possible. So likeβ¦ fingers crossed? π
Here's the full error lineup:
MPI_SUCCESSβ no error, it just worked, we love that; the MPI routine completed successfully βMPI_ERR_BUFFERβ invalid buffer pointer. Usually a null buffer where a null buffer is not valid, so like, don't do thatMPI_ERR_COUNTβ invalid count argument. Count arguments must be non-negative; a count of zero is often valid though, so zero isn't always the villain hereMPI_ERR_TYPEβ invalid datatype argument. This can ALSO happen if you use an uncommittedMPI_Datatype(seeMPI_Type_commit) in a communication call. Commit your types bestie, that's the whole point πMPI_ERR_OTHERβ other error; useMPI_Error_stringto get more info about this error code
ok that's the whole page, you're officially educated, go read some files with explicit offsets π
This has been your girl, reporting live from the MPI manual, dated 4/10/2026 β same page, same MPI_File_read_at_all_begin(3) energy. Byeeeee! πβ¨
π¦ 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