SHMEM_BARRIER(3)

πŸ’– SHMEM_BARRIER(3) β€” Open MPI πŸ’–

okay bestie, buckle up, we're doing a barrier today and it's giving synchronization royalty πŸ‘‘


✨ NAME ✨

shmem_barrier β€” Performs a barrier operation on a subset of processing elements (PEs). 🫢


🌸 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 πŸ¦‹

So like, shmem_barrier does not return until the little subset of PEs you picked out with PE_start, logPE_stride and PE_size has all rolled up into this routine at the exact same point of the execution path. no cap. everyone pulls up, then everyone leaves together. it's a group chat waiting for the last person to type "omw" πŸ’…

And fr fr, like every other SHMEM collective routine: it assumes that only the PEs in the active set call it. If a PE that is not in the active set calls a SHMEM collective routine, that's undefined behavior result. so don't do that πŸ™ˆ

The arguments are as follows:

  • PE_start β€” the lowest virtual PE number of the active set of PEs. PE_start must 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_stride must 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_size must be of type integer. If you're using Fortran, it must be a default integer value.
  • 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're 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. And the same work array has to be passed in pSync to all PEs in the active set. everyone on the same page or it's not happening πŸ’€

shmem_barrier makes sure that all the 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 is actually done-done before you keep going, not just "sent" 🌈

And the cute part: the same pSync array may be reused on consecutive calls to shmem_barrier if the same active PE set is used. recycling is iconic ♻️


πŸŽ€ NOTES πŸŽ€

The term symmetric is defined in 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(3) β€” before calling shmem_barrier for the first time. don't just wing it βœ‹

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. easy ✨


πŸ’œ 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) shmem_barrier_all(3)


2003-2026, The Open MPI Community


and that's the whole page bestie, you ate πŸ’…βœ¨ this was Open MPI's shmem_barrier(3), dated Sep 10, 2026 β€” go forth and synchronize responsibly, ily πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from