SHMEM_WAIT(3)
💖 SHMEM_WAIT(3) — Open MPI 💖
okay bestie, welcome to the Open MPI manual page for SHMEM_WAIT(3) — the whole wait-until-your-PE-friend-changes-something situation. It’s giving group-chat roll call for the wait family, and every single one is invited. 💅
✨ 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. periodt. 🫶
🌸 SYNOPSIS 🌸
C or C++:
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:
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 waiting for ivar to be changed by a remote write or atomic swap issued by a different processor. They’re for point-to-point directed synchronization, iykyk. 💫
A call to shmem_wait does not return until some other processor writes a value, not equal to cmp_value, into ivar on the waiting processor. A call to shmem_wait_until does not return until some other processor changes ivar to satisfy the condition implied by cmp and cmp_value. This mechanism is useful when a processor needs to tell another processor that it has completed some action. slay. 👑
🧸 The arguments, bestie 🧸
The arguments are as follows:
target— the remotely accessible integer data object to be updated on the remote PE. If you’re using C/C++, the type oftargetshould match what’s implied in the SYNOPSIS section. If you’re using the Fortran compiler, it must be of typeintegerwith 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 using C/C++, the type ofvalueshould match what’s implied in the SYNOPSIS section. If you’re using Fortran, it must be of typeintegerwith an element size oftarget.pe— an integer that indicates the PE number upon whichtargetis to be updated. If you’re using Fortran, it must be a default integer value.ivar— a remotely accessible integer variable that is being updated by another PE. If you’re using C/C++, the type ofivarshould match what’s implied in the SYNOPSIS section. If you’re using Fortran,ivarmust 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 comparesivarwithcmp_value.cmpmust be of typeinteger. If you’re using Fortran, it must be of default kind. If you’re using C/C++, the type ofcmpshould match what’s implied in the SYNOPSIS section. The followingcmpvalues 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— must be of typeinteger. If you’re using C/C++, the type ofcmp_valueshould match what’s implied in the SYNOPSIS section. If you’re using 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. The 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)
go read those next, bestie. no cap. 🦋
💖 okay that’s the whole page! source/version vibes: gitclone, Unreleased developer copy. date? the footer isn’t giving one, so no date to report — consider this your cute little sign-off. 🫶✨
📦 where this page comes from
- arch rolling: nvhpc-comm-libs 26.9-1 · LicenseRef-NVIDIA-HPC-SDK
- Copyright (c) 2015 University of Houston. All rights reserved
- Copyright (c) 2015 Mellanox Technologies, Inc
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms