SHMEM_LONG_FINC(3)

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

NAME ✨

shmem_int4_finc, shmem_int8_finc, shmem_int_finc, shmem_long_finc, shmem_longlong_finc β€” bestie, this is an atomic fetch-and-increment on a remote data object πŸ’–

No cap, that's the whole vibe. You reach over into somebody else's PE, grab the number that's sitting there, hand it back to yourself, and bump it by one on the way out β€” all in one indivisible little moment. 🫢

(This page lives in the Open MPI manual, section 3. Hiiii.)


SYNOPSIS 🌸

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 πŸŽ€

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 πŸ¦‹

Okay so here's what the fetch-and-increment routines do, step by step, and the order genuinely matters:

  1. They fetch the value sitting at address target on PE pe. πŸ‘€
  2. They update target with the result of incrementing that fetched value by one.
  3. And this whole thing must complete without the possibility of another process updating target between the time of the fetch and the update. That's the atomic part β€” it's giving main character energy, no interruptions allowed, periodt. ✨

The arguments, explained with love πŸ’œ

  • target β€” the remotely accessible integer data object that's getting updated on the remote PE. The type of target should match that implied in the SYNOPSIS section, bestie. Don't be out here passing the wrong type, the compiler will simply not be having it. πŸ™ˆ
  • pe β€” an integer that indicates the PE number upon which target is to be updated. If you're doing Fortran, it has to be a default integer value. That's it, that's the rule. πŸ’…

NOTES πŸ“

The term remotely accessible is defined in intro_shmem(3). If you're like "wait, remotely accessible??" β€” go read that one, iykyk. 🧚


RETURN VALUES ⭐

It returns the contents that had been at the target address on the remote PE prior to the increment. So: the old value. The pre-increment value. The before picture. The number as it was, not as it now is. 🌈

See also:


Copyright 2003-2026, The Open MPI Community.

This iconic little page was born Sep 10, 2026, straight out of the Open MPI crew, and it lives at SHMEM_LONG_FINC(3). Slay, go increment something atomically, and stay safe out there. πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from