2014-11-28 04:29:56 -05:00
|
|
|
#include "contractor/processing_chain.hpp"
|
2015-04-24 08:51:25 -04:00
|
|
|
#include "contractor/contractor_options.hpp"
|
2015-02-09 11:38:40 -05:00
|
|
|
#include "util/simple_logger.hpp"
|
2014-05-06 12:15:45 -04:00
|
|
|
|
2015-02-09 11:38:40 -05:00
|
|
|
#include <boost/program_options/errors.hpp>
|
|
|
|
|
2015-04-24 08:51:25 -04:00
|
|
|
#include <tbb/task_scheduler_init.h>
|
|
|
|
|
2015-10-18 06:19:06 -04:00
|
|
|
#include <cstdlib>
|
2015-02-09 11:38:40 -05:00
|
|
|
#include <exception>
|
2015-10-18 06:34:42 -04:00
|
|
|
#include <new>
|
2016-01-03 12:55:42 -05:00
|
|
|
#include <ostream>
|
2014-05-08 13:40:29 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
using namespace osrm;
|
|
|
|
|
2015-10-18 06:19:06 -04:00
|
|
|
int main(int argc, char *argv[]) try
|
2014-05-08 13:40:29 -04:00
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::LogPolicy::GetInstance().Unmute();
|
|
|
|
contractor::ContractorConfig contractor_config;
|
2015-10-18 06:19:06 -04:00
|
|
|
|
2016-01-07 19:31:57 -05:00
|
|
|
const contractor::return_code result =
|
|
|
|
contractor::ContractorOptions::ParseArguments(argc, argv, contractor_config);
|
2015-10-18 06:19:06 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
if (contractor::return_code::fail == result)
|
2014-05-08 13:40:29 -04:00
|
|
|
{
|
2015-10-18 06:34:42 -04:00
|
|
|
return EXIT_FAILURE;
|
2014-05-08 13:40:29 -04:00
|
|
|
}
|
2015-10-18 06:19:06 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
if (contractor::return_code::exit == result)
|
2014-05-08 13:40:29 -04:00
|
|
|
{
|
2015-10-18 06:34:42 -04:00
|
|
|
return EXIT_SUCCESS;
|
2015-10-18 06:19:06 -04:00
|
|
|
}
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
contractor::ContractorOptions::GenerateOutputFilesNames(contractor_config);
|
2015-10-18 06:19:06 -04:00
|
|
|
|
|
|
|
if (1 > contractor_config.requested_num_threads)
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger";
|
2015-10-18 06:34:42 -04:00
|
|
|
return EXIT_FAILURE;
|
2013-10-14 11:03:46 -04:00
|
|
|
}
|
2015-10-18 06:19:06 -04:00
|
|
|
|
|
|
|
const unsigned recommended_num_threads = tbb::task_scheduler_init::default_num_threads();
|
|
|
|
|
|
|
|
if (recommended_num_threads != contractor_config.requested_num_threads)
|
|
|
|
{
|
2016-01-07 19:31:57 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING)
|
|
|
|
<< "The recommended number of threads is " << recommended_num_threads
|
|
|
|
<< "! This setting may have performance side-effects.";
|
2015-10-18 06:19:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!boost::filesystem::is_regular_file(contractor_config.osrm_input_path))
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING)
|
2015-10-18 06:19:06 -04:00
|
|
|
<< "Input file " << contractor_config.osrm_input_path.string() << " not found!";
|
2015-10-18 06:34:42 -04:00
|
|
|
return EXIT_FAILURE;
|
2015-10-18 06:19:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!boost::filesystem::is_regular_file(contractor_config.profile_path))
|
|
|
|
{
|
2016-01-07 19:31:57 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING)
|
|
|
|
<< "Profile " << contractor_config.profile_path.string() << " not found!";
|
2015-10-18 06:34:42 -04:00
|
|
|
return EXIT_FAILURE;
|
2015-10-18 06:19:06 -04:00
|
|
|
}
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "Input file: "
|
2016-01-07 19:31:57 -05:00
|
|
|
<< contractor_config.osrm_input_path.filename().string();
|
|
|
|
util::SimpleLogger().Write() << "Profile: "
|
|
|
|
<< contractor_config.profile_path.filename().string();
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write() << "Threads: " << contractor_config.requested_num_threads;
|
2015-10-18 06:19:06 -04:00
|
|
|
|
|
|
|
tbb::task_scheduler_init init(contractor_config.requested_num_threads);
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
return contractor::Prepare(contractor_config).Run();
|
2015-10-18 06:19:06 -04:00
|
|
|
}
|
2015-10-18 06:34:42 -04:00
|
|
|
catch (const std::bad_alloc &e)
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
|
|
|
util::SimpleLogger().Write(logWARNING)
|
2015-10-18 06:34:42 -04:00
|
|
|
<< "Please provide more memory or consider using a larger swapfile";
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2015-10-18 06:19:06 -04:00
|
|
|
catch (const std::exception &e)
|
|
|
|
{
|
2016-01-05 10:51:13 -05:00
|
|
|
util::SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
|
2015-10-18 06:19:06 -04:00
|
|
|
return EXIT_FAILURE;
|
2013-10-14 11:03:46 -04:00
|
|
|
}
|