SHMEM\_BARRIER(3) Open MPI SHMEM\_BARRIER(3)

shmem\_barrier - Performs a barrier operation on a subset of processing elements (PEs).

# [SYNOPSIS](#SYNOPSIS)

C or C++:

```
#include <mpp/shmem.h>
void shmem_barrier(int PE_start, int logPE_stride, int PE_size,


  long *pSync)
```

Fortran:

```
INCLUDE "mpp/shmem.fh"
INTEGER PE_start, logPE_stride, PE_size
INTEGER pSync(SHMEM_BARRIER_SYNC_SIZE)
CALL SHMEM_BARRIER(PE_start, logPE_stride, PE_size, pSync)
```

# [DESCRIPTION](#DESCRIPTION)

The shmem\_barrier routine does not return until the subset of PEs specified by **PE\_start**, **logPE\_stride** and **PE\_size**, has entered this routine at the same point of the execution path.

As with all SHMEM collective routines, each of these routines assumes that only PEs in the active set call the routine. If a PE not in the active set calls a SHMEM collective routine, undefined behavior results.

The arguments are as follows:

[**PE\_start**](#PE_start)

The lowest virtual PE number of the active set of PEs. PE\_start must be of type integer. If you are using Fortran, it must be a default integer value.

[**logPE\_stride**](#logPE_stride)

The log (base 2) of the stride between consecutive virtual PE numbers in the active set. logPE\_stride must be of type integer. If you are using Fortran, it must be a default integer value.

[**PE\_size**](#PE_size)

The number of PEs in the active set. PE\_size must be of type integer. If you are using Fortran, it must be a default integer value.

[**pSync**](#pSync)

A symmetric work array. In C/C++, pSync must be of type int and size \_SHMEM\_BARRIER\_SYNC\_SIZE. In Fortran, pSync must be of type integer and size SHMEM\_BARRIER\_SYNC\_SIZE. If you are using Fortran, it must be a default integer type. Every element of this array must be initialized to 0 before any of the PEs in the active set enter shmem\_barrier the first time.

The values of arguments PE\_start, logPE\_stride, and PE\_size must be equal on all PEs in the active set. The same work array must be passed in pSync to all PEs in the active set.

shmem\_barrier ensures that all previously issued local stores and previously issued remote memory updates done by any of the PEs in the active set (by using SHMEM calls, for example [shmem\_put(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_put.3)) are complete before returning.

The same pSync array may be reused on consecutive calls to shmem\_barrier if the same active PE set is used.

# [NOTES](#NOTES)

The term symmetric is defined in [*intro\_shmem*(3)](/man/enterprise-packages/openmpi-cuda-13.2/intro_shmem.3).

If the pSync array is initialized at run time, be sure to use some type of synchronization, for example, a call to shmem\_barrier\_all &lt;#shmem-barrier-all&gt;(3), before calling shmem\_barrier for the first time.

If the active set does not change, shmem\_barrier can be called repeatedly with the same pSync array. No additional synchronization beyond that implied by shmem\_barrier itself is necessary in this case.

# [EXAMPLES](#EXAMPLES)

C/C++ example:

```
shmem_barrier(PE_start, logPE_stride, size, pSync);
```

Fortran example:

```
INTEGER PSYNC(SHMEM_BARRIER_SYNC_SIZE)
INTEGER PE_START, LOGPE_STRIDE, PE_SIZE, PSYNC
DATA PSYNC /SHMEM_BARRIER_SYNC_SIZE*0/
CALL SHMEM_BARRIER(PE_START, LOGPE_STRIDE, PE_SIZE, PSYNC)
```

**See also:**

[*intro\_shmem*(3)](/man/enterprise-packages/openmpi-cuda-13.2/intro_shmem.3) [*shmem\_barrier\_all*(3)](/man/enterprise-packages/openmpi-cuda-13.2/shmem_barrier_all.3)

# [Copyright](#Copyright)

2003-2026, The Open MPI Community

October 9, 2026

---

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