MPI_FILE_SET_ATOMICITY(3)
β¨ NAME β¨
MPI_File_set_atomicity β okay so this one sets the consistency semantics for data-access operations, and it's collective babe, don't forget that part π
(this is from the Open MPI manual, section 3, and yes we're getting into it)
π SYNTAX π
C Syntax
#include <mpi.h>
int MPI_File_set_atomicity(MPI_File fh, int flag)
Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_SET_ATOMICITY(FH, FLAG, IERROR)
INTEGER FH, FLAG, IERROR
Fortran 2008 Syntax
USE mpi_f08
MPI_File_set_atomicity(fh, flag, ierror)
TYPE(MPI_File), INTENT(IN) :: fh
LOGICAL, INTENT(IN) :: flag
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
πΈ INPUT PARAMETERS πΈ
fhβ the file handle, bestie. It's a handle. That's the whole vibe. π«Άflagβ a boolean, and it's giving very binary:trueflips on atomic mode,falseflips on nonatomic mode. Pick a lane. β¨
π OUTPUT PARAMETER π
ierrorβ Fortran only, it's the error status, and it's an integer. That's it. That's the whole output. π
π¦ DESCRIPTION π¦
So here's the tea β: the consistency semantics for data-access operations β using the set of file handles that got created by one collective MPI_File_open β get set by collectively calling MPI_File_set_atomicity. Collective. Did I say collective? Collective π
Every process in the group has to pass identical values for fh and flag. No side-eyeing, no "I'll pass something different," no main-character nonsense. Everyone agrees or nobody eats.
If flag is true β atomic mode is set. If flag is false β nonatomic mode is set. Simple. Iconic. No cap.
And the default on a call to MPI_File_open in Open MPI? Glad you asked π β it's true for jobs running on more than one node, and false for jobs running on a single SMP. That's the default, not a suggestion. For more info, go read the MPI-2 standard, it's right there. π
π₯ ERRORS π₯
Okay so error handling in MPI, buckle up buttercup π
Almost all MPI routines return an error value. C routines give it to you as the return result of the function, and Fortran routines park it in the last argument. That's the system. π«Ά
Before that error value comes back to you, the current MPI error handler associated with the communication object gets called β and "communication object" means things like a communicator, a window, or a file. If there's no communication object associated with the MPI call, then the call counts as attached to MPI_COMM_SELF, and it'll call the associated MPI error handler. And when MPI_COMM_SELF isn't initialized β meaning 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. π
And how do you change that initial error handler? Two ways, iykyk:
- call
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - use the
mpi_initial_errhandlerCLI argument tompiexec, or the info key toMPI_Comm_spawn/MPI_Comm_spawn_multiple.
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. Different handlers for different departments, honestly fair. β¨
Open MPI ships 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 it's called on a communicator, it acts as ifMPI_Abortwas called on that communicator. If it's called on a window or file, it acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. And if it's called on a session, it aborts only the local process β just you, bestie, rip. π«MPI_ERRORS_RETURNβ returns an error code to the application. The chill one. The one that lets you handle it. π
MPI applications can also roll their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
β οΈ Note that MPI does not guarantee that an MPI program can continue past an error. Like, fr fr. Don't assume you can just pick yourself up and keep going, because the standard is not promising you that π
See the MPI man page for the full list of MPI error codes. And see the Error Handling section of the MPI-3.1 standard for more info. Go read it, it's good for you π
π COPYRIGHT π
2003-2026, The Open MPI Community
and that's the whole page bestie, mwah π β this was MPI_FILE_SET_ATOMICITY(3) from Open MPI, dated Sep 11, 2026, so you know it's fresh πβ¨π¦
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms