Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FM refactoring and compile times reduction #163

Merged
merged 23 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ba20ad8
reorder and print parameters for unconstrained
N-Maas Sep 28, 2023
43fe9c2
[FM refactoring] remove FM version running on shared partition
larsgottesbueren Sep 4, 2023
51bf28c
[FM refactoring] remove perform_moves_global parameter that is not re…
N-Maas Sep 28, 2023
844d18b
[FM refactoring] perform fixed vertex check slightly deepter --> halv…
larsgottesbueren Sep 4, 2023
fd90a3d
optimize FM neighbor acquiration for graphs
N-Maas Sep 7, 2023
23e86f4
proper initialization for rebalancer
N-Maas Sep 8, 2023
339128a
remove is_initialized flag from kway FM
N-Maas Sep 28, 2023
f896f86
fix warnings for redefined macros
N-Maas Sep 28, 2023
0a0d1d2
[compile time] disable ALWAYS_INLINE in debug mode
N-Maas Sep 8, 2023
b619cc9
[compile time] machinery for unfolding only valid type trait/gain com…
N-Maas Sep 12, 2023
957f6f3
[compile time] use reduced unfolding for refiners
N-Maas Sep 12, 2023
1dc5fa8
[compile time] move refinement/coarsening dispatchers to cpp files
N-Maas Oct 4, 2023
e2f3adb
deterministic -> combined traits
N-Maas Oct 4, 2023
3ac718b
[compile time] separate cpp file for register_initial_partitioning_al…
N-Maas Sep 14, 2023
5989fd1
[compile time] refactor greedy initial partitioner into base and subc…
N-Maas Sep 14, 2023
caa2192
[compile time] adjust compilation order to start expensive jobs first
N-Maas Sep 13, 2023
bb79985
refactor gain_cache_ptr
N-Maas Sep 14, 2023
3bdd8cf
[compile time] reduce templated code in deep multilevel
N-Maas Sep 14, 2023
d6d20ac
fix
N-Maas Sep 29, 2023
68ad081
rename CombinedTratis to GraphAndGainTypes
N-Maas Oct 4, 2023
c0c9358
move initial partitioner factory to factories.h
N-Maas Oct 4, 2023
4ca7bd2
remove FM stats
N-Maas Oct 4, 2023
f7fe3c6
fix test
N-Maas Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mt-kahypar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_subdirectory(partition)
add_subdirectory(datastructures)
add_subdirectory(io)
add_subdirectory(partition)
add_subdirectory(utils)

foreach(modtarget IN LISTS PARTITIONING_SUITE_TARGETS)
Expand Down
14 changes: 0 additions & 14 deletions mt-kahypar/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,13 @@ using TypeTraitsList = kahypar::meta::Typelist<StaticHypergraphTypeTraits
ENABLE_HIGHEST_QUALITY(template class C<DynamicPartitionedHypergraph>;) \
ENABLE_HIGHEST_QUALITY_FOR_GRAPHS(template class C<DynamicPartitionedGraph>;)

#define INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS(C) \
template class C(StaticHypergraphTypeTraits); \
ENABLE_GRAPHS(template class C(StaticGraphTypeTraits);) \
ENABLE_HIGHEST_QUALITY(template class C(DynamicHypergraphTypeTraits);) \
ENABLE_HIGHEST_QUALITY_FOR_GRAPHS(template class C(DynamicGraphTypeTraits);) \
ENABLE_LARGE_K(template class C(LargeKHypergraphTypeTraits);)

#define INSTANTIATE_CLASS_WITH_TYPE_TRAITS(C) \
template class C<StaticHypergraphTypeTraits>; \
ENABLE_GRAPHS(template class C<StaticGraphTypeTraits>;) \
ENABLE_HIGHEST_QUALITY(template class C<DynamicHypergraphTypeTraits>;) \
ENABLE_HIGHEST_QUALITY_FOR_GRAPHS(template class C<DynamicGraphTypeTraits>;) \
ENABLE_LARGE_K(template class C<LargeKHypergraphTypeTraits>;)

