Revert parallelization on server part. Let node do this.

This reverts @6b2bf49 on the server components.

We do not want to parallelize there, as node should be used for
parallelizing the user requests onto multiple processes.
This commit is contained in:
Daniel J. Hofmann 2015-09-09 18:04:21 +02:00
parent 9231335eef
commit c526bec798
2 changed files with 28 additions and 34 deletions

View File

@ -88,11 +88,12 @@ template <class DataFacadeT, class SegmentT> struct ExtractRouteNames
}
// pick the longest segment for the shortest path.
tbb::parallel_sort(shortest_path_segments, length_comperator);
std::sort(shortest_path_segments.begin(), shortest_path_segments.end(), length_comperator);
shortest_segment_1 = shortest_path_segments[0];
if (!alternative_path_segments.empty())
{
tbb::parallel_sort(alternative_path_segments, length_comperator);
std::sort(alternative_path_segments.begin(), alternative_path_segments.end(),
length_comperator);
// also pick the longest segment for the alternative path
alternative_segment_1 = alternative_path_segments[0];
@ -101,13 +102,15 @@ template <class DataFacadeT, class SegmentT> struct ExtractRouteNames
// compute the set difference (for shortest path) depending on names between shortest and
// alternative
std::vector<SegmentT> shortest_path_set_difference(shortest_path_segments.size());
tbb::parallel_sort(shortest_path_segments, name_id_comperator);
tbb::parallel_sort(alternative_path_segments, name_id_comperator);
std::sort(shortest_path_segments.begin(), shortest_path_segments.end(), name_id_comperator);
std::sort(alternative_path_segments.begin(), alternative_path_segments.end(),
name_id_comperator);
std::set_difference(shortest_path_segments.begin(), shortest_path_segments.end(),
alternative_path_segments.begin(), alternative_path_segments.end(),
shortest_path_set_difference.begin(), name_id_comperator);
tbb::parallel_sort(shortest_path_set_difference, length_comperator);
std::sort(shortest_path_set_difference.begin(), shortest_path_set_difference.end(),
length_comperator);
shortest_segment_2 =
PickNextLongestSegment(shortest_path_set_difference, shortest_segment_1.name_id);
@ -124,7 +127,8 @@ template <class DataFacadeT, class SegmentT> struct ExtractRouteNames
shortest_path_segments.begin(), shortest_path_segments.end(),
alternative_path_set_difference.begin(), name_id_comperator);
tbb::parallel_sort(alternative_path_set_difference, length_comperator);
std::sort(alternative_path_set_difference.begin(), alternative_path_set_difference.end(),
length_comperator);
if (!alternative_path_segments.empty())
{

View File

@ -42,8 +42,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../util/json_util.hpp"
#include "../util/string_util.hpp"
#include <tbb/parallel_sort.h>
#include <cstdlib>
#include <algorithm>
@ -99,8 +97,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
osrm::matching::CandidateLists &candidates_lists)
{
double query_radius = 10 * gps_precision;
double last_distance =
coordinate_calculation::great_circle_distance(input_coords[0], input_coords[1]);
double last_distance = coordinate_calculation::great_circle_distance(input_coords[0], input_coords[1]);
sub_trace_lengths.resize(input_coords.size());
sub_trace_lengths[0] = 0;
@ -109,8 +106,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
bool allow_uturn = false;
if (0 < current_coordinate)
{
last_distance = coordinate_calculation::great_circle_distance(
input_coords[current_coordinate - 1], input_coords[current_coordinate]);
last_distance = coordinate_calculation::great_circle_distance(input_coords[current_coordinate - 1], input_coords[current_coordinate]);
sub_trace_lengths[current_coordinate] +=
sub_trace_lengths[current_coordinate - 1] + last_distance;
@ -134,10 +130,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
input_coords[current_coordinate], candidates, query_radius);
// sort by foward id, then by reverse id and then by distance
tbb::parallel_sort(
candidates, [](const std::pair<PhantomNode, double> &lhs,
const std::pair<PhantomNode, double> &rhs)
{
std::sort(candidates.begin(), candidates.end(),
[](const std::pair<PhantomNode, double>& lhs, const std::pair<PhantomNode, double>& rhs) {
return lhs.first.forward_node_id < rhs.first.forward_node_id ||
(lhs.first.forward_node_id == rhs.first.forward_node_id &&
(lhs.first.reverse_node_id < rhs.first.reverse_node_id ||
@ -145,10 +139,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
lhs.second < rhs.second)));
});
auto new_end = std::unique(
candidates.begin(), candidates.end(), [](const std::pair<PhantomNode, double> &lhs,
const std::pair<PhantomNode, double> &rhs)
{
auto new_end = std::unique(candidates.begin(), candidates.end(),
[](const std::pair<PhantomNode, double>& lhs, const std::pair<PhantomNode, double>& rhs) {
return lhs.first.forward_node_id == rhs.first.forward_node_id &&
lhs.first.reverse_node_id == rhs.first.reverse_node_id;
});
@ -173,9 +165,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
}
// sort by distance to make pruning effective
tbb::parallel_sort(candidates, [](const std::pair<PhantomNode, double> &lhs,
const std::pair<PhantomNode, double> &rhs)
{
std::sort(candidates.begin(), candidates.end(),
[](const std::pair<PhantomNode, double>& lhs, const std::pair<PhantomNode, double>& rhs) {
return lhs.second < rhs.second;
});
@ -279,8 +270,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
const auto &input_timestamps = route_parameters.timestamps;
if (input_timestamps.size() > 0 && input_coords.size() != input_timestamps.size())
{
json_result.values["status"] =
"Number of timestamps does not match number of coordinates .";
json_result.values["status"] = "Number of timestamps does not match number of coordinates .";
return 400;
}
@ -299,8 +289,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
return 400;
}
const bool found_candidates = getCandiates(input_coords, route_parameters.gps_precision,
sub_trace_lengths, candidates_lists);
const bool found_candidates =
getCandiates(input_coords, route_parameters.gps_precision, sub_trace_lengths, candidates_lists);
if (!found_candidates)
{
json_result.values["status"] = "No suitable matching candidates found.";