SHMEM_DOUBLE_SWAP(3)

πŸ“¦
version 5.0.10 Β· 4 versions
, in ubuntu stonking

πŸ’… 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 of target has to match whatever the SYNOPSIS said, no mixing and matching. Fortran girlies, it has to be one of these:
    • SHMEM_SWAP: Integer of default kind
    • SHMEM_INT4_SWAP: 4-byte integer
    • SHMEM_INT8_SWAP: 8-byte integer
    • SHMEM_REAL4_SWAP: 4-byte real
    • SHMEM_REAL8_SWAP: 8-byte real
  • value β€” the thing getting atomically written to the remote PE. value is the same type as target, matching energy always. πŸ’ž
  • pe β€” an integer that says which PE number target is 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:


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