Skip to content

Commit

Permalink
fix: remaining compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSeemaier committed May 6, 2024
1 parent b4707a2 commit b4aab11
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 297 deletions.
10 changes: 4 additions & 6 deletions kaminpar-cli/dkaminpar_arguments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,17 @@ CLI::Option_group *create_coarsening_options(CLI::App *app, Context &ctx) {
->capture_default_str();
coarsening
->add_option("--c-local-clustering-algorithm", ctx.coarsening.local_clustering_algorithm)
->transform(CLI::CheckedTransformer(get_local_clustering_algorithms()).description(""))
->transform(CLI::CheckedTransformer(get_clustering_algorithms()).description(""))
->description(R"(Local clustering algorithm, options are:
- noop: disable local clustering
- lp: parallel label propagation)")
- local-noop: disable local clustering
- local-lp: parallel label propagation)")
->capture_default_str();
coarsening
->add_option("--c-global-clustering-algorithm", ctx.coarsening.global_clustering_algorithm)
->transform(CLI::CheckedTransformer(get_global_clustering_algorithms()).description(""))
->transform(CLI::CheckedTransformer(get_clustering_algorithms()).description(""))
->description(R"(Global clustering algorithm, options are:
- noop: disable global clustering
- lp: parallel label propagation without active set strategy
- active-set-lp: parallel label propagation with active set strategy
- locking-lp: parallel label propagation with cluster-join requests
- hem: heavy edge matching
- hem-lp: heavy edge matching + label propagation)")

Expand Down
12 changes: 8 additions & 4 deletions kaminpar-common/datastructures/static_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ template <typename T> class StaticArray {
return _ptr -= n, *this;
}

