2424#include " build_sb_graph.hpp"
2525#include " communication_cost.hpp"
2626#include " kernighan_lin_partitioner.hpp"
27+ #include " time_profiler.hpp"
2728#include " sbg_partitioner_log.hpp"
2829
2930
3031#define PARTITION_IMBALANCE_DEBUG 0
31- #define PARTITION_IMBALANCE_PROFILE 0
3232
3333
3434// This code is based on https://github.com/CIFASIS/sbg-partitioner/discussions/17
@@ -72,6 +72,7 @@ CostMatrixImbalance generate_gain_matrix(
7272 unsigned LMin,
7373 unsigned LMax)
7474{
75+ internal::TimeProfiler profiler (" generate_gain_matrix" );
7576 CostMatrixImbalance local_cost_matrix;
7677
7778 for (size_t i = 0 ; i < partition_a.size (); i++) {
@@ -178,6 +179,7 @@ void update_diff(
178179 unsigned LMin,
179180 unsigned LMax)
180181{
182+ internal::TimeProfiler profiler (" update_diff" );
181183 logging::sbg_log << affected_node_a.first << " , " << affected_node_a.second << endl;
182184 logging::sbg_log << affected_node_b.first << " , " << affected_node_b.second << endl;
183185
@@ -328,22 +330,14 @@ int kl_sbg_imbalance(
328330 Set b_v = graph.fact ().createSet ();
329331 const auto node_weights = graph.get_node_weights ();
330332
331- auto start_generate_gain_matrix = chrono::high_resolution_clock::now ();
332333 CostMatrixImbalance gm = generate_gain_matrix (graph, cost_matrix, partition_a_id, partition_a, partition_b_id, partition_b, LMin, LMax);
333- auto end_generate_gain_matrix = chrono::high_resolution_clock::now ();
334- auto time_to_generate_gain_matrix = chrono::duration<double , std::milli>(end_generate_gain_matrix - start_generate_gain_matrix).count ();
335- #if PARTITION_IMBALANCE_PROFILE
336- cout << " time_to_generate_gain_matrix: " << time_to_generate_gain_matrix << endl;
337- #endif
338-
339334
340335#if PARTITION_IMBALANCE_DEBUG
341336 logging::sbg_log << LMin << " , "
342337 << LMax
343338 << gm << endl;
344339#endif
345340
346- double time_to_update_diff = 0 .;
347341 while ((not a_c.empty ()) and (not b_c.empty ())) {
348342 logging::sbg_log << " inside the while " << a_c << " , " << b_c << " " ;
349343 logging::sbg_log << get_partition_size (a_c, node_weights, graph.fact ()) << " , " << get_partition_size (b_c, node_weights, graph.fact ()) << endl;
@@ -353,15 +347,9 @@ int kl_sbg_imbalance(
353347 logging::sbg_log << g << endl;
354348 pair<Set, Set> a_ = {graph.fact ().createSet (), graph.fact ().createSet ()}, b_ = {graph.fact ().createSet (), graph.fact ().createSet ()};
355349 tie (a_, b_) = update_sets (a_c, b_c, a_v, b_v, g, graph);
356- auto start_update_diff = chrono::high_resolution_clock::now ();
357350 update_diff (gm, a_c, a_v, a_, b_c, b_v, b_, graph, node_weights, g, LMin, LMax);
358- auto end_update_diff = chrono::high_resolution_clock::now ();
359- time_to_update_diff += chrono::duration<double , std::milli>(end_update_diff - start_update_diff).count ();
360351 update_sum (par_sum, g.gain , max_par_sum, max_par_sum_set, a_v, b_v);
361352 }
362- #if PARTITION_IMBALANCE_PROFILE
363- cout << " time_to_update_diff: " << time_to_update_diff << endl;
364- #endif
365353
366354 if (max_par_sum > 0 ) {
367355
0 commit comments