Skip to content

Commit

Permalink
timers
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Maas committed Sep 6, 2024
1 parent 70998eb commit b315892
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class MultilevelCoarsener : public ICoarsener,
const HypernodeID hierarchy_contraction_limit = hierarchyContractionLimit(current_hg);
NumNodesTracker num_nodes_tracker(current_hg.initialNumNodes() - current_hg.numRemovedHypernodes());
AlwaysAcceptPolicy similarity_policy(current_hg.initialNumNodes());
similarity_policy.initialize(current_hg, _context);
similarity_policy.initialize(current_hg, _context, _timer);
ClusteringContext<Hypergraph> cc(_context, hierarchy_contraction_limit, cluster_ids,
_rater, _clustering_data, num_nodes_tracker);
cc.initializeCoarseningPass(current_hg, _context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ class ThreePhaseCoarsener : public ICoarsener,
_rater, _clustering_data, _num_nodes_tracker);
cc.initializeCoarseningPass(current_hg, _context);
_timer.start_timer("init_similarity", "Initialize Similarity Data");
_similarity_policy.initialize(current_hg, _context);
_similarity_policy.initialize(current_hg, _context, _timer);
_timer.stop_timer("init_similarity");
_always_accept_policy.initialize(current_hg, _context);
_always_accept_policy.initialize(current_hg, _context, _timer);

bool did_two_hop = false;
bool did_second_lp = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "mt-kahypar/partition/context.h"
#include "mt-kahypar/datastructures/hypergraph_common.h"
#include "mt-kahypar/macros.h"
#include "mt-kahypar/utils/timer.h"

namespace mt_kahypar {

Expand All @@ -47,7 +48,7 @@ class AlwaysAcceptPolicy final : public kahypar::meta::PolicyBase {
explicit AlwaysAcceptPolicy(const HypernodeID) { }

template<typename Hypergraph>
void initialize(const Hypergraph&, const Context&) { }
void initialize(const Hypergraph&, const Context&, utils::Timer&) { }

template<typename Hypergraph>
MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE
Expand Down Expand Up @@ -146,7 +147,7 @@ class PreserveRebalancingNodesPolicy final : public kahypar::meta::PolicyBase {
PreserveRebalancingNodesPolicy & operator= (PreserveRebalancingNodesPolicy &&) = delete;

template<typename Hypergraph>
void initialize(const Hypergraph& hypergraph, const Context& context) {
void initialize(const Hypergraph& hypergraph, const Context& context, utils::Timer& timer) {
ASSERT(_incident_weight.size() >= hypergraph.initialNumNodes()
&& _acceptance_limit.size() >= hypergraph.initialNumNodes());

Expand All @@ -159,6 +160,7 @@ class PreserveRebalancingNodesPolicy final : public kahypar::meta::PolicyBase {
}
};

timer.start_timer("compute_incident_weight", "Compute Incident Weight");
// compute incident weights
hypergraph.doParallelForAllNodes([&](const HypernodeID hn) {
// TODO(maas): save the total incident weight in the hypergraph data structure?
Expand All @@ -168,6 +170,9 @@ class PreserveRebalancingNodesPolicy final : public kahypar::meta::PolicyBase {
}
_incident_weight[hn] = incident_weight_sum;
});
timer.stop_timer("compute_incident_weight");

timer.start_timer("compute_similarity_metric", "Compute Similarity Metric");
if constexpr (Hypergraph::is_graph) {
// TODO: We are ignoring edges between neighbors here - the result is thus only approximate.
// This could be acceptable, though
Expand Down Expand Up @@ -228,6 +233,7 @@ class PreserveRebalancingNodesPolicy final : public kahypar::meta::PolicyBase {
} else {
ERR("not supported");
}
timer.stop_timer("compute_similarity_metric");
}

// this function decides if contracting v onto u is allowed
Expand Down

0 comments on commit b315892

Please sign in to comment.