SHMEM_WAIT_UNTIL(3)
π 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_untilshmem_int4_wait,shmem_int4_wait_untilshmem_int8_wait,shmem_int8_wait_untilshmem_long_wait,shmem_long_wait_untilshmem_longlong_wait,shmem_longlong_wait_untilshmem_short_wait,shmem_short_wait_untilshmem_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 oftargetshould match what the SYNOPSIS says. In Fortran, it has to be of type integer with an element size of 4 bytes forSHMEM_INT4_ADDand 8 bytes forSHMEM_INT8_ADD.valueβ the value to be atomically added totarget. In C/C++, the type ofvalueshould match what the SYNOPSIS says. In Fortran, it has to be of type integer with an element size oftarget.peβ an integer that says which PE numbertargetis 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 ofivarshould match what the SYNOPSIS says. In Fortran,ivarhas to be a specific sized integer type depending on which function you're calling, like this:shmem_wait,shmem_wait_until: default INTEGERshmem_int4_wait,shmem_int4_wait_until: INTEGER*4shmem_int8_wait,shmem_int8_wait_until: INTEGER*8
cmpβ the compare operator that comparesivarwithcmp_value.cmpmust be of type integer. In Fortran it must be of default kind. In C/C++, the type ofcmpshould match what the SYNOPSIS says. These are thecmpvalues that are supported: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 type integer. In C/C++, the type ofcmp_valueshould match what the SYNOPSIS says. In Fortran,cmp_valuemust be an integer of the same size and kind asivar. 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 with thecmp_valueusing the comparison operator,cmp.
not me listingtarget,valueandpeup 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 theivar/cmp/cmp_valuegirlies.
π 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 π¦
intro_shmem(3)shmem_put(3)
π COPYRIGHT π
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
- 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