reference operator[](const difference_type &n) const {
return *_ptr[n];
reference operator[](const difference_type &n) {
return *(_ptr + n);
}

const T &operator[](const difference_type &n) const {
return *(_ptr + n);
}

bool operator==(const StaticArrayIterator &other) const {
Expand All @@ -123,11 +127,11 @@ template <typename T> class StaticArray {
return _ptr >= other._ptr;
}

difference_type operator+(const StaticArrayIterator &other) {
difference_type operator+(const StaticArrayIterator &other) const {
return _ptr + other._ptr;
}

difference_type operator-(const StaticArrayIterator &other) {
difference_type operator-(const StaticArrayIterator &other) const {
return _ptr - other._ptr;
}

Expand Down
6 changes: 1 addition & 5 deletions kaminpar-dist/coarsening/clustering/lp/local_lp_clusterer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,9 @@ void LocalLPClusterer::set_max_cluster_weight(GlobalNodeWeight weight) {
void LocalLPClusterer::cluster(
StaticArray<GlobalNodeID> &global_clustering, const DistributedGraph &p_graph
) {
static_assert(sizeof(GlobalNodeID) % sizeof(NodeID) == 0, "Size mismatch");
GlobalNodeID *raw_global_clustering = global_clustering.data();
NodeID *raw_local_clustering = reinterpret_cast<NodeID *>(raw_global_clustering);
StaticArray<NodeID> local_clustering(
sizeof(GlobalNodeID) / sizeof(NodeID) * global_clustering.size(), raw_local_clustering
p_graph.n(), reinterpret_cast<NodeID *>(global_clustering.data())
);

return _impl->compute_clustering(local_clustering, p_graph);
}
} // namespace kaminpar::dist
19 changes: 17 additions & 2 deletions kaminpar-dist/coarsening/clustering/noop_clusterer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@
namespace kaminpar::dist {
class NoopClustering : public Clusterer {
public:
void cluster(StaticArray<GlobalNodeID> & /* clustering */, const DistributedGraph & /* graph */)
final {}
NoopClustering(const bool local_clusterer) : _local_clusterer(local_clusterer) {}

void cluster(StaticArray<GlobalNodeID> &clustering, const DistributedGraph &graph) final {
if (_local_clusterer) {
StaticArray<NodeID> local_clustering(
graph.n(), reinterpret_cast<NodeID *>(clustering.data())
);
graph.pfor_nodes([&](const NodeID node) { local_clustering[node] = node; });
} else {
graph.pfor_all_nodes([&](const NodeID node) {
clustering[node] = graph.local_to_global_node(node);
});
}
}

private:
bool _local_clusterer = false;
};
} // namespace kaminpar::dist
204 changes: 0 additions & 204 deletions kaminpar-dist/coarsening/coarsener.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ class LocalCoarseGraphImpl : public CoarseGraph {

std::unique_ptr<CoarseGraph>
contract_local_clustering(const DistributedGraph &graph, const StaticArray<NodeID> &clustering) {
KASSERT(clustering.size() >= graph.n());
KASSERT(
clustering.size() >= graph.n(),
"clustering array is too small for the given graph",
assert::always
);

MPI_Comm comm = graph.communicator();
const auto [size, rank] = mpi::get_comm_info(comm);

StaticArray<NavigationMarker<NodeID, Edge, ScalableVector>> all_buffered_nodes;
const PEID size = mpi::get_comm_size(comm);
const PEID rank = mpi::get_comm_rank(comm);

//
// Compute cluster buckets
Expand Down Expand Up @@ -232,6 +235,7 @@ contract_local_clustering(const DistributedGraph &graph, const StaticArray<NodeI
//
// Construct rest of the coarse graph: edges, edge weights
//
StaticArray<NavigationMarker<NodeID, Edge, ScalableVector>> all_buffered_nodes;
all_buffered_nodes = ts_navigable_list::combine<NodeID, Edge, ScalableVector>(
edge_buffer_ets, std::move(all_buffered_nodes)
);
Expand Down
2 changes: 1 addition & 1 deletion kaminpar-dist/coarsening/global_cluster_coarsener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SET_DEBUG(false);

GlobalClusterCoarsener::GlobalClusterCoarsener(const Context &input_ctx)
: _input_ctx(input_ctx),
_clusterer(factory::create_global_clusterer(_input_ctx)) {}
_clusterer(factory::create_clusterer(_input_ctx)) {}

void GlobalClusterCoarsener::initialize(const DistributedGraph *graph) {
_input_graph = graph;
Expand Down
10 changes: 7 additions & 3 deletions kaminpar-dist/context_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,31 @@ std::ostream &operator<<(std::ostream &out, const PartitioningMode mode) {

std::unordered_map<std::string, ClusteringAlgorithm> get_clustering_algorithms() {
return {
{"noop", ClusteringAlgorithm::NOOP},
{"noop", ClusteringAlgorithm::GLOBAL_NOOP},
{"global-noop", ClusteringAlgorithm::GLOBAL_NOOP},
{"lp", ClusteringAlgorithm::GLOBAL_LP},
{"global-lp", ClusteringAlgorithm::GLOBAL_LP},
{"hem", ClusteringAlgorithm::GLOBAL_HEM},
{"global-hem", ClusteringAlgorithm::GLOBAL_HEM},
{"hem-lp", ClusteringAlgorithm::GLOBAL_HEM_LP},
{"global-hem-lp", ClusteringAlgorithm::GLOBAL_HEM_LP},
{"local-noop", ClusteringAlgorithm::LOCAL_NOOP},
{"local-lp", ClusteringAlgorithm::LOCAL_LP},
};
}

std::ostream &operator<<(std::ostream &out, const ClusteringAlgorithm algorithm) {
switch (algorithm) {
case ClusteringAlgorithm::NOOP:
return out << "noop";
case ClusteringAlgorithm::GLOBAL_NOOP:
return out << "global-noop";
case ClusteringAlgorithm::GLOBAL_LP:
return out << "global-lp";
case ClusteringAlgorithm::GLOBAL_HEM:
return out << "global-hem";
case ClusteringAlgorithm::GLOBAL_HEM_LP:
return out << "global-hem-lp";
case ClusteringAlgorithm::LOCAL_NOOP:
return out << "local-noop";
case ClusteringAlgorithm::LOCAL_LP:
return out << "local-lp";
}
Expand Down
4 changes: 3 additions & 1 deletion kaminpar-dist/dkaminpar.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ enum class PartitioningMode {
};

enum class ClusteringAlgorithm {
NOOP,
GLOBAL_NOOP,
GLOBAL_LP,
GLOBAL_HEM,
GLOBAL_HEM_LP,

LOCAL_NOOP,
LOCAL_LP,
};

Expand Down
Loading

0 comments on commit b4aab11

Please sign in to comment.