Skip to content

Commit

Permalink
refactor: rename node_weighted() to is_node_weighted() etc, fix inclu…
Browse files Browse the repository at this point in the history
…des in dist partitioner
  • Loading branch information
DanielSeemaier committed Apr 30, 2024
1 parent 7cde9e3 commit f0f8204
Show file tree
Hide file tree
Showing 53 changed files with 205 additions and 180 deletions.
4 changes: 2 additions & 2 deletions apps/benchmarks/shm_compressed_graph_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ int main(int argc, char *argv[]) {

LOG << "Input graph has " << graph.n() << " vertices and " << graph.m()
<< " edges. Its density is " << ((graph.m()) / (float)(graph.n() * (graph.n() - 1))) << ".";
LOG << "Node weights: " << (graph.node_weighted() ? "yes" : "no")
<< ", edge weights: " << (graph.edge_weighted() ? "yes" : "no");
LOG << "Node weights: " << (graph.is_node_weighted() ? "yes" : "no")
<< ", edge weights: " << (graph.is_edge_weighted() ? "yes" : "no");
LOG;

Timer::global().print_human_readable(std::cout);
Expand Down
8 changes: 4 additions & 4 deletions apps/io/shm_compressed_graph_binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ struct CompressedBinaryHeader {

CompressedBinaryHeader create_header(const CompressedGraph &graph) {
return {
graph.node_weighted(),
graph.edge_weighted(),
graph.is_node_weighted(),
graph.is_edge_weighted(),

sizeof(CompressedGraph::NodeID) == 8,
sizeof(CompressedGraph::EdgeID) == 8,
Expand Down Expand Up @@ -131,11 +131,11 @@ void write(const std::string &filename, const CompressedGraph &graph) {
write_compact_static_array(out, graph.raw_nodes());
write_static_array(out, graph.raw_compressed_edges());

if (graph.node_weighted()) {
if (graph.is_node_weighted()) {
write_static_array(out, graph.raw_node_weights());
}

if (graph.edge_weighted()) {
if (graph.is_edge_weighted()) {
write_static_array(out, graph.raw_edge_weights());
}
}
Expand Down
10 changes: 5 additions & 5 deletions apps/io/shm_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,26 @@ void write(const std::string &filename, const Graph &graph) {
std::ofstream out(filename);

out << graph.n() << ' ' << (graph.m() / 2);
if (graph.node_weighted() || graph.edge_weighted()) {
if (graph.is_node_weighted() || graph.is_edge_weighted()) {
out << ' ';

if (graph.node_weighted()) {
if (graph.is_node_weighted()) {
out << '1';
}

out << (graph.edge_weighted() ? '1' : '0');
out << (graph.is_edge_weighted() ? '1' : '0');
}
out << '\n';

for (const NodeID node : graph.nodes()) {
if (graph.node_weighted()) {
if (graph.is_node_weighted()) {
out << graph.node_weight(node) << ' ';
}

graph.neighbors(node, [&](const EdgeID incident_edge, const NodeID adjacent_node) {
out << (adjacent_node + 1) << ' ';

if (graph.edge_weighted()) {
if (graph.is_edge_weighted()) {
out << graph.edge_weight(incident_edge) << ' ';
}
});
Expand Down
4 changes: 2 additions & 2 deletions apps/tools/shm_graph_properties_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ void print_graph_properties(const Graph &graph, const Context ctx, std::ostream
cio::print_delimiter("Graph Properties", '#');
out << "Graph: " << ctx.debug.graph_name << "\n";
out << " Number of nodes: " << std::setw(width) << graph.n();
if (graph.node_weighted()) {
if (graph.is_node_weighted()) {
out << " (total weight: " << graph.total_node_weight() << ")\n";
} else {
out << " (unweighted)\n";
}
out << " Number of edges: " << std::setw(width) << graph.m();
if (graph.edge_weighted()) {
if (graph.is_edge_weighted()) {
out << " (total weight: " << graph.total_edge_weight() << ")\n";
} else {
out << " (unweighted)\n";
Expand Down
2 changes: 0 additions & 2 deletions kaminpar-dist/algorithms/border_nodes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "kaminpar-dist/datastructures/distributed_partitioned_graph.h"
#include "kaminpar-dist/dkaminpar.h"

#include "kaminpar-common/timer.h"

namespace kaminpar::dist::graph {
std::vector<NodeID> find_border_nodes(const DistributedPartitionedGraph &p_graph) {
std::vector<NodeID> border_nodes;
Expand Down
2 changes: 2 additions & 0 deletions kaminpar-dist/algorithms/greedy_node_coloring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "kaminpar-common/assert.h"
#include "kaminpar-common/datastructures/marker.h"
#include "kaminpar-common/datastructures/noinit_vector.h"
#include "kaminpar-common/logger.h"
#include "kaminpar-common/math.h"
#include "kaminpar-common/parallel/algorithm.h"
#include "kaminpar-common/ranges.h"
Expand Down
2 changes: 2 additions & 0 deletions kaminpar-dist/algorithms/greedy_node_coloring.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "kaminpar-dist/datastructures/distributed_graph.h"
#include "kaminpar-dist/dkaminpar.h"

#include "kaminpar-common/datastructures/noinit_vector.h"

namespace kaminpar::dist {
using ColorID = EdgeID;

Expand Down
8 changes: 4 additions & 4 deletions kaminpar-dist/algorithms/independent_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

#include "kaminpar-dist/datastructures/distributed_partitioned_graph.h"

#include "kaminpar-common/timer.h"
#include "kaminpar-common/datastructures/noinit_vector.h"
#include "kaminpar-common/logger.h"

namespace kaminpar::dist::graph {
SET_DEBUG(false);
Expand All @@ -26,9 +27,8 @@ template <typename Generator, typename ScoreType = std::int64_t>
ScoreType compute_score(Generator &generator, const GlobalNodeID node, const int seed) {
// @todo replace with something efficient / use communication
generator.seed(seed + node);
return std::uniform_int_distribution<ScoreType>(
ScoreType(), std::numeric_limits<ScoreType>::max() - 1
)(generator);
return std::uniform_int_distribution<
ScoreType>(ScoreType(), std::numeric_limits<ScoreType>::max() - 1)(generator);
}
} // namespace

Expand Down
2 changes: 1 addition & 1 deletion kaminpar-dist/coarsening/clustering/clusterer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "kaminpar-dist/datastructures/distributed_partitioned_graph.h"
#include "kaminpar-dist/dkaminpar.h"

#include "kaminpar-common/parallel/atomic.h"
#include "kaminpar-common/datastructures/noinit_vector.h"

namespace kaminpar::dist {
template <typename ClusterID> class Clusterer {
Expand Down
2 changes: 2 additions & 0 deletions kaminpar-dist/coarsening/coarsener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include "kaminpar-shm/coarsening/max_cluster_weights.h"

#include "kaminpar-common/logger.h"

namespace kaminpar::dist {
SET_DEBUG(false);

Expand Down
2 changes: 1 addition & 1 deletion kaminpar-dist/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "kaminpar-shm/datastructures/graph.h"

// Most of the functions are part of the public API
#include "kaminpar-dist/dkaminpar.h"
#include "kaminpar-dist/dkaminpar.h" // IWYU pragma: export

namespace kaminpar::dist {
struct GraphContext {
Expand Down
5 changes: 4 additions & 1 deletion kaminpar-dist/context_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <ostream>
#include <unordered_map>

#include "kaminpar-mpi/wrapper.h"

#include "kaminpar-dist/context.h"

#include "kaminpar-common/console_io.h"
Expand Down Expand Up @@ -450,7 +452,8 @@ void print(const RefinementContext &ctx, const ParallelContext &parallel, std::o
LabelPropagationMoveExecutionStrategy::PROBABILISTIC) {
out << " Number of attempts: " << ctx.colored_lp.num_probabilistic_move_attempts
<< "\n";
} else if (ctx.colored_lp.move_execution_strategy == LabelPropagationMoveExecutionStrategy::BEST_MOVES) {
} else if (ctx.colored_lp.move_execution_strategy ==
LabelPropagationMoveExecutionStrategy::BEST_MOVES) {
out << " Sort by: "
<< (ctx.colored_lp.sort_by_rel_gain ? "relative gain" : "absolute gain") << "\n";
}
Expand Down
4 changes: 2 additions & 2 deletions kaminpar-dist/datastructures/distributed_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#include "kaminpar-mpi/wrapper.h"

#include "kaminpar-dist/graphutils/communication.h"
#include "kaminpar-dist/logger.h"

#include "kaminpar-common/datastructures/marker.h"
#include "kaminpar-common/datastructures/scalable_vector.h"
#include "kaminpar-common/math.h"
#include "kaminpar-common/parallel/algorithm.h"
#include "kaminpar-common/parallel/vector_ets.h"
#include "kaminpar-common/timer.h"

namespace kaminpar::dist {
void DistributedGraph::init_high_degree_info(const EdgeID high_degree_threshold) const {
Expand All @@ -43,7 +43,7 @@ void DistributedGraph::init_high_degree_info(const EdgeID high_degree_threshold)
[&](const auto &recv_buffer, const PEID pe) {
tbb::parallel_for<std::size_t>(0, recv_buffer.size(), [&](const std::size_t i) {
const auto &[remote_node, high_degree] = recv_buffer[i];
const NodeID local_node = remote_to_local_node(remote_node, pe);
const NodeID local_node = map_remote_node(remote_node, pe);
_high_degree_ghost_node[local_node - n()] = high_degree;
});
}
Expand Down
Loading

0 comments on commit f0f8204

Please sign in to comment.