1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_UTIL_GATHER_ALL_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_UTIL_GATHER_ALL_H
3#include <molpro/linalg/array/util/Distribution.h>
18 MPI_Comm_size(commun, &nproc);
19 MPI_Comm_rank(commun, &mpi_rank);
20 std::vector<int> chunks(nproc), displs(nproc);
21 for (
int i = 0; i < nproc; i++) {
22 displs[i] = distr.
range(i).first;
23 chunks[i] = distr.
range(i).second - distr.
range(i).first;
25 MPI_Allgatherv(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, first_elem, chunks.data(), displs.data(), MPI_DOUBLE, commun);
Specifies distribution of a contiguous array into non-overlapping chunks.
Definition: Distribution.h:16
std::pair< index_type, index_type > range(int chunk) const
Returns [fist, end) indices for section of array assigned to chunk.
Definition: Distribution.h:64
Definition: ArrayHandler.h:23
void gather_all(const Distribution< size_t > &distr, MPI_Comm commun, double *first_elem)
Replicate data of a full container on all the processes based on distributed pieces.
Definition: gather_all.h:16