SHMEM_LONG_SWAP(3)
πΈ NAME πΈ
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) β bestie, these all do one iconic thing: perform an atomic swap to a remote data object π
This is the <cyan>shmem_long_swap(3)</cyan> page from the Open MPI manual, and she contains multitudes (a whole lil family of swap functions, actually). Let's get into it β¨
π¦ SYNOPSIS π¦
okay so, C or C++ girlies:
#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 for the Fortran besties:
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 π
The atomic swap routines write value to address target on PE pe, and return the previous contents of target in one atomic operation π Like, it's all one move, no in-between, no half-swapped mess. Periodt.
Here's the cast of arguments, and yes they each have main character energy π
targetβ the remotely accessible integer data object being updated on the remote PE. If you're in C/C++ land, the type oftargetshould match whatever the SYNOPSIS says it is (no mixing and matching, iykyk). If you're doing Fortran, it's gotta be one of these types: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. She is the same type astarget, no cap π«Άpeβ an integer that says which PE numbertargetis getting updated on. In Fortran it must be a default integer value, fr fr.
π NOTES π
The term remotely accessible is defined over in intro_shmem(3). Go peek if you need the full tea π΅
π RETURN VALUES π
Whatever was sitting at the target address on the remote PE before the swap happened? Yeah, that's what you get back. The old value is returned to you, bestie β nothing gets lost, everything gets traded ππ₯
See also: intro_shmem(3)
π Copyright π
2003-2026, The Open MPI Community β they've been holding it down since 2003, iconic behavior honestly π
okay that's the whole page!! this was SHMEM_LONG_SWAP(3) from Open MPI, last touched Sep 10, 2026 β go forth and swap atomically, you've got this ππ§β¨
π¦ 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