Skip to content

Commit

Permalink
Revert "refactor gain computation for use by jet refiner"
Browse files Browse the repository at this point in the history
This reverts commit a972b3b.
  • Loading branch information
N-Maas committed Sep 7, 2023
1 parent ac76973 commit d4e6a0a
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ namespace mt_kahypar {

class CutGainComputation : public GainComputationBase<CutGainComputation, CutAttributedGains> {
using Base = GainComputationBase<CutGainComputation, CutAttributedGains>;
using RatingMap = typename Base::RatingMap;

static constexpr bool enable_heavy_assert = false;

public:
using RatingMap = typename Base::RatingMap;

CutGainComputation(const Context& context,
bool disable_randomization = false) :
Base(context, disable_randomization) { }
Expand Down
24 changes: 2 additions & 22 deletions mt-kahypar/partition/refinement/gains/gain_computation_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,6 @@ class GainComputationBase {
RatingMap& tmp_scores = _tmp_scores.local();
Gain& isolated_block_gain = _isolated_block_gain.local();
derived->precomputeGains(phg, hn, tmp_scores, isolated_block_gain, consider_non_adjacent_blocks);
Move best_move = computeMaxGainMoveForScores(phg, tmp_scores, isolated_block_gain, hn,
rebalance, consider_non_adjacent_blocks, allow_imbalance);

isolated_block_gain = 0;
tmp_scores.clear();
return best_move;
}

template<typename PartitionedHypergraph>
Move computeMaxGainMoveForScores(const PartitionedHypergraph& phg,
const RatingMap& tmp_scores,
const Gain isolated_block_gain,
const HypernodeID hn,
const bool rebalance = false,
const bool consider_non_adjacent_blocks = false,
const bool allow_imbalance = false) {
Derived* derived = static_cast<Derived*>(this);

PartitionID from = phg.partID(hn);
Move best_move { from, from, hn, rebalance ? std::numeric_limits<Gain>::max() : 0 };
Expand Down Expand Up @@ -137,18 +120,15 @@ class GainComputationBase {
}
}

isolated_block_gain = 0;
tmp_scores.clear();
return best_move;
}

inline void computeDeltaForHyperedge(const SynchronizedEdgeUpdate& sync_update) {
_deltas.local() += AttributedGains::gain(sync_update);
}

// ! Returns the local rating map for block scores
RatingMap& localScores() {
return _tmp_scores.local();
}

// ! Returns the delta in the objective function for all moves
// ! performed by the calling thread relative to the last call
// ! reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ namespace mt_kahypar {

class Km1GainComputation : public GainComputationBase<Km1GainComputation, Km1AttributedGains> {
using Base = GainComputationBase<Km1GainComputation, Km1AttributedGains>;
using RatingMap = typename Base::RatingMap;

static constexpr bool enable_heavy_assert = false;

public:
using RatingMap = typename Base::RatingMap;

Km1GainComputation(const Context& context,
bool disable_randomization = false) :
Base(context, disable_randomization) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ namespace mt_kahypar {

class SoedGainComputation : public GainComputationBase<SoedGainComputation, SoedAttributedGains> {
using Base = GainComputationBase<SoedGainComputation, SoedAttributedGains>;
using RatingMap = typename Base::RatingMap;

static constexpr bool enable_heavy_assert = false;

public:
using RatingMap = typename Base::RatingMap;

SoedGainComputation(const Context& context,
bool disable_randomization = false) :
Base(context, disable_randomization) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ namespace mt_kahypar {

class SteinerTreeGainComputation : public GainComputationBase<SteinerTreeGainComputation, SteinerTreeAttributedGains> {
using Base = GainComputationBase<SteinerTreeGainComputation, SteinerTreeAttributedGains>;
using RatingMap = typename Base::RatingMap;

static constexpr bool enable_heavy_assert = false;
static constexpr size_t BITS_PER_BLOCK = ds::StaticBitset::BITS_PER_BLOCK;

public:
using RatingMap = typename Base::RatingMap;

SteinerTreeGainComputation(const Context& context,
bool disable_randomization = false) :
Base(context, disable_randomization),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ namespace mt_kahypar {

class GraphSteinerTreeGainComputation : public GainComputationBase<GraphSteinerTreeGainComputation, GraphSteinerTreeAttributedGains> {
using Base = GainComputationBase<GraphSteinerTreeGainComputation, GraphSteinerTreeAttributedGains>;
using RatingMap = typename Base::RatingMap;

static constexpr bool enable_heavy_assert = false;
static constexpr size_t BITS_PER_BLOCK = ds::StaticBitset::BITS_PER_BLOCK;

public:
using RatingMap = typename Base::RatingMap;

GraphSteinerTreeGainComputation(const Context& context,
bool disable_randomization = false) :
Base(context, disable_randomization),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class RebalancerV2 final : public IRebalancer {
using GainCache = typename GainTypes::GainCache;
using GainCalculator = typename GainTypes::GainComputation;
using AttributedGains = typename GainTypes::AttributedGains;
using RatingMap = typename GainCalculator::RatingMap;

static constexpr bool debug = false;
static constexpr bool enable_heavy_assert = false;
Expand Down

0 comments on commit d4e6a0a

Please sign in to comment.