SHMEM_INT_WAIT(3)
π SHMEM_INT_WAIT(3) β Open MPI, but make it make sense π
okay bestie, so this one is a whole family of routines from Open MPI, all hanging out under one manpage roof. you ready? because there are like a million of them and they all do the same cute little thing: wait for a variable on your local processing element (PE) to change. π
β¨ NAME β¨
shmem_int_wait(3), shmem_int_wait(3)_until, shmem_int4_wait(3), shmem_int4_wait(3)_until, shmem_int8_wait(3), shmem_int8_wait(3)_until, shmem_long_wait(3), shmem_long_wait(3)_until, shmem_longlong_wait(3), shmem_longlong_wait(3)_until, shmem_short_wait(3), shmem_short_wait(3)_until, shmem_wait(3), shmem_wait(3)_until β Waits for a variable on the local processing element (PE) to change π¦
(yes, that's the whole squad. they're all here. no gatekeeping.)
πΈ 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 from a different processor. it's giving point-to-point directed synchronization, honestly. π
here's the vibe: a call to shmem_wait does not return until some other processor writes a value into ivar (on the waiting processor, obviously) that is not equal to cmp_value. and a call to shmem_wait_until does not return until some other processor changes ivar so it satisfies the condition implied by cmp and cmp_value. iconic behavior. this whole mechanism is useful when a processor needs to tell another processor that it has completed some action. friendship, but make it distributed. π«Ά
the arguments, bestie:
- target β The remotely accessible integer data object to be updated on the remote PE. If you are using C/C++, the type of target should match that implied in the SYNOPSIS section. If you are using the Fortran compiler, it must be of type integer with an element size of 4 bytes for
SHMEM_INT4_ADDand 8 bytes forSHMEM_INT8_ADD. - value β The value to be atomically added to target. If you are using C/C++, the type of value should match that implied in the SYNOPSIS section. If you are using Fortran, it must be of type integer with an element size of target.
- pe β An integer that indicates the PE number upon which target is to be updated. If you are using Fortran, it must be a default integer value.
- ivar β A remotely accessible integer variable that is being updated by another PE. If you are using C/C++, the type of ivar should match that implied in the SYNOPSIS section. If you are using Fortran, ivar must be a specific sized integer type according to the function being called, as follows:
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 ivar with cmp_value. cmp must be of type integer. If you are using Fortran, it must be of default kind. If you are using C/C++, the type of cmp should match that implied in the SYNOPSIS section. The following cmp values 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_value must be of type integer. If you are using C/C++, the type of cmp_value should match thatimplied in the SYNOPSIS section. If you are using Fortran, cmp_value must be an integer of the same size and kind as ivar. The
shmem_waitroutines return when ivar is no longer equal to cmp_value. Theshmem_wait_untilroutines return when the compare condition is true. The compare condition is defined by the ivar argument compared with the cmp_value using the comparison operator, cmp.
π real talk: these functions block. they do not come back until the condition is met. don't be out here calling them expecting a lil peek and a return, because that is not the assignment.
π₯ 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)
(yes go read those next, iykyk π)
π COPYRIGHT π
2003-2026, The Open MPI Community
and that's the whole page, bestie β go forth and synchronize responsibly. πβ¨π
signed, sealed, delivered by the Open MPI crew β source/version vibes: Open MPI, dated May 14, 2026 β mwah, catch you on the next manpage π¦π
π¦ where this page comes from
- arch rolling: nvhpc-comm-libs 26.9-1 Β· LicenseRef-NVIDIA-HPC-SDK
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms