SHMEM\_LONG\_WAIT(3) Open MPI SHMEM\_LONG\_WAIT(3)

shmem\_int\_wait &lt;#shmem-int-wait&gt;(3), shmem\_int\_wait &lt;#shmem-int-wait&gt;(3)\_until, [shmem\_int4\_wait(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_int4_wait.3), [shmem\_int4\_wait(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_int4_wait.3)\_until, [shmem\_int8\_wait(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_int8_wait.3), [shmem\_int8\_wait(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_int8_wait.3)\_until, [shmem\_long\_wait(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_long_wait.3), [shmem\_long\_wait(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_long_wait.3)\_until, shmem\_longlong\_wait &lt;#shmem-longlong-wait&gt;(3), shmem\_longlong\_wait &lt;#shmem-longlong-wait&gt;(3)\_until, shmem\_short\_wait &lt;#shmem-short-wait&gt;(3), shmem\_short\_wait &lt;#shmem-short-wait&gt;(3)\_until, shmem\_wait &lt;#shmem-wait&gt;(3), shmem\_wait &lt;#shmem-wait&gt;(3)\_until - Waits for a variable on the local processing element (PE) to change

# [SYNOPSIS](#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](#DESCRIPTION)

shmem\_wait &lt;#shmem-wait&gt; and shmem\_wait\_until &lt;#shmem-wait-until&gt; wait for **ivar** to be changed by a remote write or atomic swap issued by a different processor. These routines can be used for point-to- point directed synchronization. A call to shmem\_wait &lt;#shmem-wait&gt; 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 &lt;#shmem-wait-until&gt; 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.

The arguments are as follows:

[**ivar**](#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 &lt;#shmem-wait&gt;, shmem\_wait\_until &lt;#shmem-wait-until&gt;:\** default INTEGER

shmem\_int4\_wait, shmem\_int4\_wait\_until:\** INTEGER\*4

shmem\_int8\_wait, shmem\_int8\_wait\_until:\** INTEGER\*8

[**cmp**](#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**](#SHMEM_CMP_EQ)

Equal

[**SHMEM\_CMP\_NE**](#SHMEM_CMP_NE)

Not equal

[**SHMEM\_CMP\_GT**](#SHMEM_CMP_GT)

Greater than

[**SHMEM\_CMP\_LE**](#SHMEM_CMP_LE)

Less than or equal to

[**SHMEM\_CMP\_LT**](#SHMEM_CMP_LT)

Less than

[**SHMEM\_CMP\_GE**](#SHMEM_CMP_GE)

Greater than or equal to

[**cmp\_value**](#cmp_value)

cmp\_value must be of type integer. If you are using C/C++, the type of cmp\_value should match that implied 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\_wait &lt;#shmem-wait&gt; routines return when ivar is no longer equal to cmp\_value. The shmem\_wait\_until &lt;#shmem-wait-until&gt; routines 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.

# [EXAMPLES](#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)](/man/enterprise-packages/openmpi-cuda-13.2/intro_shmem.3) [*shmem\_put*(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_put.3)

# [Copyright](#Copyright)

2003-2026, The Open MPI Community

October 9, 2026

---

Document: shmem_long_wait(3) from openmpi-cuda-13.2 5.0.11-r1 (Chainguard OS)
Source: https://github.com/open-mpi/ompi
