SHMEM_BARRIER(3)
π SHMEM_BARRIER(3) β the Open MPI glow-up
okay bestie, welcome to Open MPI, and welcome to shmem_barrier β the routine that does a barrier operation on a subset of processing elements (PEs). yes, a subset. not the whole world. we're being selective. iconic behavior honestly π
β¨ 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 πΈ
okay so here's the whole vibe: shmem_barrier does not return until that subset of PEs you specified with PE_start, logPE_stride and PE_size has all entered this routine at the same point of the execution path. it's giving "we don't move until everyone's here." main character meetup energy π
and like all SHMEM collective routines, each one of these routines assumes that only PEs in the active set call it. if a PE that is not in the active set calls a SHMEM collective routine?? undefined behavior. no cap. π©
the arguments, bestie, are as follows:
PE_startβ the lowest virtual PE number of the active set of PEs.PE_startmust be of type integer. if you're using Fortran, it must be a default integer value.logPE_strideβ the log (base 2) of the stride between consecutive virtual PE numbers in the active set.logPE_stridemust be of type integer. if you're using Fortran, it must be a default integer value.PE_sizeβ the number of PEs in the active set.PE_sizemust be of type integer. if you're using Fortran, it must be a default integer value.pSyncβ a symmetric work array. in C/C++,pSyncmust be of typeintand size_SHMEM_BARRIER_SYNC_SIZE. in Fortran,pSyncmust be of type integer and sizeSHMEM_BARRIER_SYNC_SIZE. if you're using Fortran, it must be a default integer type. every element of this array must be initialized to0before any of the PEs in the active set entershmem_barrierthe first time. don't skip this. seriously. π«Ά
the values of the arguments PE_start, logPE_stride, and PE_size must be equal on all PEs in the active set. and the same work array must be passed in pSync to all PEs in the active set. matchy-matchy or it doesn't work, periodt.
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)) are complete before returning. so likeβ¦ everything's actually done done. not "sent and vibing in transit." done. β¨
and the same pSync array may be reused on consecutive calls to shmem_barrier if the same active PE set is used. free real estate, bestie π
π¦ NOTES π¦
- the term symmetric is defined in
intro_shmem(3). go read it, it's right there. - if the
pSyncarray is initialized at run time, be sure to use some type of synchronization, for example, a call toshmem_barrier_all(3), before callingshmem_barrierfor the first time. this is the "text them before you show up" of collective routines π - if the active set does not change,
shmem_barriercan be called repeatedly with the samepSyncarray. no additional synchronization beyond that implied byshmem_barrieritself is necessary in this case. lowkey convenient, we love a routine that doesn't make us do extra work π
π 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? DATA PSYNC /SHMEM_BARRIER_SYNC_SIZE*0/ β that's the zero-init we were yelling about. ate. π
π₯ SEE ALSO π₯
π COPYRIGHT π
copyright 2003-2026, The Open MPI Community. respect the elders π«Ά
okay that's the whole page, bestie β brought to you by Open MPI, version dated May 14, 2026. now go forth and synchronize responsibly. πβ¨ππ¦
π¦ 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