SHMEM_SHORT_WAIT_UNTIL(3)
π 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_waitwill not return until some other processor writes a value intoivaron the waiting processor that is not equal tocmp_value. - A call to
shmem_wait_untilwill not return until some other processor changesivarso that it satisfies the condition implied bycmpandcmp_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
targetshould match whatever the SYNOPSIS says. If you're on a Fortran compiler, it has to be of typeintegerwith an element size of 4 bytes forSHMEM_INT4_ADDand 8 bytes forSHMEM_INT8_ADD. - value β The value to be atomically added to
target. In C/C++, the type ofvalueshould match whatever the SYNOPSIS says. In Fortran, it must be of typeintegerwith an element size oftarget. - pe β An integer that says which PE number
targetis going to be updated on. In Fortran, it must be a defaultintegervalue. - ivar β A remotely accessible integer variable that's being updated by another PE. In C/C++, the type of
ivarshould match whatever the SYNOPSIS says. In Fortran,ivarmust be a specific sized integer type depending on which function you're calling, like so:shmem_wait,shmem_wait_until: defaultINTEGERshmem_int4_wait,shmem_int4_wait_until:INTEGER*4shmem_int8_wait,shmem_int8_wait_until:INTEGER*8
- cmp β The compare operator that compares
ivarwithcmp_value.cmpmust be of typeinteger. In Fortran it must be of default kind. In C/C++ the type ofcmpshould match whatever the SYNOPSIS says. These are thecmpvalues you get to pick from, and yes you have options, we love a menu π :SHMEM_CMP_EQβ EqualSHMEM_CMP_NEβ Not equalSHMEM_CMP_GTβ Greater thanSHMEM_CMP_LEβ Less than or equal toSHMEM_CMP_LTβ Less thanSHMEM_CMP_GEβ Greater than or equal to
- cmp_value β
cmp_valuemust be of typeinteger. In C/C++, the type ofcmp_valueshould match whatever the SYNOPSIS says. In Fortran,cmp_valuemust be an integer of the same size and kind asivar. Here's the rule, bestie, write it down: theshmem_waitroutines return whenivaris no longer equal tocmp_value. Theshmem_wait_untilroutines return when the compare condition is true. And that compare condition is defined by theivarargument compared againstcmp_valueusing 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)
π Copyright π
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
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms