SHMEM_FCOLLECT32(3)
π SHMEM_FCOLLECT32 β Open MPI π
okay so bestie, you clicked on the Open MPI page for SHMEM_FCOLLECT32(3) and honestly? iconic choice. this is the whole collect squad, one big happy family:
shmem_collect4(3), shmem_collect8(3), shmem_collect32(3), shmem_collect64(3), shmem_fcollect(3), shmem_fcollect4(3), shmem_fcollect8(3), shmem_fcollect32(3), shmem_fcollect64(3)
and what do they all do? they concatenate blocks of data from multiple processing elements (PEs) to an array in every PE. literally every PE gets the whole group project. the way that's actually the point π«Ά
β¨ SYNOPSIS β¨
C or C++:
#include <mpp/shmem.h>
void shmem_collect32(void *target, const void *source,
size_t nelems, int PE_start, int logPE_stride, int PE_size,
long *pSync)
void shmem_collect64(void *target, const void *source,
size_t nelems, int PE_start, int logPE_stride, int PE_size,
long *pSync)
void shmem_fcollect32(void *target, const void *source,
size_t nelems, int PE_start, int logPE_stride, int PE_size,
long *pSync)
void shmem_fcollect64(void *target, const void *source,
size_t nelems, int PE_start, int logPE_stride, int PE_size,
long *pSync)
Fortran:
INCLUDE "mpp/shmem.fh"
INTEGER nelems
INTEGER PE_start, logPE_stride, PE_size
INTEGER pSync(SHMEM_COLLECT_SYNC_SIZE)
CALL SHMEM_COLLECT4(target, source, nelems, PE_start,
& logPE_stride, PE_size, pSync)
CALL SHMEM_COLLECT8(target, source, nelems, PE_start,
& logPE_stride, PE_size, pSync)
CALL SHMEM_FCOLLECT4(target, source, nelems, PE_start,
& logPE_stride, PE_size, pSync)
CALL SHMEM_FCOLLECT8(target, source, nelems, PE_start,
& logPE_stride, PE_size, pSync)
β¨ pick your fighter β¨
πΈ DESCRIPTION πΈ
okay so here's the tea π the SHMEM collect and fcollect routines take nelems of those 64-bit or 32-bit data items, pull them out of the source array, and smush them all together into the target array β across the set of PEs described by PE_start, log2PE_stride, and PE_size, in processor number order. so the final target array has PE PE_start's contribution first, then PE PE_start + PE_stride's contribution second, and so on and so on, forever and ever until the list runs out. and the collected result gets written into target for all PEs in the active set. no crumbs left behind, bestie π
the fcollect routines are the strict friend π they require that nelems be the same value in all participating PEs. the collect routines are the chill friend π¦ they allow nelems to vary from PE to PE.
the resulting target array looks like this:
----------------------------------------------------------
source(1..nelems)
from PE (PE_start + 0 * (2**logPE_stride))
----------------------------------------------------------
source(1..nelems)
from PE (PE_start + 1 * (2**logPE_stride))
----------------------------------------------------------
...
----------------------------------------------------------
source(1..nelems) from
PE (PE_start + (PE_size - 1) * (2**logPE_stride))
----------------------------------------------------------
like a lil layered cake π every tier labeled with exactly which PE brought the snack.
As with all SHMEM collective routines, each of these routines assumes that only PEs in the active set call the routine. and if a PE that is not in the active set calls a SHMEM collective routine? undefined behavior results. π so like. don't do that. fr fr.
π§ the arguments, one by one π§
targetβ A symmetric array. it HAS to be big enough to accept the concatenation of thesourcearrays on all PEs, no negotiating. The data types are as follows:[shmem_collect8, shmem_collect64, shmem_fcollect8, and shmem_fcollect64]β any data type with an element size of 64 bits. Fortran derived types, Fortran character type, and C/C++ structures are not permitted.[shmem_collect4, shmem_collect32, shmem_fcollect4, and shmem_fcollect32]β any data type with an element size of 32 bits. Fortran derived types, Fortran character type, and C/C++ structures are not permitted.
sourceβ A symmetric data object that can be of any type permissible for thetargetargument. so whatevertargetis allowed to be,sourceis too. besties matching π«Άnelemsβ The number of elements in thesourcearray.nelemsmust 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.logPE_stridemust be of type integer. If you are 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 are using Fortran, it must be a default integer value.pSyncβ A symmetric work array. In C/C++,pSyncmust be of typeintand size_SHMEM_COLLECT_SYNC_SIZE. In Fortran,pSyncmust be of typeintegerand sizeSHMEM_COLLECT_SYNC_SIZE. If you are using Fortran, it must be a default integer value. Every single element of this array must be initialized with the value_SHMEM_SYNC_VALUEin C/C++ orSHMEM_SYNC_VALUEin Fortran before any of the PEs in the active set entershmem_barrier(). yes, every one. no skipping, no vibes-based partial init π
ok important: the values of the argumentsPE_start,logPE_stride, andPE_sizemust be equal on all PEs in the active set. and the sametargetandsourcearrays and the samepSyncwork array must be passed to all PEs in the active set. everybody has to be on the same page, no freelancing β
Upon return from a collective routine, the following are true for the local PE: the target array is updated, and the values in the pSync array are restored to the original values. give it back the way you found it, queen π
π NOTES π
The terms collective and symmetric are defined in intro_shmem(3). go read that if you want the lore π
All SHMEM collective routines reset the values in pSync before they return, so a particular pSync buffer need only be initialized the first time it is used. one-time setup, then you're free β¨
You must ensure that the pSync array is not being updated on any PE in the active set while any of the PEs participate in processing of a SHMEM collective routine. Be careful to avoid these situations, bestie, I'm serious π€:
- 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 can be reused on a subsequent SHMEM collective routine only if none of the PEs in the active set are still processing a prior SHMEM collective routine call that used the samepSyncarray. In general, this may 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
pSyncarrays and alternate between them on successive calls. β cute lil double-buffer trick β
The collective routines operate on active PE sets that have a non-power-of-two PE_size with some performance degradation. But they operate with no performance degradation when nelems is a non-power-of-two value. so like, one of those is fine and the other one is gonna cost you π
π EXAMPLES π
C/C++:
for (i=0; i < _SHMEM_COLLECT_SYNC_SIZE; i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}
shmem_barrier_all(); /* Wait for all PEs to initialize pSync */
shmem_collect32(target, source, 64, pe_start, logPE_stride,
pe_size, pSync);
Fortran:
INTEGER PSYNC(SHMEM_COLLECT_SYNC_SIZE)
DATA PSYNC /SHMEM_COLLECT_SYNC_SIZE*SHMEM_SYNC_VALUE/
CALL SHMEM_COLLECT4(TARGET, SOURCE, 64, PE_START,
& LOGPE_STRIDE, PE_SIZE, PSYNC)
See also: intro_shmem(3)
π SEE ALSO π
intro_shmem(3)β the one and only, for all your collective and symmetric definitions π
Copyright
2003-2026, The Open MPI Community
and that's the whole page, bestie π go forth and concatenate. this was the Open MPI shmem_fcollect32(3) page, dated Sep 10, 2026 β mwah, stay synchronized, and don't forget to init your pSync β¨ππ§
π¦ 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