SHMEM_ALLTOALL64(3)
π SHMEM_ALLTOALL64(3) π
okay so welcome to the Open MPI corner of the man pages, bestie β today we're learning about the squad-wide data swap. Let's get into it β¨
πΈ NAME πΈ
shmem_alltoall32(3),shmem_alltoall64(3),shmem_alltoalls32(3),shmem_alltoalls64(3)β the collective routine where each PE exchanges a fixed amount of data with all the other PEs in the Active set π«Ά
β¨ SYNOPSIS β¨
C or C++
#include <mpp/shmem.h>
void shmem_alltoall32(void *target, const void *source,
size_t nelems, int PE_start, int logPE_stride,
int PE_size, long *pSync)
void shmem_alltoall64(void *target, const void *source,
size_t nelems, int PE_start, int logPE_stride,
int PE_size, long *pSync)
void shmem_alltoalls32(void *target, const void *source,
ptrdiff_t dst, ptrdiff_t sst,
size_t nelems, int PE_start, int logPE_stride,
int PE_size, long *pSync)
void shmem_alltoalls64(void *target, const void *source,
ptrdiff_t dst, ptrdiff_t sst,
size_t nelems, int PE_start, int logPE_stride,
int PE_size, long *pSync)
Fortran
INCLUDE "mpp/shmem.fh"
INTEGER dst, sst, nelems, PE_root, PE_start, logPE_stride, PE_size
INTEGER pSync(SHMEM_ALLTOALL_SYNC_SIZE)
CALL SHMEM_ALLTOALL32(target, source, nelems,
& PE_start, logPE_stride, PE_size, fIpSync)
CALL SHMEM_ALLTOALL64(target, source, nelems,
& PE_start, logPE_stride, PE_size, pSync)
CALL SHMEM_ALLTOALLS32(target, source, dst, sst, nelems,
& PE_start, logPE_stride, PE_size, pSync)
CALL SHMEM_ALLTOALLS64(target, source, dst, sst, nelems,
& PE_start, logPE_stride, PE_size, pSync)
π yes,fIpSyncin that firstCALLis exactly what's written in the original β copy it character for character, don't "fix" it, iykyk.
π¦ DESCRIPTION π¦
okay so the shmem_alltoalls routines are collective routines β meaning the whole squad moves together, no solo main character energy allowed. Every PE in the Active set exchanges nelems strided data elements of size 32 bits (for shmem_alltoalls32) or 64 bits (for shmem_alltoalls64) with all the other PEs in the set. π
Both strides, dst and sst, must be greater than or equal to 1. Not zero, not negative, periodt.
Here's the placement tea, write it down: the sst*jth block sent from PE i to PE j is placed in the dst*ith block of the dest data object on PE j. π
And like all OpenSHMEM collective routines, these assume that only PEs in the Active set call the routine. If a PE that is not in the Active set calls an OpenSHMEM collective routine, undefined behavior results β and not the fun kind of undefined, the π kind.
The values of arguments dst, sst, nelems, PE_start, logPE_stride, and PE_size must be equal on all PEs in the Active set. The same dest and source data objects, and the same pSync work array, must be passed to all PEs in the Active set. π
Before any PE calls to a shmem_alltoalls routine, the following conditions must 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 ashmem_alltoallsroutine. - The dest data object on all PEs in the Active set is ready to accept the
shmem_alltoallsdata.
Upon return from a shmem_alltoalls routine, the following is true for the local PE:
- Its dest symmetric data object is completely updated and the data has been copied out of the source data object.
- The values in the
pSyncarray are restored to the original values.
π§ the arguments, one by one π§
A symmetric data object with one of the following data types
shmem_alltoall32β any noncharacter type that has an element size of 32 bits. No Fortran derived types, no C/C++ structures. Hard no. πshmem_alltoall64β any noncharacter type that has an element size of 64 bits. No Fortran derived types, no C/C++ structures. Same energy. π
the actual parameter list
targetβ a symmetric data object large enough to receive the combined total ofnelemselements from each PE in the Active set. Big enough or it's not gonna slay.sourceβ a symmetric data object that containsnelemselements of data for each PE in the Active set, ordered according to destination PE.dstβ the stride between consecutive elements of the dest data object. The stride is scaled by the element size. A value of1indicates contiguous data.dstmust be of typeptrdiff_t. If you're using Fortran, it must be a default integer value.sstβ the stride between consecutive elements of the source data object. The stride is scaled by the element size. A value of1indicates contiguous data.sstmust be of typeptrdiff_t. If you're using Fortran, it must be a default integer value.nelemsβ the number of elements to exchange for each PE.nelemsmust be of typesize_tfor C/C++. 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_startmust be of typeinteger. 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.log_PE_stridemust be of typeinteger. 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 typeinteger. If you're using Fortran, it must be a default integer value.pSyncβ a symmetric work array. In C/C++,pSyncmust be of typelongand size_SHMEM_ALLTOALL_SYNC_SIZE. In Fortran,pSyncmust be of typeintegerand sizeSHMEM_ALLTOALL_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(). π§
Upon return from a shmem_alltoalls routine, the following is true for the local PE: its dest symmetric data object is completely updated and the data has been copied out of the source data object. The values in the pSync array are restored to the original values.
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.
Before any PE calls a alltoall 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 alltoall routine. - The
targetarray on all PEs in the active set is ready to accept the alltoall data.
π NOTES π
The terms collective and symmetric are defined in intro_shmem(3). Go read it, bestie, it's giving foundational. π
All SHMEM alltoall 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. β¨
β οΈ You must ensure the that thepSyncarray 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 thepSyncarray 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. - ApSyncarray 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 alltoall 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. Two icons, taking turns. ππ
π EXAMPLES π
C/C++ example, served fresh:
#include <shmem.h>
#include <stdio.h>
long pSync[SHMEM_ALLTOALL_SYNC_SIZE];
int main(void)
{
int64_t *source, *dest;
int i, count, pe;
shmem_init();
count = 2;
dest = (int64_t*) shmem_malloc(count * shmem_n_pes() * sizeof(int64_t));
source = (int64_t*) shmem_malloc(count * shmem_n_pes() * sizeof(int64_t));
/* assign source values */
for (pe=0; pe <shmem_n_pes(); pe++){
for (i=0; i<count; i++){
source[(pe*count)+i] = shmem_my_pe() + pe;
dest[(pe*count)+i] = 9999;
}
}
for (i=0; i< SHMEM_ALLTOALLS_SYNC_SIZE; i++) {
pSync[i] = SHMEM_SYNC_VALUE;
}
/* wait for all PEs to initialize pSync */
shmem_barrier_all();
/* alltoalls on all PES */
shmem_alltoalls64(dest, source, 1, 1, count, 0, 0, shmem_n_pes(), pSync);
/* verify results */
for (pe=0; pe<shmem_n_pes(); pe++) {
for (i=0; i<count; i++){
if (dest[(pe*count)+i] != shmem_my_pe() + pe) {
printf("[%d] ERROR: dest[%d]=%ld, should be %d,
shmem_my_pe(),(pe*count)+i,dest[(pe*count)+i],
shmem_n_pes() + pe);
}
}
}
shmem_barrier_all();
shmem_free(dest);
shmem_free(source);
shmem_finalize();
return 0;
}
π SEE ALSO π
intro_shmem(3)β go be educated, bestie π¦
β COPYRIGHT β
2003-2026, The Open MPI Community β iconic lineup, no cap π
and that's the whole page, bestie π«Ά this gem dropped May 14, 2026, straight from the Open MPI crew, and it's filed under SHMEM_ALLTOALL64(3) in your friendly neighbourhood manual section 3. go forth and alltoall 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