Refactor logging, improve error handling workflow, clang-format. (#3385)
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
#include "util/deallocating_vector.hpp"
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/percent.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/xor_fast_hash.hpp"
|
||||
@@ -156,11 +156,10 @@ class GraphContractor
|
||||
#ifndef NDEBUG
|
||||
if (static_cast<unsigned int>(std::max(diter->weight, 1)) > 24 * 60 * 60 * 10)
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING)
|
||||
<< "Edge weight large -> "
|
||||
<< static_cast<unsigned int>(std::max(diter->weight, 1)) << " : "
|
||||
<< static_cast<unsigned int>(diter->source) << " -> "
|
||||
<< static_cast<unsigned int>(diter->target);
|
||||
util::Log(logWARNING) << "Edge weight large -> "
|
||||
<< static_cast<unsigned int>(std::max(diter->weight, 1))
|
||||
<< " : " << static_cast<unsigned int>(diter->source) << " -> "
|
||||
<< static_cast<unsigned int>(diter->target);
|
||||
}
|
||||
#endif
|
||||
edges.emplace_back(diter->source,
|
||||
@@ -245,15 +244,14 @@ class GraphContractor
|
||||
}
|
||||
}
|
||||
}
|
||||
util::SimpleLogger().Write() << "merged " << edges.size() - edge << " edges out of "
|
||||
<< edges.size();
|
||||
util::Log() << "merged " << edges.size() - edge << " edges out of " << edges.size();
|
||||
edges.resize(edge);
|
||||
contractor_graph = std::make_shared<ContractorGraph>(nodes, edges);
|
||||
edges.clear();
|
||||
edges.shrink_to_fit();
|
||||
|
||||
BOOST_ASSERT(0 == edges.capacity());
|
||||
util::SimpleLogger().Write() << "contractor finished initalization";
|
||||
util::Log() << "contractor finished initalization";
|
||||
}
|
||||
|
||||
void Run(double core_factor = 1.0)
|
||||
@@ -270,7 +268,6 @@ class GraphContractor
|
||||
const constexpr size_t DeleteGrainSize = 1;
|
||||
|
||||
const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes();
|
||||
util::Percent p(number_of_nodes);
|
||||
|
||||
ThreadDataContainer thread_data_list(number_of_nodes);
|
||||
|
||||
@@ -292,9 +289,10 @@ class GraphContractor
|
||||
bool use_cached_node_priorities = !node_levels.empty();
|
||||
if (use_cached_node_priorities)
|
||||
{
|
||||
std::cout << "using cached node priorities ..." << std::flush;
|
||||
util::UnbufferedLog log;
|
||||
log << "using cached node priorities ...";
|
||||
node_priorities.swap(node_levels);
|
||||
std::cout << "ok" << std::endl;
|
||||
log << "ok";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -302,7 +300,8 @@ class GraphContractor
|
||||
node_priorities.resize(number_of_nodes);
|
||||
node_levels.resize(number_of_nodes);
|
||||
|
||||
std::cout << "initializing elimination PQ ..." << std::flush;
|
||||
util::UnbufferedLog log;
|
||||
log << "initializing elimination PQ ...";
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, number_of_nodes, PQGrainSize),
|
||||
[this, &node_priorities, &node_depth, &thread_data_list](
|
||||
const tbb::blocked_range<int> &range) {
|
||||
@@ -313,11 +312,14 @@ class GraphContractor
|
||||
this->EvaluateNodePriority(data, node_depth[x], x);
|
||||
}
|
||||
});
|
||||
std::cout << "ok" << std::endl;
|
||||
log << "ok";
|
||||
}
|
||||
BOOST_ASSERT(node_priorities.size() == number_of_nodes);
|
||||
|
||||
std::cout << "preprocessing " << number_of_nodes << " nodes ..." << std::flush;
|
||||
util::Log() << "preprocessing " << number_of_nodes << " nodes ...";
|
||||
|
||||
util::UnbufferedLog log;
|
||||
util::Percent p(log, number_of_nodes);
|
||||
|
||||
unsigned current_level = 0;
|
||||
bool flushed_contractor = false;
|
||||
@@ -331,7 +333,7 @@ class GraphContractor
|
||||
new_edge_set; // this one is not explicitely
|
||||
// cleared since it goes out of
|
||||
// scope anywa
|
||||
std::cout << " [flush " << number_of_contracted_nodes << " nodes] " << std::flush;
|
||||
log << " [flush " << number_of_contracted_nodes << " nodes] ";
|
||||
|
||||
// Delete old heap data to free memory that we need for the coming operations
|
||||
thread_data_list.data.clear();
|
||||
@@ -599,9 +601,8 @@ class GraphContractor
|
||||
is_core_node.clear();
|
||||
}
|
||||
|
||||
util::SimpleLogger().Write() << "[core] " << remaining_nodes.size() << " nodes "
|
||||
<< contractor_graph->GetNumberOfEdges() << " edges."
|
||||
<< std::endl;
|
||||
util::Log() << "[core] " << remaining_nodes.size() << " nodes "
|
||||
<< contractor_graph->GetNumberOfEdges() << " edges.";
|
||||
|
||||
thread_data_list.data.clear();
|
||||
}
|
||||
@@ -618,8 +619,9 @@ class GraphContractor
|
||||
|
||||
template <class Edge> inline void GetEdges(util::DeallocatingVector<Edge> &edges)
|
||||
{
|
||||
util::Percent p(contractor_graph->GetNumberOfNodes());
|
||||
util::SimpleLogger().Write() << "Getting edges of minimized graph";
|
||||
util::UnbufferedLog log;
|
||||
log << "Getting edges of minimized graph ";
|
||||
util::Percent p(log, contractor_graph->GetNumberOfNodes());
|
||||
const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes();
|
||||
if (contractor_graph->GetNumberOfNodes())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user