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

refactor: slightly improve error messages #15

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion apps/KaMinPar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,18 @@ The output should be stored in a file and can be used by the -C,--config option.
auto *gp_group = mandatory->add_option_group("Partitioning")->silent();
gp_group->add_option("-k,--k", app.k, "Number of blocks in the partition.")
->configurable(false)
->check(CLI::Range(static_cast<BlockID>(2), std::numeric_limits<BlockID>::max()))
->required();
gp_group->add_option("-G,--graph", app.graph_filename, "Input graph in METIS format.")
->check(CLI::ExistingFile)
->configurable(false);

// Application options
cli.add_option("-s,--seed", app.seed, "Seed for random number generation.")
->default_val(app.seed);
cli.add_flag("-q,--quiet", app.quiet, "Suppress all console output.");
cli.add_option("-t,--threads", app.num_threads, "Number of threads to be used.")
->check(CLI::NonNegativeNumber)
->check(CLI::PositiveNumber)
->default_val(app.num_threads);
cli.add_flag("-E,--experiment", app.experiment, "Use an output format that is easier to parse.");
cli.add_flag(
Expand Down Expand Up @@ -266,6 +268,12 @@ int main(int argc, char *argv[]) {
shm::validate_undirected_graph(graph);
}

if (static_cast<std::uint64_t>(graph.m()) >
static_cast<std::uint64_t>(std::numeric_limits<EdgeWeight>::max())) {
LOG_WARNING << "The edge weight type is not large enough to store the sum of all edge weights. "
<< "This might cause overflows for very large cuts.";
}

RECORD("partition") std::vector<BlockID> partition(graph.n());
RECORD_LOCAL_DATA_STRUCT(partition, partition.capacity() * sizeof(BlockID));
STOP_HEAP_PROFILER();
Expand Down
6 changes: 2 additions & 4 deletions kaminpar-dist/context_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,15 @@ void print(const PartitionContext &ctx, const bool root, std::ostream &out, MPI_

if (root) {
out << " Number of global nodes: " << std::setw(width) << ctx.graph->global_n;
if (asserting_cast<GlobalNodeWeight>(ctx.graph->global_n) ==
ctx.graph->global_total_node_weight) {
if (static_cast<GlobalNodeWeight>(ctx.graph->global_n) == ctx.graph->global_total_node_weight) {
out << " (unweighted)\n";
} else {
out << " (total weight: " << ctx.graph->global_total_node_weight << ")\n";
}
out << " + ghost nodes: " << std::setw(width)
<< num_global_total_nodes - ctx.graph->global_n << "\n";
out << " Number of global edges: " << std::setw(width) << ctx.graph->global_m;
if (asserting_cast<GlobalEdgeWeight>(ctx.graph->global_m) ==
ctx.graph->global_total_edge_weight) {
if (static_cast<GlobalEdgeWeight>(ctx.graph->global_m) == ctx.graph->global_total_edge_weight) {
out << " (unweighted)\n";
} else {
out << " (total weight: " << ctx.graph->global_total_edge_weight << ")\n";
Expand Down
5 changes: 2 additions & 3 deletions kaminpar-shm/context_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "kaminpar-shm/kaminpar.h"

#include "kaminpar-common/asserting_cast.h"
#include "kaminpar-common/console_io.h"
#include "kaminpar-common/random.h"
#include "kaminpar-common/strutils.h"
Expand Down Expand Up @@ -574,13 +573,13 @@ void print(const PartitionContext &p_ctx, std::ostream &out) {
const std::size_t width = size > 0 ? std::ceil(std::log10(size)) : 1;

out << " Number of nodes: " << std::setw(width) << p_ctx.n;
if (asserting_cast<NodeWeight>(p_ctx.n) == p_ctx.total_node_weight) {
if (static_cast<NodeWeight>(p_ctx.n) == p_ctx.total_node_weight) {
out << " (unweighted)\n";
} else {
out << " (total weight: " << p_ctx.total_node_weight << ")\n";
}
out << " Number of edges: " << std::setw(width) << p_ctx.m;
if (asserting_cast<EdgeWeight>(p_ctx.m) == p_ctx.total_edge_weight) {
if (static_cast<EdgeWeight>(p_ctx.m) == p_ctx.total_edge_weight) {
out << " (unweighted)\n";
} else {
out << " (total weight: " << p_ctx.total_edge_weight << ")\n";
Expand Down