#define INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, Other) \
template class C(StaticHypergraphTypeTraits, Other); \
ENABLE_GRAPHS(template class C(StaticGraphTypeTraits, Other);) \
ENABLE_HIGHEST_QUALITY(template class C(DynamicHypergraphTypeTraits, Other);) \
ENABLE_HIGHEST_QUALITY_FOR_GRAPHS(template class C(DynamicGraphTypeTraits, Other);) \
ENABLE_LARGE_K(template class C(LargeKHypergraphTypeTraits, Other);)


using HighResClockTimepoint = std::chrono::time_point<std::chrono::high_resolution_clock>;

Expand Down
5 changes: 0 additions & 5 deletions mt-kahypar/io/command_line_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,6 @@ namespace mt_kahypar {
po::value<size_t>((initial_partitioning ? &context.initial_partitioning.refinement.fm.multitry_rounds :
&context.refinement.fm.multitry_rounds))->value_name("<size_t>")->default_value(10),
"Number of FM rounds within one level of the multilevel hierarchy.")
((initial_partitioning ? "i-r-fm-perform-moves-global" : "r-fm-perform-moves-global"),
po::value<bool>((initial_partitioning ? &context.initial_partitioning.refinement.fm.perform_moves_global :
&context.refinement.fm.perform_moves_global))->value_name("<bool>")->default_value(false),
"If true, then all moves performed during FM are immediately visible to other searches.\n"
"Otherwise, only move sequences that yield an improvement are applied to the global view of the partition.")
((initial_partitioning ? "i-r-fm-seed-nodes" : "r-fm-seed-nodes"),
po::value<size_t>((initial_partitioning ? &context.initial_partitioning.refinement.fm.num_seed_nodes :
&context.refinement.fm.num_seed_nodes))->value_name("<size_t>")->default_value(25),
Expand Down
1 change: 0 additions & 1 deletion mt-kahypar/io/sql_plottools_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ std::string serialize(const PartitionedHypergraph& hypergraph,
<< " sync_lp_use_active_node_set=" << context.refinement.deterministic_refinement.use_active_node_set;
oss << " fm_algorithm=" << context.refinement.fm.algorithm
<< " fm_multitry_rounds=" << context.refinement.fm.multitry_rounds
<< " fm_perform_moves_global=" << std::boolalpha << context.refinement.fm.perform_moves_global
<< " fm_rollback_parallel=" << std::boolalpha << context.refinement.fm.rollback_parallel
<< " fm_rollback_sensitive_to_num_moves=" << std::boolalpha << context.refinement.fm.iter_moves_on_recalc
<< " fm_rollback_balance_violation_factor=" << context.refinement.fm.rollback_balance_violation_factor
Expand Down
8 changes: 7 additions & 1 deletion mt-kahypar/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
template<bool T = EXPR> \
std::enable_if_t<!T, TYPE>

#if defined(__GNUC__) || defined(__clang__)
#if (defined(__GNUC__) || defined(__clang__)) && defined(NDEBUG)
#define MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline)) inline
#else
#define MT_KAHYPAR_ATTRIBUTE_ALWAYS_INLINE
Expand Down Expand Up @@ -121,6 +121,9 @@

// In windows unisgned long != size_t
#define UL(X) (size_t) X
#ifdef STR
#undef STR
#endif
#define STR(X) std::to_string(X)
#define STREAM2STR(X) static_cast<std::stringstream>(X).str();

Expand All @@ -133,6 +136,9 @@
#define BOLD "\033[1m"
#define END "\033[0m"
#define INFO(msg) LOG << CYAN << "[INFO]" << END << msg
#ifdef WARNING
#undef WARNING
#endif
#define WARNING(msg) LOG << YELLOW << "[WARNING]" << END << msg
#define ERR(msg) LOG << RED << "[ERROR]" << END << msg; std::exit(-1)

Expand Down
2 changes: 1 addition & 1 deletion mt-kahypar/partition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_subdirectory(mapping)
add_subdirectory(registries)

set(PartitionSources
deep_multilevel.cpp
partitioner.cpp
partitioner_facade.cpp
multilevel.cpp
Expand All @@ -14,7 +15,6 @@ set(PartitionSources
conversion.cpp
metrics.cpp
recursive_bipartitioning.cpp
deep_multilevel.cpp
)

foreach(modtarget IN LISTS PARTITIONING_SUITE_TARGETS)
Expand Down
4 changes: 4 additions & 0 deletions mt-kahypar/partition/coarsening/multilevel_uncoarsener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ namespace mt_kahypar {
improvement_found = false;
const HyperedgeWeight metric_before = _current_metrics.quality;

if ( _rebalancer && _context.refinement.rebalancer != RebalancingAlgorithm::do_nothing ) {
_rebalancer->initialize(phg);
}

if ( _label_propagation && _context.refinement.label_propagation.algorithm != LabelPropagationAlgorithm::do_nothing ) {
_timer.start_timer("initialize_lp_refiner", "Initialize LP Refiner");
_label_propagation->initialize(phg);
Expand Down
3 changes: 3 additions & 0 deletions mt-kahypar/partition/coarsening/nlevel_uncoarsener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ namespace mt_kahypar {
// Initialize Refiner
mt_kahypar_partitioned_hypergraph_t phg =
utils::partitioned_hg_cast(*_uncoarseningData.partitioned_hg);
if ( _rebalancer ) {
_rebalancer->initialize(phg);
}
if ( _label_propagation ) {
_label_propagation->initialize(phg);
}
Expand Down
1 change: 1 addition & 0 deletions mt-kahypar/partition/coarsening/nlevel_uncoarsener.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "mt-kahypar/partition/refinement/i_refiner.h"
#include "mt-kahypar/partition/coarsening/coarsening_commons.h"
#include "mt-kahypar/datastructures/streaming_vector.h"
#include "mt-kahypar/utils/progress_bar.h"

namespace mt_kahypar {

Expand Down
20 changes: 15 additions & 5 deletions mt-kahypar/partition/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ namespace mt_kahypar {
str << " Algorithm: " << params.algorithm << std::endl;
if ( params.algorithm != LabelPropagationAlgorithm::do_nothing ) {
str << " Maximum Iterations: " << params.maximum_iterations << std::endl;
str << " Unconstrained: " << std::boolalpha << params.unconstrained << std::endl;
str << " Rebalancing: " << std::boolalpha << params.rebalancing << std::endl;
str << " HE Size Activation Threshold: " << std::boolalpha << params.hyperedge_size_activation_threshold << std::endl;
str << " Relative Improvement Threshold: " << params.relative_improvement_threshold << std::endl;
}
return str;
}
Expand All @@ -134,7 +136,6 @@ namespace mt_kahypar {
out << " Algorithm: " << params.algorithm << std::endl;
if ( params.algorithm != FMAlgorithm::do_nothing ) {
out << " Multitry Rounds: " << params.multitry_rounds << std::endl;
out << " Perform Moves Globally: " << std::boolalpha << params.perform_moves_global << std::endl;
out << " Parallel Global Rollbacks: " << std::boolalpha << params.rollback_parallel << std::endl;
out << " Rollback Bal. Violation Factor: " << params.rollback_balance_violation_factor << std::endl;
out << " Num Seed Nodes: " << params.num_seed_nodes << std::endl;
Expand All @@ -144,6 +145,19 @@ namespace mt_kahypar {
out << " Release Nodes: " << std::boolalpha << params.release_nodes << std::endl;
out << " Time Limit Factor: " << params.time_limit_factor << std::endl;
}
if ( params.algorithm == FMAlgorithm::unconstrained_fm ) {
out << " Unconstrained Rounds: " << params.unconstrained_rounds << std::endl;
out << " Threshold Border Node Inclusion: " << params.treshold_border_node_inclusion << std::endl;
out << " Minimum Imbalance Penalty Factor: " << params.imbalance_penalty_min << std::endl;
out << " Maximum Imbalance Penalty Factor: " << params.imbalance_penalty_max << std::endl;
out << " Start Upper Bound for Unc.: " << params.unconstrained_upper_bound << std::endl;
out << " Final Upper Bound for Unc.: " << params.unconstrained_upper_bound_min << std::endl;
out << " Unc. Minimum Improvement Factor: " << params.unconstrained_min_improvement << std::endl;
out << " Activate Unc. Dynamically: " << std::boolalpha << params.activate_unconstrained_dynamically << std::endl;
if ( params.activate_unconstrained_dynamically ) {
out << " Penalty for Activation Test: " << params.penalty_for_activation_test << std::endl;
}
}
out << std::flush;
return out;
}
Expand Down Expand Up @@ -525,7 +539,6 @@ namespace mt_kahypar {
// initial partitioning -> refinement -> fm
initial_partitioning.refinement.fm.algorithm = FMAlgorithm::kway_fm;
initial_partitioning.refinement.fm.multitry_rounds = 5;
initial_partitioning.refinement.fm.perform_moves_global = false;
initial_partitioning.refinement.fm.rollback_parallel = true;
initial_partitioning.refinement.fm.rollback_balance_violation_factor = 1;
initial_partitioning.refinement.fm.num_seed_nodes = 25;
Expand Down Expand Up @@ -553,7 +566,6 @@ namespace mt_kahypar {
refinement.fm.algorithm = FMAlgorithm::unconstrained_fm;
refinement.fm.multitry_rounds = 10;
refinement.fm.unconstrained_rounds = 8;
refinement.fm.perform_moves_global = false;
refinement.fm.rollback_parallel = true;
refinement.fm.rollback_balance_violation_factor = 1.0;
refinement.fm.treshold_border_node_inclusion = 0.7;
Expand Down Expand Up @@ -756,7 +768,6 @@ namespace mt_kahypar {
// initial partitioning -> refinement -> fm
initial_partitioning.refinement.fm.algorithm = FMAlgorithm::kway_fm;
initial_partitioning.refinement.fm.multitry_rounds = 5;
initial_partitioning.refinement.fm.perform_moves_global = false;
initial_partitioning.refinement.fm.rollback_parallel = false;
initial_partitioning.refinement.fm.rollback_balance_violation_factor = 1;
initial_partitioning.refinement.fm.num_seed_nodes = 5;
Expand Down Expand Up @@ -786,7 +797,6 @@ namespace mt_kahypar {
// refinement -> fm
refinement.fm.algorithm = FMAlgorithm::kway_fm;
refinement.fm.multitry_rounds = 10;
refinement.fm.perform_moves_global = false;
refinement.fm.rollback_parallel = false;
refinement.fm.rollback_balance_violation_factor = 1.25;
refinement.fm.num_seed_nodes = 5;
Expand Down
10 changes: 4 additions & 6 deletions mt-kahypar/partition/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ std::ostream & operator<< (std::ostream& str, const CoarseningParameters& params
struct LabelPropagationParameters {
LabelPropagationAlgorithm algorithm = LabelPropagationAlgorithm::do_nothing;
size_t maximum_iterations = 1;
bool unconstrained = false;
bool rebalancing = true;
bool execute_sequential = false;
bool unconstrained = false;
size_t hyperedge_size_activation_threshold = std::numeric_limits<size_t>::max();
double relative_improvement_threshold = -1.0;
};
Expand All @@ -152,25 +152,23 @@ struct FMParameters {
double min_improvement = -1.0;
double time_limit_factor = std::numeric_limits<double>::max();

bool perform_moves_global = false;
bool rollback_parallel = true;
bool iter_moves_on_recalc = false;
bool shuffle = true;
mutable bool obey_minimal_parallelism = false;
bool release_nodes = true;

double treshold_border_node_inclusion = 0.75;
double unconstrained_upper_bound = 0.0;

// unconstrained
size_t unconstrained_rounds = 1;
double treshold_border_node_inclusion = 0.75;
double imbalance_penalty_min = 0.2;
double imbalance_penalty_max = 1.0;
double unconstrained_upper_bound = 0.0;
double unconstrained_upper_bound_min = 0.0;
double unconstrained_min_improvement = -1.0;

bool activate_unconstrained_dynamically = false;
double penalty_for_activation_test = 0.5;
double unconstrained_min_improvement = -1.0;
};

std::ostream& operator<<(std::ostream& out, const FMParameters& params);
Expand Down
Loading