14#ifndef _ZOLTAN2_PARTITIONINGHELPERS_HPP_
15#define _ZOLTAN2_PARTITIONINGHELPERS_HPP_
43template <
typename SolutionAdapter,
typename DataAdapter>
46 const DataAdapter *
const data,
47 ArrayRCP<typename DataAdapter::gno_t> &imports
56 if (numParts >
size_t(numProcs)) {
58 sprintf(msg,
"Number of parts %lu exceeds number of ranks %d; "
59 "%s requires a MappingSolution for this case\n",
60 numParts, numProcs, __func__);
61 throw std::logic_error(msg);
64 size_t localNumIds = data->getLocalNumIDs();
65 const typename DataAdapter::gno_t *gids = NULL;
66 data->getIDsView(gids);
71 Array<int> counts(numProcs, 0);
72 for (
size_t i=0; i < localNumIds; i++)
75 Array<gno_t> offsets(numProcs+1, 0);
76 for (
int i=1; i <= numProcs; i++){
77 offsets[i] = offsets[i-1] + counts[i-1];
80 Array<typename DataAdapter::gno_t> gidList(localNumIds);
81 for (
size_t i=0; i < localNumIds; i++) {
82 gno_t idx = offsets[parts[i]];
83 gidList[idx] = gids[i];
84 offsets[parts[i]] = idx + 1;
87 Array<int> recvCounts(numProcs, 0);
91 gidList(), counts(), imports, recvCounts());
95 return imports.size();
AlltoAll communication methods.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the PartitioningSolution class.
A PartitioningSolution is a solution to a partitioning problem.
size_t getActualGlobalNumberOfParts() const
Returns the actual global number of parts provided in setParts().
const RCP< const Environment > & getEnvironment() const
Return the environment associated with the solution.
const part_t * getPartListView() const
Returns the part list corresponding to the global ID list.
const RCP< const Comm< int > > & getCommunicator() const
Return the communicator associated with the solution.
Created by mbenlioglu on Aug 31, 2020.
size_t getImportList(const PartitioningSolution< SolutionAdapter > &solution, const DataAdapter *const data, ArrayRCP< typename DataAdapter::gno_t > &imports)
From a PartitioningSolution, get a list of IDs to be imported. Assumes part numbers in PartitioningSo...
void AlltoAllv(const Comm< int > &comm, const Environment &env, const ArrayView< const std::string > &sendBuf, const ArrayView< const int > &sendCount, ArrayRCP< std::string > &recvBuf, const ArrayView< int > &recvCount)