Site Tools


mpi-one-sided

Table of Contents

MPI One-sided communication

One-sided communication (RMA) lets processes access remote memory directly. MPI_Win_create exposes a window; other processes read with MPI_Get or write with MPI_Put.

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.

mpi-one-sided.md · Last modified: by 127.0.0.1