SHMEM_INT_ADD(3)

πŸ’– NAME πŸ’–

okay bestie, gather round, because these five functions are literally the atomic-add queens of Open MPI: shmem_int_add(3), shmem_int4_add(3), shmem_int8_add(3), shmem_long_add(3), shmem_longlong_add(3) β€” they perform an atomic add operation. that's the whole vibe. no cap.


✨ SYNOPSIS ✨

C or C++, my love:

#include <mpp/shmem.h>

void shmem_int_add(int *target, int value, int pe)
void shmem_long_add(long *target, long value, int pe)
void shmem_longlong_add(long long *target, long long value,
  int pe)

Fortran girlies, this one's for you:

include 'mpp/shmem.h'

INTEGER pe

CALL SHMEM_INT4_ADD(target, value, pe)
CALL SHMEM_INT8_ADD(target, value, pe)

🌸 DESCRIPTION 🌸

so the atomic add routines add value to the data sitting at address target on PE pe. and the way it completes β€” okay this is the iconic part β€” it does so without the possibility of another process updating target between the time of the fetch and the update. atomicity slay. πŸ’… nobody can jump in mid-update, periodt.

the arguments are giving:

  • target β€” the remotely accessible integer data object that's getting updated on the remote PE. if you're in C/C++ land, the type of target should match that implied in the SYNOPSIS section. if you're compiling Fortran, it must be of type integer with an element size of 4 bytes for SHMEM_INT4_ADD and 8 bytes for SHMEM_INT8_ADD. πŸ™ˆ
  • value β€” the value being atomically added to target. C/C++ besties: the type of value should match that implied in the SYNOPSIS section. Fortran besties: it must be of type integer with an element size of target. 🫢
  • pe β€” an integer that indicates the PE number upon which target is to be updated. if you're using Fortran, it must be a default integer value. πŸ’œ

πŸ‘‘ NOTES πŸ‘‘

the term remotely accessible is defined in intro_shmem(3) β€” go read it, it's the lore. ✨

also see:


and that's the page, babe πŸŽ€ this one's brought to you by the Open MPI girlies, dated Sep 10, 2026, and the copyright is held tight by 2003-2026, The Open MPI Community. go forth and add atomically, you're doing amazing sweetie πŸ¦‹πŸ’–

πŸ“¦ where this page comes from