Deprecated tbb::task_scheduler_init replaced with std::thread and tbb::global_control
This commit is contained in:
@@ -6,7 +6,12 @@
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <tbb/tbb_stddef.h> // For version lookup
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
#endif
|
||||
|
||||
using namespace osrm;
|
||||
using namespace osrm::contractor;
|
||||
@@ -16,7 +21,11 @@ BOOST_AUTO_TEST_SUITE(graph_contractor)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(contract_graph)
|
||||
{
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
tbb::global_control scheduler(tbb::global_control::max_allowed_parallelism, 1);
|
||||
#else
|
||||
tbb::task_scheduler_init scheduler(1);
|
||||
#endif
|
||||
/*
|
||||
* <--1--<
|
||||
* (0) >--3--> (1) >--3--> (3)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "osrm/contractor.hpp"
|
||||
#include "osrm/contractor_config.hpp"
|
||||
|
||||
#include <tbb/task_scheduler_init.h> // default_num_threads
|
||||
#include <thread>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_contract)
|
||||
|
||||
@@ -13,7 +13,7 @@ BOOST_AUTO_TEST_CASE(test_contract_with_invalid_config)
|
||||
using namespace osrm;
|
||||
|
||||
osrm::ContractorConfig config;
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_THROW(osrm::contract(config),
|
||||
std::exception); // including osrm::util::exception, etc.
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "osrm/customizer.hpp"
|
||||
#include "osrm/customizer_config.hpp"
|
||||
|
||||
#include <tbb/task_scheduler_init.h> // default_num_threads
|
||||
#include <thread>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_customize)
|
||||
|
||||
@@ -13,7 +13,7 @@ BOOST_AUTO_TEST_CASE(test_customize_with_invalid_config)
|
||||
using namespace osrm;
|
||||
|
||||
osrm::CustomizationConfig config;
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_THROW(osrm::customize(config),
|
||||
std::exception); // including osrm::util::exception, etc.
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
#include "osrm/extractor.hpp"
|
||||
#include "osrm/extractor_config.hpp"
|
||||
|
||||
#include <tbb/task_scheduler_init.h> // default_num_threads
|
||||
#include <thread>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_extract)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_extract_with_invalid_config)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_THROW(osrm::extract(config),
|
||||
std::exception); // including osrm::util::exception, osmium::io_error, etc.
|
||||
}
|
||||
@@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_NO_THROW(osrm::extract(config));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "osrm/partitioner.hpp"
|
||||
#include "osrm/partitioner_config.hpp"
|
||||
|
||||
#include <tbb/task_scheduler_init.h> // default_num_threads
|
||||
#include <thread>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_partition)
|
||||
|
||||
@@ -13,7 +13,7 @@ BOOST_AUTO_TEST_CASE(test_partition_with_invalid_config)
|
||||
using namespace osrm;
|
||||
|
||||
osrm::PartitionerConfig config;
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||
BOOST_CHECK_THROW(osrm::partition(config),
|
||||
std::exception); // including osrm::util::exception, etc.
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
// make sure not to leak in recursive bisection
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
tbb::global_control scheduler(tbb::global_control::max_allowed_parallelism, 2);
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
tbb::task_scheduler_init init(2);
|
||||
#endif
|
||||
|
||||
using namespace osrm::partitioner;
|
||||
using namespace osrm::util;
|
||||
|
||||
@@ -26,10 +26,14 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
|
||||
// explicit TBB scheduler init to register resources cleanup at exit
|
||||
#if TBB_VERSION_MAJOR == 2020
|
||||
#include <tbb/global_control.h>
|
||||
tbb::global_control scheduler(tbb::global_control::max_allowed_parallelism, 2);
|
||||
#else
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
tbb::task_scheduler_init init(2);
|
||||
#endif
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(static_rtree)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user