MPI_File_iread_shared(3)

πŸ’– MPI_File_iread_shared πŸ’–

okay so bestie, welcome to the MPI manual page for MPI_File_iread_shared(3) β€” yes it's a whole mouthful, yes it slays, and yes I'm gonna walk you through every single crumb of it. grab a strawberry πŸ“ and let's go.


✨ NAME ✨

MPI_File_iread_shared β€” nonblocking read using shared file pointer πŸ¦‹

like… it reads, but it does NOT wait around for you. main character energy fr. and it does it using the shared file pointer, iykyk.


✨ SYNOPSIS ✨

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

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

two flavors, no cap. the _c one is the same vibe, it just takes an MPI_Count for count instead of an int. πŸ’…


✨ INPUT PARAMETERS ✨

  • fh β€” the file handle (type: handle). your lil ticket to the file, basically.
  • count β€” how many elements are in your buffer (integer). the population of your buffer, if you will πŸ’€
  • datatype β€” the datatype of each buffer element (handle). every element gets a lil glow-up label.

✨ OUTPUT PARAMETERS ✨

  • buf β€” initial address of the buffer (choice). where the read data lands, periodt.
  • request β€” the request object (handle). this is the lil thing you hold onto so you can check on your nonblocking read later. keep it safe bestie 🫢

✨ THREAD AND INTERRUPT SAFETY ✨

okay this part matters, so listen up:

this routine is thread-safe πŸ”₯. that means multiple threads can use it at the same time with zero user-provided thread locks β€” you don't have to do anything, it's just built like that. iconic.

BUT. it is not interrupt safe. and like, the reason is usually kind of mundane: it comes from using memory allocation routines such as malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so yeah 🫠


✨ NOTES FOR FORTRAN ✨

for the Fortran girlies 🌸:

  • every MPI routine in Fortran (except MPI_WTIME and MPI_WTICK) has an extra argument ierr tacked onto the end of the argument list.
  • ierr is an integer and it means exactly the 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.
  • all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. no cap.

✨ ERRORS ✨

all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines hand it back as the value of the function, and Fortran routines stick it in the last argument. before that value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job 😭 so like, do not play games.

you can swap the error handler out with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated β€” so, retire her πŸ’€. there's also a predefined error handler, MPI_ERRORS_RETURN, that you can use to make error values get returned instead.

heads up: MPI does not guarantee that 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 roster:

  • MPI_SUCCESS β€” no error; the routine completed successfully. slay ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and it's 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. the mysterious one πŸ’…

and that's the whole page babes πŸ’œ go forth and nonblocking-read responsibly.

this page is from the MPI manual, MPI_File_iread_shared(3), dated 4/10/2026 β€” mwah, bye bestie πŸŽ€

πŸ“¦ where this page comes from