Parallelize generation of the edge-expanded-edges.

This commit is contained in:
Daniel Patterson
2017-06-06 21:31:07 -07:00
committed by Patrick Niklaus
parent b68d79407e
commit 35550d8c0a
12 changed files with 425 additions and 240 deletions
@@ -18,6 +18,7 @@
#include "extractor/query_node.hpp"
#include "extractor/restriction_map.hpp"
#include "util/concurrent_id_map.hpp"
#include "util/deallocating_vector.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
@@ -41,6 +42,9 @@
#include <boost/filesystem/fstream.hpp>
#include <tbb/concurrent_unordered_map.h>
#include <tbb/concurrent_vector.h>
namespace osrm
{
namespace extractor
@@ -167,9 +171,9 @@ class EdgeBasedGraphFactory
std::size_t skipped_uturns_counter;
std::size_t skipped_barrier_turns_counter;
std::unordered_map<util::guidance::BearingClass, BearingClassID> bearing_class_hash;
util::ConcurrentIDMap<util::guidance::BearingClass, BearingClassID> bearing_class_hash;
std::vector<BearingClassID> bearing_class_by_node_based_node;
std::unordered_map<util::guidance::EntryClass, EntryClassID> entry_class_hash;
util::ConcurrentIDMap<util::guidance::EntryClass, EntryClassID> entry_class_hash;
};
} // namespace extractor
} // namespace osrm
@@ -65,12 +65,16 @@ const constexpr char *scenario_names[] = {"Simple",
class TurnLaneHandler
{
using UpgradableMutex = boost::interprocess::interprocess_upgradable_mutex;
using ScopedReaderLock = boost::interprocess::sharable_lock<UpgradableMutex>;
using ScopedWriterLock = boost::interprocess::scoped_lock<UpgradableMutex>;
public:
typedef std::vector<TurnLaneData> LaneDataVector;
TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
std::vector<std::uint32_t> &turn_lane_offsets,
std::vector<TurnLaneType::Mask> &turn_lane_masks,
const std::vector<std::uint32_t> &turn_lane_offsets,
const std::vector<TurnLaneType::Mask> &turn_lane_masks,
LaneDescriptionMap &lane_description_map,
const TurnAnalysis &turn_analysis,
util::guidance::LaneDataIdMap &id_map);
@@ -86,8 +90,8 @@ class TurnLaneHandler
// we need to be able to look at previous intersections to, in some cases, find the correct turn
// lanes for a turn
const util::NodeBasedDynamicGraph &node_based_graph;
std::vector<std::uint32_t> &turn_lane_offsets;
std::vector<TurnLaneType::Mask> &turn_lane_masks;
const std::vector<std::uint32_t> &turn_lane_offsets;
const std::vector<TurnLaneType::Mask> &turn_lane_masks;
LaneDescriptionMap &lane_description_map;
const TurnAnalysis &turn_analysis;
util::guidance::LaneDataIdMap &id_map;
@@ -10,6 +10,7 @@
#include <boost/functional/hash.hpp>
#include "util/concurrent_id_map.hpp"
#include "util/json_container.hpp"
#include "util/typedefs.hpp"
@@ -93,9 +94,9 @@ struct TurnLaneDescription_hash
}
};
typedef std::unordered_map<guidance::TurnLaneDescription,
LaneDescriptionID,
guidance::TurnLaneDescription_hash>
typedef util::ConcurrentIDMap<guidance::TurnLaneDescription,
LaneDescriptionID,
guidance::TurnLaneDescription_hash>
LaneDescriptionMap;
} // guidance
+22 -10
View File
@@ -31,6 +31,15 @@ void write(storage::io::FileWriter &writer,
const detail::TurnDataContainerImpl<Ownership> &turn_data);
}
struct TurnData
{
extractor::guidance::TurnInstruction turn_instruction;
LaneDataID lane_data_id;
EntryClassID entry_class_id;
util::guidance::TurnBearing pre_turn_bearing;
util::guidance::TurnBearing post_turn_bearing;
};
namespace detail
{
template <storage::Ownership Ownership> class TurnDataContainerImpl
@@ -75,17 +84,20 @@ template <storage::Ownership Ownership> class TurnDataContainerImpl
// Used by EdgeBasedGraphFactory to fill data structure
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
void push_back(extractor::guidance::TurnInstruction turn_instruction,
LaneDataID lane_data_id,
EntryClassID entry_class_id,
util::guidance::TurnBearing pre_turn_bearing,
util::guidance::TurnBearing post_turn_bearing)
void push_back(const TurnData &data)
{
turn_instructions.push_back(turn_instruction);
lane_data_ids.push_back(lane_data_id);
entry_class_ids.push_back(entry_class_id);
pre_turn_bearings.push_back(pre_turn_bearing);
post_turn_bearings.push_back(post_turn_bearing);
turn_instructions.push_back(data.turn_instruction);
lane_data_ids.push_back(data.lane_data_id);
entry_class_ids.push_back(data.entry_class_id);
pre_turn_bearings.push_back(data.pre_turn_bearing);
post_turn_bearings.push_back(data.post_turn_bearing);
}
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
void append(const std::vector<TurnData> &others)
{
std::for_each(
others.begin(), others.end(), [this](const TurnData &other) { push_back(other); });
}
friend void serialization::read<Ownership>(storage::io::FileReader &reader,