SHMEM_FLOAT_SWAP(3)
π¦ NAME π¦
okay so this is SHMEM_FLOAT_SWAP(3) from Open MPI, and it's literally the whole glow-up squad of atomic swap besties:
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),shmem_longlong_swap(3)
β¦and what do they all do? They perform an atomic swap to a remote data object. no cap. π
β¨ SYNOPSIS β¨
okay bestie, here's the C or C++ situation:
#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)
and now the Fortran girlies πΈ:
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 they return the previous contents of target β all in one atomic operation. like, one single flawless move, no half-steps, she ate and left no crumbs. π
and here's the cast of arguments, bestie:
targetβ the remotely accessible integer data object that's getting updated on the remote PE. if you're in C/C++, the type oftargetshould match what it says up in the SYNOPSIS section (ikykw). if you're in Fortran, 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 value getting atomically written to the remote PE.valueis the same type astarget, periodt.peβ an integer that says which PE numbertargetis getting updated on. if you're in Fortran, it has to be a default integer value. π
π NOTES π
the term remotely accessible is defined in intro_shmem(3). go check her out, she explains everything. π«Ά
π RETURN VALUES π
what comes back to you is the contents that had been at the target address on the remote PE prior to the swap. like she hands you the old vibe and takes the new one. π₯
See also:
intro_shmem(3)
Β©οΈ Copyright Β©οΈ
2003-2026, The Open MPI Community β protect her at all costs. π
and that's the whole page bestie, no notes, she's iconic. this was SHMEM_FLOAT_SWAP(3) from the Open MPI fam, dated Sep 10, 2026 β slay, bye, ily, go write some atomic swaps. πβ¨π
π¦ 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