SHMEM_BROADCAST64(3)
π SHMEM_BROADCAST64(3) β the Open MPI girlies' guide to yeeting data from one PE to everybody π
okay bestie so this is the Open MPI manual page for shmem_broadcast4, shmem_broadcast8, shmem_broadcast32, and shmem_broadcast64. Four routines, one job: copy a data object from a designated PE to a target location on all the other PEs of the active set. that's it. that's the whole personality. π
β¨ NAME β¨
shmem_broadcast4(3), shmem_broadcast8(3), shmem_broadcast32(3), shmem_broadcast64(3) β Copy a data object from a designated PE to a target location on all other PEs of the active set. no cap. π«Ά
π¦ SYNOPSIS π¦
C or C++:
#include <mpp/shmem.h>
void shmem_broadcast32(void *target, const void *source,
size_t nelems, int PE_root, int PE_start, int logPE_stride,
int PE_size, long *pSync)
void shmem_broadcast64(void *target, const void *source,
size_t nelems, int PE_root, int PE_start, int logPE_stride,
int PE_size, long *pSync)
Fortran:
INCLUDE "mpp/shmem.fh"
INTEGER nelems, PE_root, PE_start, logPE_stride, PE_size
INTEGER pSync(SHMEM_BCAST_SYNC_SIZE)
CALL SHMEM_BROADCAST4(target, source, nelems, PE_root,
& PE_start, logPE_stride, PE_size, fIpSync)
CALL SHMEM_BROADCAST8(target, source, nelems, PE_root,
& PE_start, logPE_stride, PE_size, pSync)
CALL SHMEM_BROADCAST32(target, source, nelems,
& PE_root, PE_start, logPE_stride, PE_size, pSync)
CALL SHMEM_BROADCAST64(target, source, nelems,
& PE_root, PE_start, logPE_stride, PE_size, pSync)
πΈ DESCRIPTION πΈ
So here's the tea, bestie. The broadcast routines write the data at address source of the PE you picked with PE_root, and they write it to address target on all the other PEs in the active set. Your active set is defined by the iconic triplet: PE_start, logPE_stride and PE_size. π
IMPORTANT: the data is not copied to thetargetaddress on the PE specified byPE_root. the root PE stays unbothered. it's giving main character energy and honestly, valid. π
Before it returns, the broadcast routines make sure the elements of the pSync array are restored to their initial values. so pSync gets its glow back. β¨
And like all SHMEM collective routines, each of these assumes that only PEs in the active set call the routine. If a PE that is not in the active set calls a SHMEM collective routine, undefined behavior results. not a vibe. do not do that. π
The arguments are as follows:
targetβ A symmetric data object with one of the following data types:shmem_broadcast8,shmem_broadcast64: Any noncharacter type that has an element size of 64 bits. No Fortran derived types or C/C++ structures are allowed. π ββοΈshmem_broadcast32: Any noncharacter type that has an element size of 32 bits. No Fortran derived types or C/C++ structures are allowed.shmem_broadcast4: Any noncharacter type that has an element size of 32 bits.
sourceβ A symmetric data object that can be of any data type that is permissible for thetargetargument. twins fr fr. π«Άnelemsβ The number of elements insource. Forshmem_broadcast32andshmem_broadcast4, this is the number of 32-bit halfwords.nelemsmust be of type integer. If you are using Fortran, it must be a default integer value.PE_rootβ Zero-based ordinal of the PE, with respect to the active set, from which the data is copied. Must be greater than or equal to 0 and less thanPE_size.PE_rootmust be of type integer. If you are using Fortran, it must be a default integer value. β¨PE_startβ The lowest virtual PE number of the active set of PEs.PE_startmust be of type integer. If you are 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.log_PE_stridemust be of type integer. If you are using Fortran, it must be a default integer value. math girlies rise πPE_sizeβ The number of PEs in the active set.PE_sizemust be of type integer. If you are using Fortran, it must be a default integer value.pSyncβ A symmetric work array. In C/C++,pSyncmust be of typelongand size_SHMEM_BCAST_SYNC_SIZE. In Fortran,pSyncmust be of type integer and sizeSHMEM_BCAST_SYNC_SIZE. Every element of this array must be initialized with the value_SHMEM_SYNC_VALUE(in C/C++) orSHMEM_SYNC_VALUE(in Fortran) before any of the PEs in the active set entershmem_barrier(). yes, every single element. bestie I'm serious. π
The values of arguments PE_root, PE_start, logPE_stride, and PE_size must be equal on all PEs in the active set. The same target and source data objects and the same pSync work array must be passed to all PEs in the active set. it's giving matching outfits. coordinated. slay. π―ββοΈ
Before any PE calls a broadcast routine, you must ensure that the following conditions exist (synchronization via a barrier or some other method is often needed to ensure this):
- The
pSyncarray on all PEs in the active set is not still in use from a prior call to a broadcast routine. - The
targetarray on all PEs in the active set is ready to accept the broadcast data.
Upon return from a broadcast routine, the following are true for the local PE:
- If the current PE is not the root PE, the
targetdata object is updated. π - The values in the
pSyncarray are restored to the original values.
π NOTES π
The terms collective and symmetric are defined in intro_shmem(3). go read it, iykyk. π
All SHMEM broadcast routines restore pSync to its original contents. Multiple calls to SHMEM routines that use the same pSync array do not require that pSync be reinitialized after the first call. it just keeps working. iconic behavior. π
WARNING bestie: You must ensure that the pSync array is not being updated by any PE in the active set while any of the PEs participates in processing of a SHMEM broadcast routine.
Be careful to avoid these situations:
- If the
pSyncarray is initialized at run time, some type of synchronization is needed to ensure that all PEs in the working set have initializedpSyncbefore any of them enter a SHMEM routine called with thepSyncsynchronization array. - A
pSyncarray may be reused on a subsequent SHMEM broadcast routine only if none of the PEs in the active set are still processing a prior SHMEM broadcast routine call that used the samepSyncarray. In general, this can be ensured only by doing some type of synchronization.
However, in the special case of SHMEM routines being called with the same active set, you can allocate two pSync arrays and alternate between them on successive calls. the two-array switch-up. the rotation. π
π EXAMPLES π
In the following examples, the call to shmem_broadcast64 copies source on PE 4 to target on PEs 5, 6, and 7. yes, PE 4 is that girl. π
C/C++ example:
for (i=0; i < _SHMEM_BCAST_SYNC_SIZE; i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}
shmem_barrier_all(); /* Wait for all PEs to initialize pSync */
shmem_broadcast64(target, source, nelems, 0, 4, 0, 4, pSync);
Fortran example:
INTEGER PSYNC(SHMEM_BCAST_SYNC_SIZE)
INTEGER TARGET, SOURCE, NELEMS, PE_ROOT, PE_START,
& LOGPE_STRIDE, PE_SIZE, PSYNC
COMMON /COM/ TARGET, SOURCE
DATA PSYNC /SHMEM_BCAST_SYNC_SIZE*SHMEM_SYNC_VALUE/
CALL SHMEM_BROADCAST64(TARGET, SOURCE, NELEMS, 0, 4, 0, 4,
& PSYNC)
π SEE ALSO π
intro_shmem(3) π¦
π Copyright π
2003-2026, The Open MPI Community π
and that's the whole page bestie!! ππ«Ά this edition of the Open MPI manual page dropped on Sep 10, 2026, brought to you by the Open MPI girlies, and yes β SHMEM_BROADCAST64(3) is the moment. go broadcast something. slay. π
β¨π
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms