SHMEM_DOUBLE_SWAP(3)
π SHMEM_DOUBLE_SWAP(3) β the Open MPI manual, but make it make sense
okay bestie, buckle up, because this is the page for a whole girl gang of functions and they all do the same iconic thing: atomically swap a value into somebody else's memory. β¨
The crew is: shmem_double_swap(3), shmem_float_swap(3), shmem_int_swap(3), shmem_long_swap(3), shmem_swap(3), shmem_int4_swap(3), shmem_int8_swap(3), shmem_real4_swap(3), shmem_real8_swap(3), and shmem_longlong_swap(3).
And what do they do? Performs an atomic swap to a remote data object. periodt. π
β¨ SYNOPSIS β¨
C or C++ girlies, hit it:
#include <mpp/shmem.h>
double shmem_double_swap(double *target, double value,
int pe)
float shmem_float_swap(float *target, float value, int pe)
int shmem_int_swap(int *target, int value, int pe)
long shmem_long_swap(long *target, long value, int pe)
long long shmem_longlong_swap(long long *target,
long long value, int pe)
long shmem_swap(long *target, long value, int pe)
Fortran besties, this one's for you:
INCLUDE "mpp/shmem.fh"
INTEGER pe
INTEGER SHMEM_SWAP
ires = SHMEM_SWAP(target, value, pe)
INTEGER(KIND=4) SHMEM_INT4_SWAP
ires = SHMEM_INT4_SWAP(target, value, pe)
INTEGER(KIND=8) SHMEM_INT8_SWAP
ires = SHMEM_INT8_SWAP(target, value, pe)
REAL(KIND=4) SHMEM_REAL4_SWAP
res = SHMEM_REAL4_SWAP(target, value, pe)
REAL(KIND=8) SHMEM_REAL8_SWAP
res = SHMEM_REAL8_SWAP(target, value, pe)
πΈ DESCRIPTION πΈ
so the atomic swap routines write value to address target on PE pe, and then hand you back the previous contents of target β and they do the whole thing in one atomic operation. no half-swaps, no sneaky in-between states, no drama. it's giving locked-in. π
The arguments are as follows:
targetβ the remotely accessible integer data object that's getting updated on the remote PE. C/C++ girlies: the type oftargethas to match whatever the SYNOPSIS said, no mixing and matching. Fortran girlies, it has to be one of these:SHMEM_SWAP: Integer of default kindSHMEM_INT4_SWAP: 4-byte integerSHMEM_INT8_SWAP: 8-byte integerSHMEM_REAL4_SWAP: 4-byte realSHMEM_REAL8_SWAP: 8-byte real
valueβ the thing getting atomically written to the remote PE.valueis the same type astarget, matching energy always. πpeβ an integer that says which PE numbertargetis getting updated on. Fortran bestie, this one has to be a default integer value.
π NOTES π
the term remotely accessible is defined over in intro_shmem(3) β go read that if the vibe check on that phrase is failing, iykyk. π¦
π RETURN VALUES π
what you get back is the contents that had been at the target address on the remote PE prior to the swap. so like, the old thing. you gave them the new thing, they gave you the old thing. fair trade, fr fr. π₯
See also:
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, bestie!! π no cap, you're now fully fluent in atomic remote swaps. this was the Open MPI version of SHMEM_DOUBLE_SWAP(3), dated Sep 10, 2026 β go forth and swap responsibly. π
β¨π«Ά
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms