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. // 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]; shortest_segment_1 = shortest_path_segments[0];
if (!alternative_path_segments.empty()) 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 // also pick the longest segment for the alternative path
alternative_segment_1 = alternative_path_segments[0]; 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 // compute the set difference (for shortest path) depending on names between shortest and
// alternative // alternative
std::vector<SegmentT> shortest_path_set_difference(shortest_path_segments.size()); std::vector<SegmentT> shortest_path_set_difference(shortest_path_segments.size());
tbb::parallel_sort(shortest_path_segments, name_id_comperator); std::sort(shortest_path_segments.begin(), shortest_path_segments.end(), name_id_comperator);
tbb::parallel_sort(alternative_path_segments, 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(), std::set_difference(shortest_path_segments.begin(), shortest_path_segments.end(),
alternative_path_segments.begin(), alternative_path_segments.end(), alternative_path_segments.begin(), alternative_path_segments.end(),
shortest_path_set_difference.begin(), name_id_comperator); 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 = shortest_segment_2 =
PickNextLongestSegment(shortest_path_set_difference, shortest_segment_1.name_id); 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(), shortest_path_segments.begin(), shortest_path_segments.end(),
alternative_path_set_difference.begin(), name_id_comperator); 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()) 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/json_util.hpp"
#include "../util/string_util.hpp" #include "../util/string_util.hpp"
#include <tbb/parallel_sort.h>
#include <cstdlib> #include <cstdlib>
#include <algorithm> #include <algorithm>
@ -99,8 +97,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
osrm::matching::CandidateLists &candidates_lists) osrm::matching::CandidateLists &candidates_lists)
{ {
double query_radius = 10 * gps_precision; double query_radius = 10 * gps_precision;
double last_distance = double last_distance = coordinate_calculation::great_circle_distance(input_coords[0], input_coords[1]);
coordinate_calculation::great_circle_distance(input_coords[0], input_coords[1]);
sub_trace_lengths.resize(input_coords.size()); sub_trace_lengths.resize(input_coords.size());
sub_trace_lengths[0] = 0; sub_trace_lengths[0] = 0;
@ -109,8 +106,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
bool allow_uturn = false; bool allow_uturn = false;
if (0 < current_coordinate) if (0 < current_coordinate)
{ {
last_distance = coordinate_calculation::great_circle_distance( last_distance = coordinate_calculation::great_circle_distance(input_coords[current_coordinate - 1], input_coords[current_coordinate]);
input_coords[current_coordinate - 1], input_coords[current_coordinate]);
sub_trace_lengths[current_coordinate] += sub_trace_lengths[current_coordinate] +=
sub_trace_lengths[current_coordinate - 1] + last_distance; 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); input_coords[current_coordinate], candidates, query_radius);
// sort by foward id, then by reverse id and then by distance // sort by foward id, then by reverse id and then by distance
tbb::parallel_sort( std::sort(candidates.begin(), candidates.end(),
candidates, [](const std::pair<PhantomNode, double> &lhs, [](const std::pair<PhantomNode, double>& lhs, const std::pair<PhantomNode, double>& rhs) {
const std::pair<PhantomNode, double> &rhs)
{
return lhs.first.forward_node_id < rhs.first.forward_node_id || return lhs.first.forward_node_id < rhs.first.forward_node_id ||
(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 || (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))); lhs.second < rhs.second)));
}); });
auto new_end = std::unique( auto new_end = std::unique(candidates.begin(), candidates.end(),
candidates.begin(), candidates.end(), [](const std::pair<PhantomNode, double> &lhs, [](const std::pair<PhantomNode, double>& lhs, const std::pair<PhantomNode, double>& rhs) {
const std::pair<PhantomNode, double> &rhs)
{
return lhs.first.forward_node_id == rhs.first.forward_node_id && return lhs.first.forward_node_id == rhs.first.forward_node_id &&
lhs.first.reverse_node_id == rhs.first.reverse_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 // sort by distance to make pruning effective
tbb::parallel_sort(candidates, [](const std::pair<PhantomNode, double> &lhs, std::sort(candidates.begin(), candidates.end(),
const std::pair<PhantomNode, double> &rhs) [](const std::pair<PhantomNode, double>& lhs, const std::pair<PhantomNode, double>& rhs) {
{
return lhs.second < rhs.second; return lhs.second < rhs.second;
}); });
@ -279,8 +270,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
const auto &input_timestamps = route_parameters.timestamps; const auto &input_timestamps = route_parameters.timestamps;
if (input_timestamps.size() > 0 && input_coords.size() != input_timestamps.size()) if (input_timestamps.size() > 0 && input_coords.size() != input_timestamps.size())
{ {
json_result.values["status"] = json_result.values["status"] = "Number of timestamps does not match number of coordinates .";
"Number of timestamps does not match number of coordinates .";
return 400; return 400;
} }
@ -299,8 +289,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
return 400; return 400;
} }
const bool found_candidates = getCandiates(input_coords, route_parameters.gps_precision, const bool found_candidates =
sub_trace_lengths, candidates_lists); getCandiates(input_coords, route_parameters.gps_precision, sub_trace_lengths, candidates_lists);
if (!found_candidates) if (!found_candidates)
{ {
json_result.values["status"] = "No suitable matching candidates found."; json_result.values["status"] = "No suitable matching candidates found.";