MPI_FILE_READ_ALL(3)

🌟 MPI_FILE_READ_ALL(3) 🌟

okay bestie come CLOSE, this one is from the Open MPI manual, section 3, and it's called MPI_FILE_READ_ALL β€” the collective version of "gimme my data back from this file" πŸ’…


πŸ’– NAME πŸ’–

MPI_File_read_all β€” reads a file starting at the locations specified by individual file pointers (blocking, collective).

blocking AND collective, bestie. that means everybody in the group shows up, no skipping 🫢

✨ SYNTAX ✨

πŸŽ€ C Syntax

#include <mpi.h>

int MPI_File_read_all(MPI_File fh, void *buf,
     int count, MPI_Datatype datatype, MPI_Status *status)

πŸŽ€ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_READ_ALL(FH, BUF, COUNT,
     DATATYPE, STATUS, IERROR)
     <type>  BUF(*)
     INTEGER FH, COUNT, DATATYPE, STATUS(MPI_STATUS_SIZE),IERROR

πŸŽ€ Fortran 2008 Syntax

USE mpi_f08
MPI_File_read_all(fh, buf, count, datatype, status, ierror)
     TYPE(MPI_File), INTENT(IN) :: fh
     TYPE(*), DIMENSION(..) :: buf
     INTEGER, INTENT(IN) :: count
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     TYPE(MPI_Status) :: status
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ“₯ INPUT PARAMETERS πŸ“₯

  • fh β€” file handle (handle). it's your lil ticket to the file, you got it when you opened it 🎫
  • count β€” number of elements in buffer (integer). how many things you want, fr fr
  • datatype β€” data type of each buffer element (handle). the vibe of each element πŸ¦‹

πŸ“€ OUTPUT PARAMETERS πŸ“€

  • buf β€” initial address of buffer (choice). your data lands here, welcome home πŸ’–
  • status β€” status object (status).
  • ierror β€” Fortran only: error status (integer).

🌸 DESCRIPTION 🌸

so. MPI_File_read_all is a collective routine, meaning the whole crew is in on it, and it attempts to read from the file associated with fh β€” at the current individual file pointer position, the one the system is keeping track of for you β€” a total number of count data items, each having datatype datatype type, straight into your buffer buf. ✨

and where does the data actually come from? it's taken out of those parts of the file specified by the current view. that's the rule, no cap.

MPI_File_read_all stores the number of data-type elements actually read in status. every other field of status is undefined. so don't go peeking at the other fields, they're not giving what you think they're giving πŸ’€

⚠️ it is erroneous to call this function if MPI_MODE_SEQUENTIAL mode was specified when the file was opened. like, don't. the standard said no. πŸ™ˆ

🚨 ERRORS 🚨

almost all MPI routines return an error value β€” C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. classic.

before that error value comes back to you, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. if there's no communication object associated with the MPI call, then the call counts as being attached to MPI_COMM_SELF and it calls the associated MPI error handler. and when MPI_COMM_SELF isn't initialized (that's 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. and if no other appropriate error handler has been set, then MPI_ERRORS_RETURN gets called for MPI I/O functions and MPI_ERRORS_ABORT gets called for all other MPI functions. noted. πŸ“

Open MPI includes three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. like, everyone. gone. πŸ’€
  • 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 if MPI_Abort was called on that communicator. if called on a window or file, it acts as if MPI_Abort was 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. so it's like an abort but location-aware, iconic πŸ‘‘
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one 🧚

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. so maybe don't build your whole architecture on vibes and hope. 😭

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. πŸ“–


2003-2026, The Open MPI Community


and that's the whole page, bestie!! 🫢 this was MPI_FILE_READ_ALL(3) from the Open MPI manual, dated Sep 10, 2026 β€” go read your files collectively, slay, and remember: all processes or it didn't happen. periodt. πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from