SHMEM_INT_SWAP(3)
π SHMEM_INT_SWAP β bestie edition
okay so. we're in the Open MPI house tonight and the page is literally called SHMEM_INT_SWAP(3), but honestly? it's a whole girl squad. say hi to the family:
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 do? one job, and they do it flawlessly: performs an atomic swap to a remote data object. β¨ no cap.
β¨ SYNOPSIS β¨
C or C++
#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
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. one. single. operation. it's giving main character energy and honestly we're obsessed. π
the arguments are as follows:
targetβ the remotely accessible integer data object that's getting updated on the remote PE. if you're doing C/C++, the type oftargetshould match whatever the SYNOPSIS section implied (look up, bestie π). if you're doing Fortran, it must 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 to be atomically written to the remote PE.valueis the same type astarget, they're matching, it's a coordinated outfit πpeβ an integer that indicates the PE number on whichtargetis to be updated. if you're doing Fortran, it must be a default integer value.
π NOTES π
the term remotely accessible is defined in intro_shmem(3). go read it, i'll wait π«Ά
π¦ RETURN VALUES π¦
the contents that had been at the target address on the remote PE prior to the swap is returned. yes, you get the old thing back. the vibes are exchanged. it's a swap. it's literally in the name π
see also:
lowkey reminder: if you're in Fortran,targettypes and default-integerpeare not a suggestion, they're the law.
and that's the whole page, bestie, we ate and left no crumbs. this whole thing is copyright 2003-2026, The Open MPI Community π and it comes to you from the Open MPI era, dated Sep 10, 2026 β so you know it's fresh. mwah. ππ§β¨
π¦ 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