Skip to content

Commit

Permalink
Revert "add cmake compile flag for disabling cut metric"
Browse files Browse the repository at this point in the history
This reverts commit 222113d.
  • Loading branch information
kittobi1992 committed Jul 20, 2023
1 parent 222113d commit 46646b6
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/branch_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
rm -rf build
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DKAHYPAR_CI_BUILD=ON -DKAHYPAR_ENABLE_CUT_METRIC=OFF -DKAHYPAR_ENABLE_SOED_METRIC=OFF -DKAHYPAR_ENABLE_STEINER_TREE_METRIC=OFF -DKAHYPAR_ENABLE_GRAPH_PARTITIONING_FEATURES=OFF -DKAHYPAR_ENABLE_QUALITY_PRESET_FEATURES=OFF -DKAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES=OFF
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DKAHYPAR_CI_BUILD=ON -DKAHYPAR_ENABLE_STEINER_TREE_METRIC=OFF -DKAHYPAR_ENABLE_GRAPH_PARTITIONING_FEATURES=OFF -DKAHYPAR_ENABLE_QUALITY_PRESET_FEATURES=OFF -DKAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES=OFF
make -j2 MtKaHyPar
mt_kahypar_test_suite:
Expand All @@ -63,7 +63,7 @@ jobs:
rm -rf build
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DKAHYPAR_USE_GCOV=ON -DKAHYPAR_CI_BUILD=ON -DKAHYPAR_ENABLE_CUT_METRIC=OFF -DKAHYPAR_ENABLE_SOED_METRIC=OFF -DKAHYPAR_ENABLE_STEINER_TREE_METRIC=OFF -DKAHYPAR_ENABLE_GRAPH_PARTITIONING_FEATURES=OFF -DKAHYPAR_ENABLE_QUALITY_PRESET_FEATURES=OFF -DKAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES=OFF
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DKAHYPAR_USE_GCOV=ON -DKAHYPAR_CI_BUILD=ON -DKAHYPAR_ENABLE_STEINER_TREE_METRIC=OFF -DKAHYPAR_ENABLE_GRAPH_PARTITIONING_FEATURES=OFF -DKAHYPAR_ENABLE_QUALITY_PRESET_FEATURES=OFF -DKAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES=OFF
make -j2 mt_kahypar_tests;
- name: Run Mt-KaHyPar Tests
Expand Down
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ option(KAHYPAR_ENABLE_QUALITY_PRESET_FEATURES
option(KAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES
"Enables large k partitioning features. Can be turned off for faster compilation." ON)

option(KAHYPAR_ENABLE_CUT_METRIC
"Enables the cut metric. Can be turned off for faster compilation." ON)

option(KAHYPAR_ENABLE_SOED_METRIC
"Enables the sum-of-external-degree metric. Can be turned off for faster compilation." ON)

Expand Down Expand Up @@ -131,10 +128,6 @@ if(KAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES)
add_compile_definitions(KAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES)
endif(KAHYPAR_ENABLE_LARGE_K_PARTITIONING_FEATURES)

if(KAHYPAR_ENABLE_CUT_METRIC)
add_compile_definitions(KAHYPAR_ENABLE_CUT_METRIC)
endif(KAHYPAR_ENABLE_CUT_METRIC)

if(KAHYPAR_ENABLE_SOED_METRIC)
add_compile_definitions(KAHYPAR_ENABLE_SOED_METRIC)
endif(KAHYPAR_ENABLE_SOED_METRIC)
Expand Down
6 changes: 0 additions & 6 deletions mt-kahypar/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@
#define ENABLE_QUALITY_PRESET_FOR_GRAPHS(X)
#endif

#ifdef KAHYPAR_ENABLE_CUT_METRIC
#define ENABLE_CUT(X) X
#else
#define ENABLE_CUT(X)
#endif

#ifdef KAHYPAR_ENABLE_SOED_METRIC
#define ENABLE_SOED(X) X
#else
Expand Down
7 changes: 0 additions & 7 deletions mt-kahypar/partition/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,6 @@ namespace mt_kahypar {
}

void Context::setupGainPolicy() {
#ifndef KAHYPAR_ENABLE_CUT_METRIC
if ( partition.objective == Objective::cut ) {
ERR("Cut metric is deactivated. Add -DKAHYPAR_ENABLE_CUT_METRIC=ON"
<< "to the cmake command and rebuild Mt-KaHyPar.");
}
#endif

#ifndef KAHYPAR_ENABLE_SOED_METRIC
if ( partition.objective == Objective::soed ) {
ERR("SOED metric is deactivated. Add -DKAHYPAR_ENABLE_SOED_METRIC=ON"
Expand Down
2 changes: 0 additions & 2 deletions mt-kahypar/partition/deep_multilevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,10 @@ void bipartition_each_block(typename TypeTraits::PartitionedHypergraph& partitio
const HyperedgeWeight current_objective,
const bool progress_bar_enabled) {
switch(gain_cache.type) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut:
bipartition_each_block<TypeTraits>(partitioned_hg, context,
GainCachePtr::cast<CutGainCache>(gain_cache), info, rb_tree,
already_cut, current_k, current_objective, progress_bar_enabled); break;
#endif
case GainPolicy::km1:
bipartition_each_block<TypeTraits>(partitioned_hg, context,
GainCachePtr::cast<Km1GainCache>(gain_cache), info, rb_tree,
Expand Down
5 changes: 1 addition & 4 deletions mt-kahypar/partition/refinement/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ set(SteinerTreeGraphSources
foreach(modtarget IN LISTS PARTITIONING_SUITE_TARGETS)
target_sources(${modtarget} PRIVATE ${RefinementSources})
target_sources(${modtarget} PRIVATE ${Km1Sources})

if ( KAHYPAR_ENABLE_CUT_METRIC )
target_sources(${modtarget} PRIVATE ${CutSources})
endif()
target_sources(${modtarget} PRIVATE ${CutSources})

if ( KAHYPAR_ENABLE_SOED_METRIC )
target_sources(${modtarget} PRIVATE ${SoedSources})
Expand Down
18 changes: 0 additions & 18 deletions mt-kahypar/partition/refinement/gains/gain_cache_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@
#include "mt-kahypar/partition/context_enum_classes.h"
#include "mt-kahypar/datastructures/hypergraph_common.h"
#include "mt-kahypar/partition/refinement/gains/km1/km1_gain_cache.h"
#ifdef KAHYPAR_ENABLE_CUT_METRIC
#include "mt-kahypar/partition/refinement/gains/cut/cut_gain_cache.h"
#endif
#ifdef KAHYPAR_ENABLE_SOED_METRIC
#include "mt-kahypar/partition/refinement/gains/soed/soed_gain_cache.h"
#endif
#ifdef KAHYPAR_ENABLE_STEINER_TREE_METRIC
#include "mt-kahypar/partition/refinement/gains/steiner_tree/steiner_tree_gain_cache.h"
#endif
Expand All @@ -62,9 +58,7 @@ class GainCachePtr {
public:
static gain_cache_t constructGainCache(const Context& context) {
switch(context.partition.gain_policy) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut: return constructGainCache<CutGainCache>(context);
#endif
case GainPolicy::km1: return constructGainCache<Km1GainCache>(context);
#ifdef KAHYPAR_ENABLE_SOED_METRIC
case GainPolicy::soed: return constructGainCache<SoedGainCache>(context);
Expand All @@ -86,10 +80,8 @@ class GainCachePtr {
static void deleteGainCache(gain_cache_t gain_cache) {
if ( gain_cache.gain_cache ) {
switch(gain_cache.type) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut:
delete reinterpret_cast<CutGainCache*>(gain_cache.gain_cache); break;
#endif
case GainPolicy::km1:
delete reinterpret_cast<Km1GainCache*>(gain_cache.gain_cache); break;
#ifdef KAHYPAR_ENABLE_SOED_METRIC
Expand Down Expand Up @@ -118,9 +110,7 @@ class GainCachePtr {
static void initializeGainCache(const PartitionedHypergraph& partitioned_hg,
gain_cache_t gain_cache) {
switch(gain_cache.type) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut: cast<CutGainCache>(gain_cache).initializeGainCache(partitioned_hg); break;
#endif
case GainPolicy::km1: cast<Km1GainCache>(gain_cache).initializeGainCache(partitioned_hg); break;
#ifdef KAHYPAR_ENABLE_SOED_METRIC
case GainPolicy::soed: cast<SoedGainCache>(gain_cache).initializeGainCache(partitioned_hg); break;
Expand All @@ -140,9 +130,7 @@ class GainCachePtr {

static void resetGainCache(gain_cache_t gain_cache) {
switch(gain_cache.type) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut: cast<CutGainCache>(gain_cache).reset(); break;
#endif
case GainPolicy::km1: cast<Km1GainCache>(gain_cache).reset(); break;
#ifdef KAHYPAR_ENABLE_SOED_METRIC
case GainPolicy::soed: cast<SoedGainCache>(gain_cache).reset(); break;
Expand All @@ -166,9 +154,7 @@ class GainCachePtr {
const Batch& batch,
gain_cache_t gain_cache) {
switch(gain_cache.type) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut: partitioned_hg.uncontract(batch, cast<CutGainCache>(gain_cache)); break;
#endif
case GainPolicy::km1: partitioned_hg.uncontract(batch, cast<Km1GainCache>(gain_cache)); break;
#ifdef KAHYPAR_ENABLE_SOED_METRIC
case GainPolicy::soed: partitioned_hg.uncontract(batch, cast<SoedGainCache>(gain_cache)); break;
Expand All @@ -190,11 +176,9 @@ class GainCachePtr {
const vec<ParallelHyperedge>& hes_to_restore,
gain_cache_t gain_cache) {
switch ( gain_cache.type ) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut:
partitioned_hg.restoreSinglePinAndParallelNets(hes_to_restore,
cast<CutGainCache>(gain_cache)); break;
#endif
case GainPolicy::km1:
partitioned_hg.restoreSinglePinAndParallelNets(hes_to_restore,
cast<Km1GainCache>(gain_cache)); break;
Expand Down Expand Up @@ -227,11 +211,9 @@ class GainCachePtr {
static bool checkTrackedPartitionInformation(PartitionedHypergraph& partitioned_hg,
gain_cache_t gain_cache) {
switch ( gain_cache.type ) {
#ifdef KAHYPAR_ENABLE_CUT_METRIC
case GainPolicy::cut:
return partitioned_hg.checkTrackedPartitionInformation(
cast<CutGainCache>(gain_cache));
#endif
case GainPolicy::km1:
return partitioned_hg.checkTrackedPartitionInformation(
cast<Km1GainCache>(gain_cache));
Expand Down
10 changes: 3 additions & 7 deletions mt-kahypar/partition/refinement/gains/gain_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@
#include "mt-kahypar/partition/refinement/gains/km1/km1_gain_computation.h"
#include "mt-kahypar/partition/refinement/gains/km1/km1_attributed_gains.h"
#include "mt-kahypar/partition/refinement/gains/km1/km1_flow_network_construction.h"
#ifdef KAHYPAR_ENABLE_CUT_METRIC
#include "mt-kahypar/partition/refinement/gains/cut/cut_gain_cache.h"
#include "mt-kahypar/partition/refinement/gains/cut/cut_rollback.h"
#include "mt-kahypar/partition/refinement/gains/cut/cut_gain_computation.h"
#include "mt-kahypar/partition/refinement/gains/cut/cut_attributed_gains.h"
#include "mt-kahypar/partition/refinement/gains/cut/cut_flow_network_construction.h"
#endif
#ifdef KAHYPAR_ENABLE_SOED_METRIC
#include "mt-kahypar/partition/refinement/gains/soed/soed_attributed_gains.h"
#include "mt-kahypar/partition/refinement/gains/soed/soed_gain_computation.h"
Expand Down Expand Up @@ -81,7 +79,6 @@ struct Km1GainTypes : public kahypar::meta::PolicyBase {
using FlowNetworkConstruction = Km1FlowNetworkConstruction;
};

#ifdef KAHYPAR_ENABLE_CUT_METRIC
struct CutGainTypes : public kahypar::meta::PolicyBase {
using GainComputation = CutGainComputation;
using AttributedGains = CutAttributedGains;
Expand All @@ -90,7 +87,6 @@ struct CutGainTypes : public kahypar::meta::PolicyBase {
using Rollback = CutRollback;
using FlowNetworkConstruction = CutFlowNetworkConstruction;
};
#endif

#ifdef KAHYPAR_ENABLE_SOED_METRIC
struct SoedGainTypes : public kahypar::meta::PolicyBase {
Expand Down Expand Up @@ -137,16 +133,16 @@ struct SteinerTreeForGraphsTypes : public kahypar::meta::PolicyBase {
#endif


using GainTypes = kahypar::meta::Typelist<Km1GainTypes
ENABLE_CUT(COMMA CutGainTypes)
using GainTypes = kahypar::meta::Typelist<Km1GainTypes,
CutGainTypes
ENABLE_SOED(COMMA SoedGainTypes)
ENABLE_STEINER_TREE(COMMA SteinerTreeGainTypes)
ENABLE_GRAPHS(COMMA CutGainForGraphsTypes)
ENABLE_GRAPHS(ENABLE_STEINER_TREE(COMMA SteinerTreeForGraphsTypes))>;

#define INSTANTIATE_CLASS_WITH_TYPE_TRAITS_AND_GAIN_TYPES(C) \
INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, Km1GainTypes) \
ENABLE_CUT(INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, CutGainTypes)) \
INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, CutGainTypes) \
ENABLE_SOED(INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, SoedGainTypes)) \
ENABLE_STEINER_TREE(INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, SteinerTreeGainTypes)) \
ENABLE_GRAPHS(INSTANTIATE_CLASS_MACRO_WITH_TYPE_TRAITS_AND_OTHER_CLASS(C, CutGainForGraphsTypes)) \
Expand Down
2 changes: 0 additions & 2 deletions mt-kahypar/partition/registries/register_policies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ REGISTER_POLICY(AcceptancePolicy, AcceptancePolicy::best,
// Gain Type Policies
// //////////////////////////////////////////////////////////////////////////////
REGISTER_POLICY(GainPolicy, GainPolicy::km1, Km1GainTypes);
#ifdef KAHYPAR_ENABLE_CUT_METRIC
REGISTER_POLICY(GainPolicy, GainPolicy::cut, CutGainTypes);
#endif
#ifdef KAHYPAR_ENABLE_SOED_METRIC
REGISTER_POLICY(GainPolicy, GainPolicy::soed, SoedGainTypes);
#endif
Expand Down
4 changes: 2 additions & 2 deletions tests/partition/refinement/bipartitioning_gain_policy_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class ABipartitioningPolicy : public Test {
Context context;
};

typedef ::testing::Types<ObjectiveF<Objective::km1>
ENABLE_CUT(COMMA ObjectiveF<Objective::cut>)
typedef ::testing::Types<ObjectiveF<Objective::cut>,
ObjectiveF<Objective::km1>
ENABLE_SOED(COMMA ObjectiveF<Objective::soed>)> TestConfigs;

TYPED_TEST_CASE(ABipartitioningPolicy, TestConfigs);
Expand Down
12 changes: 6 additions & 6 deletions tests/partition/refinement/gain_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,20 +430,20 @@ class AGainCache : public Test {
ds::ThreadSafeFastResetFlagArray<> was_moved;
};

typedef ::testing::Types<TestConfig<StaticHypergraphTypeTraits, Km1GainTypes>
ENABLE_CUT(COMMA TestConfig<StaticHypergraphTypeTraits COMMA CutGainTypes>)
typedef ::testing::Types<TestConfig<StaticHypergraphTypeTraits, Km1GainTypes>,
TestConfig<StaticHypergraphTypeTraits, CutGainTypes>
ENABLE_SOED(COMMA TestConfig<StaticHypergraphTypeTraits COMMA SoedGainTypes>)
ENABLE_STEINER_TREE(COMMA TestConfig<StaticHypergraphTypeTraits COMMA SteinerTreeGainTypes>)
ENABLE_GRAPHS(ENABLE_CUT(COMMA TestConfig<StaticGraphTypeTraits COMMA CutGainForGraphsTypes>))
ENABLE_GRAPHS(COMMA TestConfig<StaticGraphTypeTraits COMMA CutGainForGraphsTypes>)
ENABLE_GRAPHS(ENABLE_STEINER_TREE(COMMA TestConfig<StaticGraphTypeTraits COMMA SteinerTreeForGraphsTypes>))
ENABLE_QUALITY_PRESET(COMMA TestConfig<DynamicHypergraphTypeTraits COMMA Km1GainTypes>)
ENABLE_QUALITY_PRESET(ENABLE_CUT(COMMA TestConfig<DynamicHypergraphTypeTraits COMMA CutGainTypes>))
ENABLE_QUALITY_PRESET(COMMA TestConfig<DynamicHypergraphTypeTraits COMMA CutGainTypes>)
ENABLE_QUALITY_PRESET(ENABLE_SOED(COMMA TestConfig<DynamicHypergraphTypeTraits COMMA SoedGainTypes>))
ENABLE_QUALITY_PRESET(ENABLE_STEINER_TREE(COMMA TestConfig<DynamicHypergraphTypeTraits COMMA SteinerTreeGainTypes>))
ENABLE_QUALITY_PRESET_FOR_GRAPHS(ENABLE_CUT(COMMA TestConfig<DynamicGraphTypeTraits COMMA CutGainForGraphsTypes>))
ENABLE_QUALITY_PRESET_FOR_GRAPHS(COMMA TestConfig<DynamicGraphTypeTraits COMMA CutGainForGraphsTypes>)
ENABLE_QUALITY_PRESET_FOR_GRAPHS(ENABLE_STEINER_TREE(COMMA TestConfig<DynamicGraphTypeTraits COMMA SteinerTreeForGraphsTypes>))
ENABLE_LARGE_K(COMMA TestConfig<LargeKHypergraphTypeTraits COMMA Km1GainTypes>)
ENABLE_LARGE_K(ENABLE_CUT(COMMA TestConfig<LargeKHypergraphTypeTraits COMMA CutGainTypes>))
ENABLE_LARGE_K(COMMA TestConfig<LargeKHypergraphTypeTraits COMMA CutGainTypes>)
ENABLE_LARGE_K(ENABLE_SOED(COMMA TestConfig<LargeKHypergraphTypeTraits COMMA SoedGainTypes>))
ENABLE_LARGE_K(ENABLE_STEINER_TREE(COMMA TestConfig<LargeKHypergraphTypeTraits COMMA SteinerTreeGainTypes>))> TestConfigs;

Expand Down

0 comments on commit 46646b6

Please sign in to comment.