diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 0e44276f2..56abbd3b2 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -32,7 +32,11 @@ #include #include +#if TBB_VERSION_MAJOR == 2020 +#include +#else #include +#endif namespace osrm::extractor { @@ -567,8 +571,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( const constexpr unsigned GRAINSIZE = 100; // First part of the pipeline generates iterator ranges of IDs in sets of GRAINSIZE +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t> generator_stage( + tbb::filter::serial_in_order, [&](tbb::flow_control &fc) { +#else tbb::filter> generator_stage( tbb::filter_mode::serial_in_order, [&](tbb::flow_control &fc) { +#endif if (current_node < node_count) { auto next_node = std::min(current_node + GRAINSIZE, node_count); @@ -707,8 +716,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( // // Edge-based-graph stage // +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t, EdgesPipelineBufferPtr> processor_stage( + tbb::filter::parallel, +#else tbb::filter, EdgesPipelineBufferPtr> processor_stage( tbb::filter_mode::parallel, +#endif [&](const tbb::blocked_range &intersection_node_range) { auto buffer = std::make_shared(); buffer->nodes_processed = intersection_node_range.size(); @@ -1118,8 +1132,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( util::UnbufferedLog log; util::Percent routing_progress(log, node_count); std::vector delayed_data; +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t output_stage( + tbb::filter::serial_in_order, [&](auto buffer) { +#else tbb::filter output_stage( tbb::filter_mode::serial_in_order, [&](auto buffer) { +#endif routing_progress.PrintAddition(buffer->nodes_processed); m_connectivity_checksum = buffer->checksum.update_checksum(m_connectivity_checksum); diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index b2107bef1..3e4efa1da 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -44,7 +44,11 @@ #include #include #include +#if TBB_VERSION_MAJOR == 2020 +#include +#else #include +#endif #include #include @@ -443,8 +447,13 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting ExtractionRelationContainer relations; const auto buffer_reader = [](osmium::io::Reader &reader) { +#if TBB_VERSION_MAJOR == 2020 + return tbb::filter_t( + tbb::filter::serial_in_order, [&reader](tbb::flow_control &fc) { +#else return tbb::filter( tbb::filter_mode::serial_in_order, [&reader](tbb::flow_control &fc) { +#endif if (auto buffer = reader.read()) { return std::make_shared(std::move(buffer)); @@ -465,15 +474,25 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting osmium_index_type location_cache; osmium_location_handler_type location_handler(location_cache); +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t location_cacher( + tbb::filter::serial_in_order, [&location_handler](SharedBuffer buffer) { +#else tbb::filter location_cacher( tbb::filter_mode::serial_in_order, [&location_handler](SharedBuffer buffer) { +#endif osmium::apply(buffer->begin(), buffer->end(), location_handler); return buffer; }); // OSM elements Lua parser +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t buffer_transformer( + tbb::filter::parallel, +#else tbb::filter buffer_transformer( tbb::filter_mode::parallel, +#endif // NOLINTNEXTLINE(performance-unnecessary-value-param) [&](const SharedBuffer buffer) { ParsedBuffer parsed_buffer; @@ -494,8 +513,13 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting unsigned number_of_ways = 0; unsigned number_of_restrictions = 0; unsigned number_of_maneuver_overrides = 0; +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t buffer_storage( + tbb::filter::serial_in_order, [&](const ParsedBuffer &parsed_buffer) { +#else tbb::filter buffer_storage( tbb::filter_mode::serial_in_order, [&](const ParsedBuffer &parsed_buffer) { +#endif number_of_nodes += parsed_buffer.resulting_nodes.size(); // put parsed objects thru extractor callbacks for (const auto &result : parsed_buffer.resulting_nodes) @@ -521,8 +545,13 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting } }); +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t> buffer_relation_cache( + tbb::filter::parallel, +#else tbb::filter> buffer_relation_cache( tbb::filter_mode::parallel, +#endif // NOLINTNEXTLINE(performance-unnecessary-value-param) [&](const SharedBuffer buffer) { if (!buffer) @@ -559,8 +588,13 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting }); unsigned number_of_relations = 0; +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t, void> buffer_storage_relation( + tbb::filter::serial_in_order, +#else tbb::filter, void> buffer_storage_relation( tbb::filter_mode::serial_in_order, +#endif // NOLINTNEXTLINE(performance-unnecessary-value-param) [&](const std::shared_ptr parsed_relations) { number_of_relations += parsed_relations->GetRelationsNum(); diff --git a/src/guidance/guidance_processing.cpp b/src/guidance/guidance_processing.cpp index 0c510b54b..e12329743 100644 --- a/src/guidance/guidance_processing.cpp +++ b/src/guidance/guidance_processing.cpp @@ -9,7 +9,11 @@ #include "util/percent.hpp" #include +#if TBB_VERSION_MAJOR == 2020 +#include +#else #include +#endif #include @@ -95,8 +99,13 @@ 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 +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t> generator_stage( + tbb::filter::serial_in_order, [&](tbb::flow_control &fc) { +#else tbb::filter> generator_stage( tbb::filter_mode::serial_in_order, [&](tbb::flow_control &fc) { +#endif if (current_node < node_count) { auto next_node = std::min(current_node + GRAINSIZE, node_count); @@ -114,8 +123,13 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, // // Guidance stage // +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t, TurnsPipelineBufferPtr> guidance_stage( + tbb::filter::parallel, +#else tbb::filter, TurnsPipelineBufferPtr> guidance_stage( tbb::filter_mode::parallel, +#endif [&](const tbb::blocked_range &intersection_node_range) { auto buffer = std::make_shared(); buffer->nodes_processed = intersection_node_range.size(); @@ -306,8 +320,13 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, util::Percent guidance_progress(log, node_count); std::vector delayed_turn_data; +#if TBB_VERSION_MAJOR == 2020 + tbb::filter_t guidance_output_stage( + tbb::filter::serial_in_order, [&](auto buffer) { +#else tbb::filter guidance_output_stage( tbb::filter_mode::serial_in_order, [&](auto buffer) { +#endif guidance_progress.PrintAddition(buffer->nodes_processed); connectivity_checksum = buffer->checksum.update_checksum(connectivity_checksum); diff --git a/src/partitioner/recursive_bisection.cpp b/src/partitioner/recursive_bisection.cpp index de9e509d9..dea3f1f71 100644 --- a/src/partitioner/recursive_bisection.cpp +++ b/src/partitioner/recursive_bisection.cpp @@ -62,12 +62,20 @@ RecursiveBisection::RecursiveBisection(BisectionGraph &bisection_graph_, return TreeNode{std::move(graph), internal_state.SCCDepth()}; }); +#if TBB_VERSION_MAJOR == 2020 + using Feeder = tbb::parallel_do_feeder; +#else using Feeder = tbb::feeder; +#endif TIMER_START(bisection); // Bisect graph into two parts. Get partition point and recurse left and right in parallel. +#if TBB_VERSION_MAJOR == 2020 + tbb::parallel_do(begin(forest), end(forest), [&](const TreeNode &node, Feeder &feeder) { +#else tbb::parallel_for_each(begin(forest), end(forest), [&](const TreeNode &node, Feeder &feeder) { +#endif const auto cut = computeInertialFlowCut(node.graph, num_optimizing_cuts, balance, boundary_factor); const auto center = internal_state.ApplyBisection(