SHMEM_WAIT_UNTIL(3)

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

πŸ’– SHMEM_WAIT_UNTIL πŸ’–

okay so bestie, we're in the Open MPI manual, section 3, and this page is literally about making your program sit there and wait for a value to change. group-chat-approved concurrency, let's go 🫢

These are the icons on this page:

  • shmem_int_wait, shmem_int_wait_until
  • shmem_int4_wait, shmem_int4_wait_until
  • shmem_int8_wait, shmem_int8_wait_until
  • shmem_long_wait, shmem_long_wait_until
  • shmem_longlong_wait, shmem_longlong_wait_until
  • shmem_short_wait, shmem_short_wait_until
  • shmem_wait, shmem_wait_until

and what they all do is: waits for a variable on the local processing element (PE) to change. periodt. πŸ’…


✨ 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)

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 🌸

So shmem_wait and shmem_wait_until are out here waiting for ivar to get changed by a remote write or an atomic swap that some different processor pulled off. Basically it's point-to-point directed synchronization, and it's lowkey iconic for that.

shmem_wait does not come back until some other processor writes a value into ivar on the waiting processor that is not equal to cmp_value. shmem_wait_until does not come back until some other processor changes ivar so that the condition implied by cmp and cmp_value is satisfied. This whole mechanism is chef's kiss when a processor needs to tell another processor "hey, I finished the thing." πŸŽ€

the arguments (yes all of them)

  • target β€” the remotely accessible integer data object that gets updated on the remote PE. In C/C++, the type of target should match what the SYNOPSIS says. In Fortran, 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 what the SYNOPSIS says. In Fortran, it has to be of type integer with an element size of target.
  • pe β€” an integer that says which PE number target is to be updated on. In Fortran, it has to be a default integer value.
  • ivar β€” the remotely accessible integer variable that another PE is updating. In C/C++, the type of ivar should match what the SYNOPSIS says. In Fortran, ivar has to be a specific sized integer type depending on which function you're calling, like this:
    • 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 what the SYNOPSIS says. These are the cmp values that are supported:
    • 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 what the SYNOPSIS says. In Fortran, cmp_value must be an integer of the same size and kind as ivar. 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 with the cmp_value using the comparison operator, cmp.
not me listing target, value and pe up there when they're nowhere in the synopsis πŸ’€ bestie I promise I'm just giving you the page exactly as it is. the ones you'll actually be passing are the ivar / cmp / cmp_value girlies.

🌈 EXAMPLES 🌈

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

INTEGER*8 IVAR

CALL SHMEM_INT8_WAIT(IVAR, INT8(100))

Example 2: the following 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: the following 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: the following Fortran example is 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 πŸ¦‹


2003-2026, The Open MPI Community


and that's the whole vibe check, bestie β€” go forth and wait on your variables, they'll change eventually fr fr πŸ’œ

sooo this page is from the Open MPI manual, SHMEM_WAIT_UNTIL(3), and it's dated Sep 10, 2026. slay, bye βœ¨πŸŽ€πŸ’–

πŸ“¦ where this page comes from