SHMEM_WAIT(3)
π SHMEM_WAIT(3) β okay bestie, listen
Hi hi hiii π you just opened the Open MPI manual page for the whole shmem_wait family, and honestly? It's giving "I will sit here and wait patiently for you to text back" but make it a processor. πΈ
The full girlies in this crew are:
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 their whole job β their entire purpose, their moment, their slay β is described in the NAME section:
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 literally just sitting there, waiting for ivar to get changed by a remote write or an atomic swap issued by a different processor. That's the whole vibe check. π¦
These routines can be used for point-to-point directed synchronization β iykyk. And here's the tea:
- A call to
shmem_waitdoes not return until some other processor writes a value intoivaron the waiting processor, and that value is not equal tocmp_value. - A call to
shmem_wait_untildoes not return until some other processor changesivarto satisfy the condition implied bycmpandcmp_value.
This mechanism is useful when a processor needs to tell another processor that it has completed some action. π«Ά like a little "done!!" text but for PEs.
the arguments, bestie π
targetβ the remotely accessible integer data object to be updated on the remote PE. If you're on C/C++, the type oftargetshould match what the SYNOPSIS section implies. If you're using the Fortran compiler, it must 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. If you're on C/C++, the type ofvalueshould match what the SYNOPSIS section implies. If you're on Fortran, it must be of type integer with an element size oftarget.peβ an integer that indicates the PE number upon whichtargetis to be updated. If you're on Fortran, it must be a default integer value.ivarβ a remotely accessible integer variable that is being updated by another PE. If you're on C/C++, the type ofivarshould match what the SYNOPSIS section implies. If you're on Fortran,ivarmust be a specific-sized integer type according to the function being called, like so: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. If you're on Fortran, it must be default kind. If you're on C/C++, the type ofcmpshould match what the SYNOPSIS section implies. Here are the supportedcmpvalues, no cap: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β must be of type integer. If you're on C/C++, the type ofcmp_valueshould match that implied in the SYNOPSIS section. If you're on 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. π
πΈ 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
okay that's the whole page, you ate it, you read the whole thing, main character energy fr fr π quick sign-off though β this little number is from Sep 10, 2026, with source and version credit going to the Open MPI girlies and the copyright at the bottom reading 2003-2026, The Open MPI Community. now go forth and wait until your condition is true, bestie π¦πβ¨
π¦ 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