SHMEM_COLLECT64(3)

πŸ“¦
version 5.0.10 Β· 4 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

SHMEM_COLLECT64 from the Open MPI manuals, section 3 β€” and bestie, she brought her whole friend group. This one page covers:

  • shmem_collect4
  • shmem_collect8
  • shmem_collect32
  • shmem_collect64
  • shmem_fcollect
  • shmem_fcollect4
  • shmem_fcollect8
  • shmem_fcollect32
  • shmem_fcollect64

and they're all here to do one iconic thing: concatenate blocks of data from multiple processing elements (PEs) into an array in every PE. That's it. That's the job. πŸ‘‘

ok so three of the names in the original page came with these lil link-ghost artifacts stuck to them: shmem_collect32 <#shmem-collect32>, shmem_fcollect32 <#shmem-fcollect32>, and shmem_fcollect64 <#shmem-fcollect64>. Not me preserving them for posterity 🫢 nothing goes missing on my watch.

✨ 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)

🌈 DESCRIPTION 🌈

So like, the SHMEM collect and fcollect routines take nelems 64-bit or 32-bit data items from the source array and concatenate them into the target array, across the set of PEs defined by PE_start, log2PE_stride, and PE_size, in processor number order. The resulting target array holds the contribution from PE PE_start first, then the contribution from PE PE_start + PE_stride second, and so on down the line. The collected result gets written to the target array for every PE in the active set. everyone eats, no crumbs left behind πŸ’…

The fcollect routines require that nelems be the same value in all participating PEs, while the collect routines are chill and let nelems vary from PE to PE.

The resulting target array looks like this, and yes it's giving spreadsheet but make it fashion:

----------------------------------------------------------
   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))
----------------------------------------------------------

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. so like, don't do that, bestie, that's the villain origin story 😭


πŸŽ€ the arguments (aka the cast)

  • target β€” a symmetric array. It has to be large enough to accept the concatenation of the source arrays on all PEs. The data types go like this:
    • [shmem_collect8, shmem_collect64, shmem_fcollect8, and shmem_fcollect64]</italic> 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 the target argument.
  • nelems β€” the number of elements in the source array. nelems must be of type integer. If you're using Fortran, it must be a default integer value.
  • 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_COLLECT_SYNC_SIZE. In Fortran, pSync must be of type integer and size SHMEM_COLLECT_SYNC_SIZE. If you're using Fortran, it must be a default integer value. Every single element of this array must be initialized with the value _SHMEM_SYNC_VALUE in C/C++ or SHMEM_SYNC_VALUE in Fortran before any of the PEs in the active set enter shmem_barrier(). fr fr, every element, don't skip one πŸ™ˆ

The values of PE_start, logPE_stride, and PE_size must be equal on all PEs in the active set. The same target and source arrays and the same pSync work array must be passed to all PEs in the active set. like, matching fits only, no mismatched energy here πŸ¦‹

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. she cleans up after herself, we love a tidy queen ✨


πŸ’€ NOTES πŸ’€

The terms collective and symmetric are defined in intro_shmem(3). All SHMEM collective routines reset the values in pSync before they return, so a particular pSync buffer only needs to be initialized the first time it's used. one and done, so efficient πŸ’…

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 (this is the part where you pay attention πŸ‘€):

  • If the pSync array is initialized at run time, some type of synchronization is needed to ensure that all PEs in the working set have initialized pSync before any of them enter a SHMEM routine called with the pSync synchronization array.
  • A pSync array 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 same pSync array.
  • In general, this may be ensured only by doing some type of synchronization.

However β€” plot twist, a good one 🌸 β€” 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. main character problem-solving right there.

The collective routines operate on active PE sets that have a non-power-of-two PE_size with some performance degradation. They operate with no performance degradation when nelems is a non-power-of-two value. so the vibes are: weird nelems? fine. weird PE_size? fine but she's gonna take a lil longer to get ready 😭


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


2003-2026, The Open MPI Community


ok bestie that's the whole page πŸ’– go forth and concatenate responsibly. this page is from the Open MPI set, page SHMEM_COLLECT64(3), and its date stamp says Sep 10, 2026 β€” yes, she's dated in the future, she's just that ahead of her time ✨🫢🌸

πŸ“¦ where this page comes from