SHMEM_SHORT_WAIT_UNTIL(3)

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

πŸ’– SHMEM_SHORT_WAIT_UNTIL(3) β€” bestie edition πŸ’–

okay so this is a page out of the Open MPI manuals, and it's technically filed under SHMEM_SHORT_WAIT_UNTIL(3) but it actually covers the whole wait/wait_until family. We're talking:

shmem_int_wait(3), shmem_int_wait_until(3), shmem_int4_wait(3), shmem_int4_wait_until(3), shmem_int8_wait(3), shmem_int8_wait_until(3), shmem_long_wait(3), shmem_long_wait_until(3), shmem_longlong_wait(3), shmem_longlong_wait_until(3), shmem_short_wait(3), shmem_short_wait_until(3), shmem_wait(3), shmem_wait_until(3)

and they all do the same iconic thing: wait for a variable on the local processing element (PE) to change. πŸ’…


✨ NAME ✨

shmem_int_wait(3), shmem_int_wait_until(3), shmem_int4_wait(3), shmem_int4_wait_until(3), shmem_int8_wait(3), shmem_int8_wait_until(3), shmem_long_wait(3), shmem_long_wait_until(3), shmem_longlong_wait(3), shmem_longlong_wait_until(3), shmem_short_wait(3), shmem_short_wait_until(3), shmem_wait(3), shmem_wait_until(3) β€” Waits for a variable on the local processing element (PE) to change πŸ¦‹


🌸 SYNOPSIS 🌸

C or C++

#include <mpp/shmem.h>

void shmem_int_wait(volatile int *var, int value)

void shmem_int_wait_until(volatile int *var, int cond, int value)

void shmem_long_wait(volatile long *var, long value)

void shmem_long_wait_until(volatile long *var, int cond, long value)

void shmem_longlong_wait(volatile long long *var, long long value)

void shmem_longlong_wait_until(volatile long long *var, int cond,
  long long value)

void shmem_short_wait(volatile short *var, short value)

void shmem_short_wait_until(volatile short *var, int cond,
  short value)

void shmem_wait(volatile long *ivar, long cmp_value)

void shmem_wait_until(volatile long *ivar, int cmp, long value)
not me listing every single one of these, but like… they're all here and they all matter, so. 🫢

Fortran

INCLUDE "mpp/shmem.fh"

CALL SHMEM_INT4_WAIT(ivar, cmp_value)

CALL SHMEM_INT4_WAIT_UNTIL(ivar, cmp, cmp_value)

CALL SHMEM_INT8_WAIT(ivar, cmp_value)

CALL SHMEM_INT8_WAIT_UNTIL(ivar, cmp, cmp_value)

CALL SHMEM_WAIT(ivar, cmp_value)

CALL SHMEM_WAIT_UNTIL(ivar, cmp, cmp_value)

πŸŽ€ DESCRIPTION πŸŽ€

okay bestie, here's the tea. β˜•

shmem_wait and shmem_wait_until just vibe until ivar gets changed by a remote write or an atomic swap from a different processor. They're the moment for point-to-point directed synchronization β€” very "I'll just be here until you text me back" energy. 😭

  • A call to shmem_wait will not return until some other processor writes a value into ivar on the waiting processor that is not equal to cmp_value.
  • A call to shmem_wait_until will not return until some other processor changes ivar so that it satisfies the condition implied by cmp and cmp_value.

This whole mechanism is so useful when one processor needs to tell another processor that it has finished doing a thing. iconic, honestly.

The arguments are as follows:

  • target β€” The remotely accessible integer data object to be updated on the remote PE. In C/C++, the type of target should match whatever the SYNOPSIS says. If you're on a Fortran compiler, it has to 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 to be atomically added to target. In C/C++, the type of value should match whatever the SYNOPSIS says. In Fortran, it must be of type integer with an element size of target.
  • pe β€” An integer that says which PE number target is going to be updated on. In Fortran, it must be a default integer value.
  • ivar β€” A remotely accessible integer variable that's being updated by another PE. In C/C++, the type of ivar should match whatever the SYNOPSIS says. In Fortran, ivar must be a specific sized integer type depending on which function you're calling, like so:
    • shmem_wait, shmem_wait_until: default INTEGER
    • shmem_int4_wait, shmem_int4_wait_until: INTEGER*4
    • shmem_int8_wait, shmem_int8_wait_until: INTEGER*8
  • cmp β€” The compare operator that compares ivar with cmp_value. cmp must be of type integer. In Fortran it must be of default kind. In C/C++ the type of cmp should match whatever the SYNOPSIS says. These are the cmp values you get to pick from, and yes you have options, we love a menu πŸ’…:
    • SHMEM_CMP_EQ β€” Equal
    • SHMEM_CMP_NE β€” Not equal
    • SHMEM_CMP_GT β€” Greater than
    • SHMEM_CMP_LE β€” Less than or equal to
    • SHMEM_CMP_LT β€” Less than
    • SHMEM_CMP_GE β€” Greater than or equal to
  • cmp_value β€” cmp_value must be of type integer. In C/C++, the type of cmp_value should match whatever the SYNOPSIS says. In Fortran, cmp_value must be an integer of the same size and kind as ivar. Here's the rule, bestie, write it down: the shmem_wait routines return when ivar is no longer equal to cmp_value. The shmem_wait_until routines return when the compare condition is true. And that compare condition is defined by the ivar argument compared against cmp_value using the comparison operator, cmp. 🧚

🌈 EXAMPLES 🌈

Example 1: This call returns when the variable ivar is not equal to 100:

INTEGER*8 IVAR

CALL SHMEM_INT8_WAIT(IVAR, INT8(100))

Example 2: This call to SHMEM_INT8_WAIT_UNTIL is equivalent to the call to SHMEM_INT8_WAIT in example 1:

INTEGER*8 IVAR

CALL SHMEM_INT8_WAIT_UNTIL(IVAR, SHMEM_CMP_NE, INT8(100))

Example 3: This C/C++ call waits until the sign bit in ivar is set by a transfer from a remote PE:

int ivar;

shmem_int_wait_until(&ivar, SHMEM_CMP_LT, 0);

Example 4: This Fortran example lives in the context of a subroutine:

SUBROUTINE EXAMPLE()
  INTEGER FLAG_VAR
  COMMON/FLAG/FLAG_VAR
  . . .
  FLAG_VAR = FLAG_VALUE ! initialize the event variable
  . . .
  IF (FLAG_VAR .EQ. FLAG_VALUE) THEN
    CALL SHMEM_WAIT(FLAG_VAR, FLAG_VALUE)
  ENDIF
  FLAG_VAR = FLAG_VALUE ! reset the event variable for next time
  . . .
END

πŸ‘‘ See also:

intro_shmem(3) shmem_put(3)


2003-2026, The Open MPI Community


and that's a wrap, bestie 🫢 no cap, you're gonna wait_until it clicks and then it'll be so obvious. This page was dated Sep 10, 2026 and it came straight from the Open MPI crew β€” go be the main character of your own PE. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from