|
55 | 55 | #include <osmium/thread/pool.hpp> |
56 | 56 | #include <osmium/visitor.hpp> |
57 | 57 |
|
58 | | -#include <tbb/pipeline.h> |
| 58 | +#if TBB_VERSION_MAJOR == 2020 |
| 59 | +#include <tbb/global_control.h> |
| 60 | +#else |
59 | 61 | #include <tbb/task_scheduler_init.h> |
| 62 | +#endif |
| 63 | +#include <tbb/pipeline.h> |
60 | 64 |
|
61 | 65 | #include <cstdlib> |
62 | 66 |
|
@@ -214,11 +218,16 @@ int Extractor::run(ScriptingEnvironment &scripting_environment) |
214 | 218 | { |
215 | 219 | util::LogPolicy::GetInstance().Unmute(); |
216 | 220 |
|
217 | | - const unsigned recommended_num_threads = tbb::task_scheduler_init::default_num_threads(); |
| 221 | + const unsigned recommended_num_threads = std::thread::hardware_concurrency(); |
218 | 222 | const auto number_of_threads = std::min(recommended_num_threads, config.requested_num_threads); |
219 | | - tbb::task_scheduler_init init(number_of_threads ? number_of_threads |
220 | | - : tbb::task_scheduler_init::automatic); |
| 223 | + |
| 224 | +#if TBB_VERSION_MAJOR == 2020 |
| 225 | + tbb::global_control gc(tbb::global_control::max_allowed_parallelism, |
| 226 | + config.requested_num_threads); |
| 227 | +#else |
| 228 | + tbb::task_scheduler_init init(config.requested_num_threads); |
221 | 229 | BOOST_ASSERT(init.is_active()); |
| 230 | +#endif |
222 | 231 |
|
223 | 232 | LaneDescriptionMap turn_lane_map; |
224 | 233 | std::vector<TurnRestriction> turn_restrictions; |
@@ -604,7 +613,7 @@ Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment, |
604 | 613 |
|
605 | 614 | // Parse OSM elements with parallel transformer |
606 | 615 | // Number of pipeline tokens that yielded the best speedup was about 1.5 * num_cores |
607 | | - const auto num_threads = tbb::task_scheduler_init::default_num_threads() * 1.5; |
| 616 | + const auto num_threads = std::thread::hardware_concurrency() * 1.5; |
608 | 617 | const auto read_meta = |
609 | 618 | config.use_metadata ? osmium::io::read_meta::yes : osmium::io::read_meta::no; |
610 | 619 |
|
|
0 commit comments