Table of Contents

One-sided communication (MPI)

mmap with MAP_SHARED lets two processes on the same machine map the same physical memory. One process writes through its pointer and the other immediately sees the update — no explicit send or receive, no coordination required from the reader. One-sided MPI communication (also called RMA, remote memory access) extends this idea across nodes. A process exposes a memory region as a window with MPI_Win_create, and any other process in the communicator can write into it with MPI_Put or read from it with MPI_Get, without the target process calling any MPI function.

int val = (rank == 0) ? 42 : 0;
MPI_Win win;
MPI_Win_create(&val, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_fence(0, win);
if (rank == 1)
    MPI_Get(&val, 1, MPI_INT, 0, 0, 1, MPI_INT, win);  // rank 1 reads rank 0's val
MPI_Win_fence(0, win);   // val on rank 1 is now 42
MPI_Win_free(&win);

MPI_Win_fence acts as a collective barrier that opens and closes access epochs. MPI_Accumulate is an atomic RMA update that applies an MPI operator rather than simply overwriting. Finer-grained passive-target synchronisation is possible with MPI_Win_lock and MPI_Win_unlock, where the target process does not participate at all.