Skip to content
Closed
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
19 changes: 19 additions & 0 deletions src/extractor/edge_based_graph_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@

#include <tbb/blocked_range.h>
#include <tbb/parallel_for.h>
#if TBB_VERSION_MAJOR == 2020
#include <tbb/pipeline.h>
#else
#include <tbb/parallel_pipeline.h>
#endif

namespace osrm
{
Expand Down Expand Up @@ -569,8 +573,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<void, tbb::blocked_range<NodeID>> generator_stage(
tbb::filter::serial_in_order, [&](tbb::flow_control &fc) {
#else
tbb::filter<void, tbb::blocked_range<NodeID>> 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);
Expand Down Expand Up @@ -709,8 +718,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
//
// Edge-based-graph stage
//
#if TBB_VERSION_MAJOR == 2020
tbb::filter_t<tbb::blocked_range<NodeID>, EdgesPipelineBufferPtr> processor_stage(
tbb::filter::parallel,
#else
tbb::filter<tbb::blocked_range<NodeID>, EdgesPipelineBufferPtr> processor_stage(
tbb::filter_mode::parallel,
#endif
[&](const tbb::blocked_range<NodeID> &intersection_node_range) {
auto buffer = std::make_shared<EdgesPipelineBuffer>();
buffer->nodes_processed = intersection_node_range.size();
Expand Down Expand Up @@ -1120,8 +1134,13 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
util::UnbufferedLog log;
util::Percent routing_progress(log, node_count);
std::vector<EdgeWithData> delayed_data;
#if TBB_VERSION_MAJOR == 2020
tbb::filter_t<EdgesPipelineBufferPtr, void> output_stage(
tbb::filter::serial_in_order, [&](auto buffer) {
#else
tbb::filter<EdgesPipelineBufferPtr, void> 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);
Expand Down
34 changes: 34 additions & 0 deletions src/extractor/extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
#include <osmium/thread/pool.hpp>
#include <osmium/visitor.hpp>
#include <tbb/global_control.h>
#if TBB_VERSION_MAJOR == 2020
#include <tbb/pipeline.h>
#else
#include <tbb/parallel_pipeline.h>
#endif

#include <algorithm>
#include <atomic>
Expand Down Expand Up @@ -445,8 +449,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<void, SharedBuffer>(
tbb::filter::serial_in_order, [&reader](tbb::flow_control &fc) {
#else
return tbb::filter<void, SharedBuffer>(
tbb::filter_mode::serial_in_order, [&reader](tbb::flow_control &fc) {
#endif
if (auto buffer = reader.read())
{
return std::make_shared<osmium::memory::Buffer>(std::move(buffer));
Expand All @@ -467,15 +476,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<SharedBuffer, SharedBuffer> location_cacher(
tbb::filter::serial_in_order, [&location_handler](SharedBuffer buffer) {
#else
tbb::filter<SharedBuffer, SharedBuffer> 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<SharedBuffer, ParsedBuffer> buffer_transformer(
tbb::filter::parallel,
#else
tbb::filter<SharedBuffer, ParsedBuffer> buffer_transformer(
tbb::filter_mode::parallel,
#endif
// NOLINTNEXTLINE(performance-unnecessary-value-param)
[&](const SharedBuffer buffer) {
ParsedBuffer parsed_buffer;
Expand All @@ -496,8 +515,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<ParsedBuffer, void> buffer_storage(
tbb::filter::serial_in_order, [&](const ParsedBuffer &parsed_buffer) {
#else
tbb::filter<ParsedBuffer, void> 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)
Expand All @@ -523,8 +547,13 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting
}
});

#if TBB_VERSION_MAJOR == 2020
tbb::filter_t<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
tbb::filter::parallel,
#else
tbb::filter<SharedBuffer, std::shared_ptr<ExtractionRelationContainer>> buffer_relation_cache(
tbb::filter_mode::parallel,
#endif
// NOLINTNEXTLINE(performance-unnecessary-value-param)
[&](const SharedBuffer buffer) {
if (!buffer)
Expand Down Expand Up @@ -561,8 +590,13 @@ Extractor::ParsedOSMData Extractor::ParseOSMData(ScriptingEnvironment &scripting
});

unsigned number_of_relations = 0;
#if TBB_VERSION_MAJOR == 2020
tbb::filter_t<std::shared_ptr<ExtractionRelationContainer>, void> buffer_storage_relation(
tbb::filter::serial_in_order,
#else
tbb::filter<std::shared_ptr<ExtractionRelationContainer>, void> buffer_storage_relation(
tbb::filter_mode::serial_in_order,
#endif
// NOLINTNEXTLINE(performance-unnecessary-value-param)
[&](const std::shared_ptr<ExtractionRelationContainer> parsed_relations) {
number_of_relations += parsed_relations->GetRelationsNum();
Expand Down
19 changes: 19 additions & 0 deletions src/guidance/guidance_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#include "util/percent.hpp"

#include <tbb/blocked_range.h>
#if TBB_VERSION_MAJOR == 2020
#include <tbb/pipeline.h>
#else
#include <tbb/parallel_pipeline.h>
#endif

#include <thread>

Expand Down Expand Up @@ -97,8 +101,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<void, tbb::blocked_range<NodeID>> generator_stage(
tbb::filter::serial_in_order, [&](tbb::flow_control &fc) {
#else
tbb::filter<void, tbb::blocked_range<NodeID>> 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);
Expand All @@ -116,8 +125,13 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
//
// Guidance stage
//
#if TBB_VERSION_MAJOR == 2020
tbb::filter_t<tbb::blocked_range<NodeID>, TurnsPipelineBufferPtr> guidance_stage(
tbb::filter::parallel,
#else
tbb::filter<tbb::blocked_range<NodeID>, TurnsPipelineBufferPtr> guidance_stage(
tbb::filter_mode::parallel,
#endif
[&](const tbb::blocked_range<NodeID> &intersection_node_range) {
auto buffer = std::make_shared<TurnsPipelineBuffer>();
buffer->nodes_processed = intersection_node_range.size();
Expand Down Expand Up @@ -308,8 +322,13 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
util::Percent guidance_progress(log, node_count);
std::vector<guidance::TurnData> delayed_turn_data;

#if TBB_VERSION_MAJOR == 2020
tbb::filter_t<TurnsPipelineBufferPtr, void> guidance_output_stage(
tbb::filter::serial_in_order, [&](auto buffer) {
#else
tbb::filter<TurnsPipelineBufferPtr, void> 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);
Expand Down
8 changes: 8 additions & 0 deletions src/partitioner/recursive_bisection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,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<TreeNode>;
#else
using Feeder = tbb::feeder<TreeNode>;
#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(
Expand Down