Migrate to modern TBB version (#6300)
This commit is contained in:
committed by
GitHub
parent
a98074a051
commit
91895604c9
@@ -35,12 +35,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
#endif
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -49,13 +44,8 @@ namespace contractor
|
||||
|
||||
int Contractor::Run()
|
||||
{
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
tbb::global_control gc(tbb::global_control::max_allowed_parallelism,
|
||||
config.requested_num_threads);
|
||||
#else
|
||||
tbb::task_scheduler_init init(config.requested_num_threads);
|
||||
BOOST_ASSERT(init.is_active());
|
||||
#endif
|
||||
|
||||
if (config.core_factor != 1.0)
|
||||
{
|
||||
|
||||
@@ -21,11 +21,7 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
#endif
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -122,13 +118,8 @@ std::vector<CellMetric> customizeFilteredMetrics(const partitioner::MultiLevelEd
|
||||
|
||||
int Customizer::Run(const CustomizationConfig &config)
|
||||
{
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
tbb::global_control gc(tbb::global_control::max_allowed_parallelism,
|
||||
config.requested_num_threads);
|
||||
#else
|
||||
tbb::task_scheduler_init init(config.requested_num_threads);
|
||||
BOOST_ASSERT(init.is_active());
|
||||
#endif
|
||||
|
||||
TIMER_START(loading_data);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/pipeline.h>
|
||||
#include <tbb/parallel_pipeline.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
@@ -489,8 +489,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
// Sets of intersection IDs are batched in groups of GRAINSIZE (100) `generator_stage`, then
|
||||
// those groups are processed in parallel `processor_stage`. Finally, results are appended to
|
||||
// the various buffer vectors by the `output_stage` in the same order that the `generator_stage`
|
||||
// created them in (tbb::filter::serial_in_order creates this guarantee). The order needs to be
|
||||
// maintained because we depend on it later in the processing pipeline.
|
||||
// created them in (tbb::filter_mode::serial_in_order creates this guarantee). The order needs
|
||||
// to be maintained because we depend on it later in the processing pipeline.
|
||||
{
|
||||
const NodeID node_count = m_node_based_graph.GetNumberOfNodes();
|
||||
|
||||
@@ -540,8 +540,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
const constexpr unsigned GRAINSIZE = 100;
|
||||
|
||||
// First part of the pipeline generates iterator ranges of IDs in sets of GRAINSIZE
|
||||
tbb::filter_t<void, tbb::blocked_range<NodeID>> generator_stage(
|
||||
tbb::filter::serial_in_order, [&](tbb::flow_control &fc) {
|
||||
tbb::filter<void, tbb::blocked_range<NodeID>> generator_stage(
|
||||
tbb::filter_mode::serial_in_order, [&](tbb::flow_control &fc) {
|
||||
if (current_node < node_count)
|
||||
{
|
||||
auto next_node = std::min(current_node + GRAINSIZE, node_count);
|
||||
@@ -675,8 +675,9 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
//
|
||||
// Edge-based-graph stage
|
||||
//
|
||||
tbb::filter_t<tbb::blocked_range<NodeID>, EdgesPipelineBufferPtr> processor_stage(
|
||||
tbb::filter::parallel, [&](const tbb::blocked_range<NodeID> &intersection_node_range) {
|
||||
tbb::filter<tbb::blocked_range<NodeID>, EdgesPipelineBufferPtr> processor_stage(
|
||||
tbb::filter_mode::parallel,
|
||||
[&](const tbb::blocked_range<NodeID> &intersection_node_range) {
|
||||
auto buffer = std::make_shared<EdgesPipelineBuffer>();
|
||||
buffer->nodes_processed = intersection_node_range.size();
|
||||
|
||||
@@ -1085,8 +1086,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
util::UnbufferedLog log;
|
||||
util::Percent routing_progress(log, node_count);
|
||||
std::vector<EdgeWithData> delayed_data;
|
||||
tbb::filter_t<EdgesPipelineBufferPtr, void> output_stage(
|
||||
tbb::filter::serial_in_order, [&](auto buffer) {
|
||||
tbb::filter<EdgesPipelineBufferPtr, void> output_stage(
|
||||
tbb::filter_mode::serial_in_order, [&](auto buffer) {
|
||||
routing_progress.PrintAddition(buffer->nodes_processed);
|
||||
|
||||
m_connectivity_checksum = buffer->checksum.update_checksum(m_connectivity_checksum);
|
||||
|
||||
+13
-23
@@ -43,13 +43,8 @@
|
||||
#include <osmium/io/any_input.hpp>
|
||||
#include <osmium/thread/pool.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
#endif
|
||||
#include <tbb/pipeline.h>
|
||||
#include <tbb/parallel_pipeline.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
@@ -206,13 +201,8 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
const unsigned recommended_num_threads = std::thread::hardware_concurrency();
|
||||
const auto number_of_threads = std::min(recommended_num_threads, config.requested_num_threads);
|
||||
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
tbb::global_control gc(tbb::global_control::max_allowed_parallelism,
|
||||
config.requested_num_threads);
|
||||
#else
|
||||
tbb::task_scheduler_init init(config.requested_num_threads);
|
||||
BOOST_ASSERT(init.is_active());
|
||||
#endif
|
||||
|
||||
LaneDescriptionMap turn_lane_map;
|
||||
std::vector<TurnRestriction> turn_restrictions;
|
||||
@@ -456,8 +446,8 @@ std::
|
||||
ExtractionRelationContainer relations;
|
||||
|
||||
const auto buffer_reader = [](osmium::io::Reader &reader) {
|
||||
return tbb::filter_t<void, SharedBuffer>(
|
||||
tbb::filter::serial_in_order, [&reader](tbb::flow_control &fc) {
|
||||
return tbb::filter<void, SharedBuffer>(
|
||||
tbb::filter_mode::serial_in_order, [&reader](tbb::flow_control &fc) {
|
||||
if (auto buffer = reader.read())
|
||||
{
|
||||
return std::make_shared<osmium::memory::Buffer>(std::move(buffer));
|
||||
@@ -478,15 +468,15 @@ std::
|
||||
osmium_index_type location_cache;
|
||||
osmium_location_handler_type location_handler(location_cache);
|
||||
|
||||
tbb::filter_t<SharedBuffer, SharedBuffer> location_cacher(
|
||||
tbb::filter::serial_in_order, [&location_handler](SharedBuffer buffer) {
|
||||
tbb::filter<SharedBuffer, SharedBuffer> location_cacher(
|
||||
tbb::filter_mode::serial_in_order, [&location_handler](SharedBuffer buffer) {
|
||||
osmium::apply(buffer->begin(), buffer->end(), location_handler);
|
||||
return buffer;
|
||||
});
|
||||
|
||||
// OSM elements Lua parser
|
||||
tbb::filter_t<SharedBuffer, ParsedBuffer> buffer_transformer(
|
||||
tbb::filter::parallel,
|
||||
tbb::filter<SharedBuffer, ParsedBuffer> buffer_transformer(
|
||||
tbb::filter_mode::parallel,
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
[&](const SharedBuffer buffer) {
|
||||
ParsedBuffer parsed_buffer;
|
||||
@@ -507,8 +497,8 @@ std::
|
||||
unsigned number_of_ways = 0;
|
||||
unsigned number_of_restrictions = 0;
|
||||
unsigned number_of_maneuver_overrides = 0;
|
||||
tbb::filter_t<ParsedBuffer, void> buffer_storage(
|
||||
tbb::filter::serial_in_order, [&](const ParsedBuffer &parsed_buffer) {
|
||||
tbb::filter<ParsedBuffer, void> buffer_storage(
|
||||
tbb::filter_mode::serial_in_order, [&](const ParsedBuffer &parsed_buffer) {
|
||||
number_of_nodes += parsed_buffer.resulting_nodes.size();
|
||||
// put parsed objects thru extractor callbacks
|
||||
for (const auto &result : parsed_buffer.resulting_nodes)
|
||||
@@ -534,8 +524,8 @@ std::
|
||||
}
|
||||
});
|
||||
|
||||
tbb::filter_t<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
|
||||
tbb::filter::parallel,
|
||||
tbb::filter<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
|
||||
tbb::filter_mode::parallel,
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
[&](const SharedBuffer buffer) {
|
||||
if (!buffer)
|
||||
@@ -572,8 +562,8 @@ std::
|
||||
});
|
||||
|
||||
unsigned number_of_relations = 0;
|
||||
tbb::filter_t<std::shared_ptr<ExtractionRelationContainer>, void> buffer_storage_relation(
|
||||
tbb::filter::serial_in_order,
|
||||
tbb::filter<std::shared_ptr<ExtractionRelationContainer>, void> buffer_storage_relation(
|
||||
tbb::filter_mode::serial_in_order,
|
||||
// NOLINTNEXTLINE(performance-unnecessary-value-param)
|
||||
[&](const std::shared_ptr<ExtractionRelationContainer> parsed_relations) {
|
||||
number_of_relations += parsed_relations->GetRelationsNum();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "util/percent.hpp"
|
||||
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/pipeline.h>
|
||||
#include <tbb/parallel_pipeline.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
@@ -97,8 +97,8 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const constexpr unsigned GRAINSIZE = 100;
|
||||
|
||||
// First part of the pipeline generates iterator ranges of IDs in sets of GRAINSIZE
|
||||
tbb::filter_t<void, tbb::blocked_range<NodeID>> generator_stage(
|
||||
tbb::filter::serial_in_order, [&](tbb::flow_control &fc) {
|
||||
tbb::filter<void, tbb::blocked_range<NodeID>> generator_stage(
|
||||
tbb::filter_mode::serial_in_order, [&](tbb::flow_control &fc) {
|
||||
if (current_node < node_count)
|
||||
{
|
||||
auto next_node = std::min(current_node + GRAINSIZE, node_count);
|
||||
@@ -116,8 +116,9 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
//
|
||||
// Guidance stage
|
||||
//
|
||||
tbb::filter_t<tbb::blocked_range<NodeID>, TurnsPipelineBufferPtr> guidance_stage(
|
||||
tbb::filter::parallel, [&](const tbb::blocked_range<NodeID> &intersection_node_range) {
|
||||
tbb::filter<tbb::blocked_range<NodeID>, TurnsPipelineBufferPtr> guidance_stage(
|
||||
tbb::filter_mode::parallel,
|
||||
[&](const tbb::blocked_range<NodeID> &intersection_node_range) {
|
||||
auto buffer = std::make_shared<TurnsPipelineBuffer>();
|
||||
buffer->nodes_processed = intersection_node_range.size();
|
||||
|
||||
@@ -307,8 +308,8 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
util::Percent guidance_progress(log, node_count);
|
||||
std::vector<guidance::TurnData> delayed_turn_data;
|
||||
|
||||
tbb::filter_t<TurnsPipelineBufferPtr, void> guidance_output_stage(
|
||||
tbb::filter::serial_in_order, [&](auto buffer) {
|
||||
tbb::filter<TurnsPipelineBufferPtr, void> guidance_output_stage(
|
||||
tbb::filter_mode::serial_in_order, [&](auto buffer) {
|
||||
guidance_progress.PrintAddition(buffer->nodes_processed);
|
||||
|
||||
connectivity_checksum = buffer->checksum.update_checksum(connectivity_checksum);
|
||||
|
||||
@@ -27,12 +27,7 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
#endif
|
||||
|
||||
#include "util/geojson_debug_logger.hpp"
|
||||
#include "util/geojson_debug_policies.hpp"
|
||||
@@ -74,13 +69,8 @@ auto getGraphBisection(const PartitionerConfig &config)
|
||||
|
||||
int Partitioner::Run(const PartitionerConfig &config)
|
||||
{
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
tbb::global_control gc(tbb::global_control::max_allowed_parallelism,
|
||||
config.requested_num_threads);
|
||||
#else
|
||||
tbb::task_scheduler_init init(config.requested_num_threads);
|
||||
BOOST_ASSERT(init.is_active());
|
||||
#endif
|
||||
|
||||
const std::vector<BisectionID> &node_based_partition_ids = getGraphBisection(config);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "util/log.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include <tbb/parallel_do.h>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits> // for CHAR_BIT
|
||||
@@ -64,12 +64,12 @@ RecursiveBisection::RecursiveBisection(BisectionGraph &bisection_graph_,
|
||||
return TreeNode{std::move(graph), internal_state.SCCDepth()};
|
||||
});
|
||||
|
||||
using Feeder = tbb::parallel_do_feeder<TreeNode>;
|
||||
using Feeder = tbb::feeder<TreeNode>;
|
||||
|
||||
TIMER_START(bisection);
|
||||
|
||||
// Bisect graph into two parts. Get partition point and recurse left and right in parallel.
|
||||
tbb::parallel_do(begin(forest), end(forest), [&](const TreeNode &node, Feeder &feeder) {
|
||||
tbb::parallel_for_each(begin(forest), end(forest), [&](const TreeNode &node, Feeder &feeder) {
|
||||
const auto cut =
|
||||
computeInertialFlowCut(node.graph, num_optimizing_cuts, balance, boundary_factor);
|
||||
const auto center = internal_state.ApplyBisection(
|
||||
|
||||
+26
-26
@@ -290,27 +290,27 @@ int Storage::Run(int max_wait, const std::string &dataset_name, bool only_metric
|
||||
|
||||
std::vector<std::pair<bool, boost::filesystem::path>> Storage::GetStaticFiles()
|
||||
{
|
||||
constexpr bool REQUIRED = true;
|
||||
constexpr bool OPTIONAL = false;
|
||||
constexpr bool IS_REQUIRED = true;
|
||||
constexpr bool IS_OPTIONAL = false;
|
||||
|
||||
std::vector<std::pair<bool, boost::filesystem::path>> files = {
|
||||
{OPTIONAL, config.GetPath(".osrm.cells")},
|
||||
{OPTIONAL, config.GetPath(".osrm.partition")},
|
||||
{REQUIRED, config.GetPath(".osrm.icd")},
|
||||
{REQUIRED, config.GetPath(".osrm.properties")},
|
||||
{REQUIRED, config.GetPath(".osrm.nbg_nodes")},
|
||||
{REQUIRED, config.GetPath(".osrm.ebg_nodes")},
|
||||
{REQUIRED, config.GetPath(".osrm.tls")},
|
||||
{REQUIRED, config.GetPath(".osrm.tld")},
|
||||
{REQUIRED, config.GetPath(".osrm.timestamp")},
|
||||
{REQUIRED, config.GetPath(".osrm.maneuver_overrides")},
|
||||
{REQUIRED, config.GetPath(".osrm.edges")},
|
||||
{REQUIRED, config.GetPath(".osrm.names")},
|
||||
{REQUIRED, config.GetPath(".osrm.ramIndex")}};
|
||||
{IS_OPTIONAL, config.GetPath(".osrm.cells")},
|
||||
{IS_OPTIONAL, config.GetPath(".osrm.partition")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.icd")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.properties")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.nbg_nodes")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.ebg_nodes")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.tls")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.tld")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.timestamp")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.maneuver_overrides")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.edges")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.names")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.ramIndex")}};
|
||||
|
||||
for (const auto &file : files)
|
||||
{
|
||||
if (file.first == REQUIRED && !boost::filesystem::exists(file.second))
|
||||
if (file.first == IS_REQUIRED && !boost::filesystem::exists(file.second))
|
||||
{
|
||||
throw util::exception("Could not find required filed: " + std::get<1>(file).string());
|
||||
}
|
||||
@@ -321,21 +321,21 @@ std::vector<std::pair<bool, boost::filesystem::path>> Storage::GetStaticFiles()
|
||||
|
||||
std::vector<std::pair<bool, boost::filesystem::path>> Storage::GetUpdatableFiles()
|
||||
{
|
||||
constexpr bool REQUIRED = true;
|
||||
constexpr bool OPTIONAL = false;
|
||||
constexpr bool IS_REQUIRED = true;
|
||||
constexpr bool IS_OPTIONAL = false;
|
||||
|
||||
std::vector<std::pair<bool, boost::filesystem::path>> files = {
|
||||
{OPTIONAL, config.GetPath(".osrm.mldgr")},
|
||||
{OPTIONAL, config.GetPath(".osrm.cell_metrics")},
|
||||
{OPTIONAL, config.GetPath(".osrm.hsgr")},
|
||||
{REQUIRED, config.GetPath(".osrm.datasource_names")},
|
||||
{REQUIRED, config.GetPath(".osrm.geometry")},
|
||||
{REQUIRED, config.GetPath(".osrm.turn_weight_penalties")},
|
||||
{REQUIRED, config.GetPath(".osrm.turn_duration_penalties")}};
|
||||
{IS_OPTIONAL, config.GetPath(".osrm.mldgr")},
|
||||
{IS_OPTIONAL, config.GetPath(".osrm.cell_metrics")},
|
||||
{IS_OPTIONAL, config.GetPath(".osrm.hsgr")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.datasource_names")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.geometry")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.turn_weight_penalties")},
|
||||
{IS_REQUIRED, config.GetPath(".osrm.turn_duration_penalties")}};
|
||||
|
||||
for (const auto &file : files)
|
||||
{
|
||||
if (file.first == REQUIRED && !boost::filesystem::exists(file.second))
|
||||
if (file.first == IS_REQUIRED && !boost::filesystem::exists(file.second))
|
||||
{
|
||||
throw util::exception("Could not find required filed: " + std::get<1>(file).string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user