10 #ifndef _ZOLTAN2_ALGBLOCK_HPP_
11 #define _ZOLTAN2_ALGBLOCK_HPP_
55 template <
typename Adapter>
60 const RCP<const Environment> env;
61 const RCP<const Comm<int> > problemComm;
62 const RCP<const typename Adapter::base_adapter_t > adapter;
72 const RCP<const Environment> &env_,
73 const RCP<
const Comm<int> > &problemComm_,
74 const RCP<const typename Adapter::base_adapter_t > &adapter_
76 env(env_), problemComm(problemComm_), adapter(adapter_)
84 int rank = env->myRank_;
85 int nprocs = env->numProcs_;
97 ArrayView<const gno_t> idList;
99 ArrayView<input_t> wgtList;
104 bool uniformWeights = (wgtList.size() == 0);
111 const Teuchos::ParameterList &pl = env->getParameters();
112 const Teuchos::ParameterEntry *pe;
114 pe = pl.getEntryPtr(
"partitioning_objective");
116 std::string po = pe->getValue<std::string>(&po);
117 if (po == std::string(
"balance_object_count"))
118 uniformWeights =
true;
121 double imbalanceTolerance=1.1;
122 pe = pl.getEntryPtr(
"imbalance_tolerance");
123 if (pe) imbalanceTolerance = pe->getValue<
double>(&imbalanceTolerance);
129 size_t numGlobalParts = solution->getTargetGlobalNumberOfParts();
131 Array<scalar_t> part_sizes(numGlobalParts);
133 if (solution->criteriaHasUniformPartSizes(0))
134 for (
unsigned int i=0; i<numGlobalParts; i++)
135 part_sizes[i] = 1.0 / numGlobalParts;
137 for (
unsigned int i=0; i<numGlobalParts; i++)
138 part_sizes[i] = solution->getCriteriaPartSize(0, i);
140 for (
unsigned int i=1; i<numGlobalParts; i++)
141 part_sizes[i] += part_sizes[i-1];
156 if (!uniformWeights) {
157 for (
size_t i=0; i<numGnos; i++)
158 wtsum += wgtList[0][i];
161 wtsum =
static_cast<scalar_t>(numGnos);
163 Array<scalar_t> scansum(nprocs+1, 0);
165 Teuchos::gatherAll<int, scalar_t>(*problemComm, 1, &wtsum, nprocs,
166 scansum.getRawPtr()+1);
170 for (
int i=2; i<=nprocs; i++)
171 scansum[i] += scansum[i-1];
173 scalar_t globalTotalWeight = scansum[nprocs];
176 std::ostringstream oss(
"Part sizes: ");
177 for (
unsigned int i=0; i < numGlobalParts; i++)
178 oss << part_sizes[i] <<
" ";
179 oss << std::endl << std::endl <<
"Weights : ";
180 for (
int i=0; i <= nprocs; i++)
181 oss << scansum[i] <<
" ";
188 wtsum = scansum[rank];
189 Array<scalar_t> partTotal(numGlobalParts, 0);
190 ArrayRCP<part_t> gnoPart= arcp(
new part_t[numGnos], 0, numGnos);
192 env->memory(
"Block algorithm memory");
194 for (
size_t i=0; i<numGnos; i++){
195 scalar_t gnoWeight = (uniformWeights ? 1.0 : wgtList[0][i]);
199 while (
unsigned(part)<numGlobalParts-1 &&
200 (wtsum+0.5*gnoWeight) > part_sizes[part]*globalTotalWeight)
203 partTotal[part] += gnoWeight;
210 solution->setParts(gnoPart);
AlgBlock(const RCP< const Environment > &env_, const RCP< const Comm< int > > &problemComm_, const RCP< const typename Adapter::base_adapter_t > &adapter_)
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
map_t::global_ordinal_type gno_t
Defines the PartitioningSolution class.
sub-steps, each method's entry and exit
SparseMatrixAdapter_t::part_t part_t
Defines the IdentifierModel interface.
A PartitioningSolution is a solution to a partitioning problem.
Adapter::scalar_t scalar_t
The StridedData class manages lists of weights or coordinates.
Algorithm defines the base class for all algorithms.
map_t::local_ordinal_type lno_t
size_t getLocalNumIdentifiers() const
void partition(const RCP< PartitioningSolution< Adapter > > &solution)
Partitioning method.
IdentifierModel defines the interface for all identifier models.
include more detail about sub-steps
blockParams
The boolean parameters of interest to the Block algorithm.
size_t getIdentifierList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const