SHMEM_FINC(3)

πŸ’– SHMEM_FINC(3) β€” Open MPI’s atomic fetch-and-increment, bestie edition πŸ’–

Okay so this is the Open MPI manual page for SHMEM_FINC(3), and it’s giving atomic remote fetch-and-increment main character energy. No cap, these routines are here to do one very specific little slay.


✨ NAME ✨

The squad is:

And what do they do? They perform an atomic fetch-and-increment operation on a remote data object. Periodt. πŸ’…


πŸ›  SYNOPSIS πŸ› 

C or C++:

C or C++:
#include <mpp/shmem.h>

int shmem_int_finc(int *target, int pe);

long shmem_long_finc(long *target, int pe);

long long shmem_longlong_finc(long long *target, int pe);

Fortran:

Fortran:
INCLUDE "mpp/shmem.fh"

INTEGER pe
INTEGER(KIND=4) SHMEM_INT4_FINC, target4
INTEGER(KIND=8) SHMEM_INT8_FINC, target8

ires4 = SHMEM_INT4_FINC(target4, pe)

ires8 = SHMEM_INT8_FINC(target8, pe)

πŸ¦‹ DESCRIPTION πŸ¦‹

Bestie, here’s the vibe: the fetch-and-increment routines grab the value at address target on PE pe, then update target with the result of incrementing that retrieved value by one. Iconic. πŸŽ€

And the very important part? The operation must be completed without the possibility of another process updating target between the time of the fetch and the update. That’s the atomicity of it all β€” it’s not just cute, it’s required. πŸ’€

The arguments are giving:

  • target β€” the remotely accessible integer data object to be updated on the remote PE. The type of target should match that implied in the SYNOPSIS section. Don’t try to be mysterious with the type, okay? Match it. 🫢
  • pe β€” an integer that indicates the PE number upon which target is to be updated. If you are using Fortran, it must be a default integer value. Fr fr, default integer. ✨

πŸ“ NOTES πŸ“

The term remotely accessible is defined in intro_shmem(3). That’s the lore, iykyk. 🌸


πŸ” RETURN VALUES πŸ”

These routines return the contents that had been at the target address on the remote PE prior to the increment. So you get the old value back, and the remote object gets the +1 glow-up. πŸ’–


πŸ‘€ SEE ALSO πŸ‘€

  • intro_shmem(3) β€” go read it, bestie, that’s where β€œremotely accessible” gets its definition. πŸ¦‹

Source/version check: the footer says gitclone, Unreleased developer copy, and echoes SHMEM_FINC(3). Date? Not listed in this footer, so it’s lowkey timeless. Stay atomic, bestie. πŸ’…βœ¨

πŸ“¦ where this page comes from
  • arch rolling: nvhpc-comm-libs 26.9-1 Β· LicenseRef-NVIDIA-HPC-SDK
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms