Replace bool for using shared memory with MemorySetting enum

This commit is contained in:
Pepijn Schoen 2017-03-29 14:06:52 +02:00 committed by Patrick Niklaus
parent 70b3962c35
commit 266e65e6d2
22 changed files with 211 additions and 184 deletions

View File

@ -7,6 +7,8 @@
#include "util/static_graph.hpp"
#include "util/typedefs.hpp"
#include "storage/shared_memory.hpp"
#include <boost/filesystem/path.hpp>
namespace osrm
@ -16,16 +18,16 @@ namespace customizer
using EdgeBasedGraphEdgeData = partition::EdgeBasedGraphEdgeData;
struct MultiLevelEdgeBasedGraph : public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, false>
struct MultiLevelEdgeBasedGraph : public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::MemorySetting::InternalMemory>
{
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, false>;
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::MemorySetting::InternalMemory>;
using Base::Base;
};
struct MultiLevelEdgeBasedGraphView
: public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, true>
: public partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::MemorySetting::SharedMemory>
{
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, true>;
using Base = partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::MemorySetting::SharedMemory>;
using Base::Base;
};

View File

@ -20,6 +20,7 @@
#include "partition/multi_level_partition.hpp"
#include "storage/shared_datatype.hpp"
#include "storage/shared_memory.hpp"
#include "util/exception.hpp"
#include "util/exception_utils.hpp"
@ -61,7 +62,7 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH>
: public datafacade::AlgorithmDataFacade<algorithm::CH>
{
private:
using QueryGraph = util::StaticGraph<EdgeData, true>;
using QueryGraph = util::StaticGraph<EdgeData, osrm::storage::MemorySetting::SharedMemory>;
using GraphNode = QueryGraph::NodeArrayEntry;
using GraphEdge = QueryGraph::EdgeArrayEntry;
@ -78,9 +79,9 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH>
auto graph_edges_ptr = data_layout.GetBlockPtr<GraphEdge>(
memory_block, storage::DataLayout::CH_GRAPH_EDGE_LIST);
util::ShM<GraphNode, true>::vector node_list(
util::ShM<GraphNode, osrm::storage::MemorySetting::SharedMemory>::vector node_list(
graph_nodes_ptr, data_layout.num_entries[storage::DataLayout::CH_GRAPH_NODE_LIST]);
util::ShM<GraphEdge, true>::vector edge_list(
util::ShM<GraphEdge, osrm::storage::MemorySetting::SharedMemory>::vector edge_list(
graph_edges_ptr, data_layout.num_entries[storage::DataLayout::CH_GRAPH_EDGE_LIST]);
m_query_graph.reset(new QueryGraph(node_list, edge_list));
}
@ -154,7 +155,7 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CoreCH>
: public datafacade::AlgorithmDataFacade<algorithm::CoreCH>
{
private:
util::ShM<bool, true>::vector m_is_core_node;
util::ShM<unsigned, osrm::storage::MemorySetting::SharedMemory>::vector m_is_core_node;
// allocator that keeps the allocation data
std::shared_ptr<ContiguousBlockAllocator> allocator;
@ -163,7 +164,7 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CoreCH>
{
auto core_marker_ptr =
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::CH_CORE_MARKER);
util::ShM<bool, true>::vector is_core_node(
util::ShM<unsigned, osrm::storage::MemorySetting::SharedMemory>::vector is_core_node(
core_marker_ptr, data_layout.num_entries[storage::DataLayout::CH_CORE_MARKER]);
m_is_core_node = std::move(is_core_node);
}
@ -199,10 +200,10 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
private:
using super = BaseDataFacade;
using IndexBlock = util::RangeTable<16, true>::BlockT;
using IndexBlock = util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>::BlockT;
using RTreeLeaf = super::RTreeLeaf;
using SharedRTree =
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, true>::vector, true>;
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, osrm::storage::MemorySetting::SharedMemory>::vector, osrm::storage::MemorySetting::SharedMemory>;
using SharedGeospatialQuery = GeospatialQuery<SharedRTree, BaseDataFacade>;
using RTreeNode = SharedRTree::TreeNode;
@ -211,28 +212,28 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
extractor::Datasources *m_datasources;
unsigned m_check_sum;
util::ShM<util::Coordinate, true>::vector m_coordinate_list;
util::PackedVector<OSMNodeID, true> m_osmnodeid_list;
util::ShM<GeometryID, true>::vector m_via_geometry_list;
util::ShM<NameID, true>::vector m_name_ID_list;
util::ShM<LaneDataID, true>::vector m_lane_data_id;
util::ShM<extractor::guidance::TurnInstruction, true>::vector m_turn_instruction_list;
util::ShM<extractor::TravelMode, true>::vector m_travel_mode_list;
util::ShM<util::guidance::TurnBearing, true>::vector m_pre_turn_bearing;
util::ShM<util::guidance::TurnBearing, true>::vector m_post_turn_bearing;
util::ShM<util::Coordinate, osrm::storage::MemorySetting::SharedMemory>::vector m_coordinate_list;
util::PackedVector<OSMNodeID, osrm::storage::MemorySetting::SharedMemory> m_osmnodeid_list;
util::ShM<GeometryID, osrm::storage::MemorySetting::SharedMemory>::vector m_via_geometry_list;
util::ShM<NameID, osrm::storage::MemorySetting::SharedMemory>::vector m_name_ID_list;
util::ShM<LaneDataID, osrm::storage::MemorySetting::SharedMemory>::vector m_lane_data_id;
util::ShM<extractor::guidance::TurnInstruction, osrm::storage::MemorySetting::SharedMemory>::vector m_turn_instruction_list;
util::ShM<extractor::TravelMode, osrm::storage::MemorySetting::SharedMemory>::vector m_travel_mode_list;
util::ShM<util::guidance::TurnBearing, osrm::storage::MemorySetting::SharedMemory>::vector m_pre_turn_bearing;
util::ShM<util::guidance::TurnBearing, osrm::storage::MemorySetting::SharedMemory>::vector m_post_turn_bearing;
util::NameTable m_names_table;
util::ShM<unsigned, true>::vector m_name_begin_indices;
util::ShM<bool, true>::vector m_is_core_node;
util::ShM<std::uint32_t, true>::vector m_lane_description_offsets;
util::ShM<extractor::guidance::TurnLaneType::Mask, true>::vector m_lane_description_masks;
util::ShM<TurnPenalty, true>::vector m_turn_weight_penalties;
util::ShM<TurnPenalty, true>::vector m_turn_duration_penalties;
util::ShM<unsigned, osrm::storage::MemorySetting::SharedMemory>::vector m_name_begin_indices;
util::ShM<bool, osrm::storage::MemorySetting::SharedMemory>::vector m_is_core_node;
util::ShM<std::uint32_t, osrm::storage::MemorySetting::SharedMemory>::vector m_lane_description_offsets;
util::ShM<extractor::guidance::TurnLaneType::Mask, osrm::storage::MemorySetting::SharedMemory>::vector m_lane_description_masks;
util::ShM<TurnPenalty, osrm::storage::MemorySetting::SharedMemory>::vector m_turn_weight_penalties;
util::ShM<TurnPenalty, osrm::storage::MemorySetting::SharedMemory>::vector m_turn_duration_penalties;
extractor::SegmentDataView segment_data;
util::ShM<char, true>::vector m_datasource_name_data;
util::ShM<std::size_t, true>::vector m_datasource_name_offsets;
util::ShM<std::size_t, true>::vector m_datasource_name_lengths;
util::ShM<util::guidance::LaneTupleIdPair, true>::vector m_lane_tupel_id_pairs;
util::ShM<char, osrm::storage::MemorySetting::SharedMemory>::vector m_datasource_name_data;
util::ShM<std::size_t, osrm::storage::MemorySetting::SharedMemory>::vector m_datasource_name_offsets;
util::ShM<std::size_t, osrm::storage::MemorySetting::SharedMemory>::vector m_datasource_name_lengths;
util::ShM<util::guidance::LaneTupleIdPair, osrm::storage::MemorySetting::SharedMemory>::vector m_lane_tupel_id_pairs;
std::unique_ptr<SharedRTree> m_static_rtree;
std::unique_ptr<SharedGeospatialQuery> m_geospatial_query;
@ -240,17 +241,17 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
util::NameTable m_name_table;
// bearing classes by node based node
util::ShM<BearingClassID, true>::vector m_bearing_class_id_table;
util::ShM<BearingClassID, osrm::storage::MemorySetting::SharedMemory>::vector m_bearing_class_id_table;
// entry class IDs
util::ShM<EntryClassID, true>::vector m_entry_class_id_list;
util::ShM<EntryClassID, osrm::storage::MemorySetting::SharedMemory>::vector m_entry_class_id_list;
// the look-up table for entry classes. An entry class lists the possibility of entry for all
// available turns. Such a class id is stored with every edge.
util::ShM<util::guidance::EntryClass, true>::vector m_entry_class_table;
util::ShM<util::guidance::EntryClass, osrm::storage::MemorySetting::SharedMemory>::vector m_entry_class_table;
// the look-up table for distinct bearing classes. A bearing class lists the available bearings
// at an intersection
std::shared_ptr<util::RangeTable<16, true>> m_bearing_ranges_table;
util::ShM<DiscreteBearing, true>::vector m_bearing_values_table;
std::shared_ptr<util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>> m_bearing_ranges_table;
util::ShM<DiscreteBearing, osrm::storage::MemorySetting::SharedMemory>::vector m_bearing_values_table;
// allocator that keeps the allocation data
std::shared_ptr<ContiguousBlockAllocator> allocator;
@ -326,52 +327,52 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
const auto travel_mode_list_ptr = data_layout.GetBlockPtr<extractor::TravelMode>(
memory_block, storage::DataLayout::TRAVEL_MODE);
util::ShM<extractor::TravelMode, true>::vector travel_mode_list(
util::ShM<extractor::TravelMode, osrm::storage::MemorySetting::SharedMemory>::vector travel_mode_list(
travel_mode_list_ptr, data_layout.num_entries[storage::DataLayout::TRAVEL_MODE]);
m_travel_mode_list = std::move(travel_mode_list);
const auto lane_data_id_ptr =
data_layout.GetBlockPtr<LaneDataID>(memory_block, storage::DataLayout::LANE_DATA_ID);
util::ShM<LaneDataID, true>::vector lane_data_id(
util::ShM<LaneDataID, osrm::storage::MemorySetting::SharedMemory>::vector lane_data_id(
lane_data_id_ptr, data_layout.num_entries[storage::DataLayout::LANE_DATA_ID]);
m_lane_data_id = std::move(lane_data_id);
const auto lane_tupel_id_pair_ptr =
data_layout.GetBlockPtr<util::guidance::LaneTupleIdPair>(
memory_block, storage::DataLayout::TURN_LANE_DATA);
util::ShM<util::guidance::LaneTupleIdPair, true>::vector lane_tupel_id_pair(
util::ShM<util::guidance::LaneTupleIdPair, osrm::storage::MemorySetting::SharedMemory>::vector lane_tupel_id_pair(
lane_tupel_id_pair_ptr, data_layout.num_entries[storage::DataLayout::TURN_LANE_DATA]);
m_lane_tupel_id_pairs = std::move(lane_tupel_id_pair);
const auto turn_instruction_list_ptr =
data_layout.GetBlockPtr<extractor::guidance::TurnInstruction>(
memory_block, storage::DataLayout::TURN_INSTRUCTION);
util::ShM<extractor::guidance::TurnInstruction, true>::vector turn_instruction_list(
util::ShM<extractor::guidance::TurnInstruction, osrm::storage::MemorySetting::SharedMemory>::vector turn_instruction_list(
turn_instruction_list_ptr,
data_layout.num_entries[storage::DataLayout::TURN_INSTRUCTION]);
m_turn_instruction_list = std::move(turn_instruction_list);
const auto name_id_list_ptr =
data_layout.GetBlockPtr<NameID>(memory_block, storage::DataLayout::NAME_ID_LIST);
util::ShM<NameID, true>::vector name_id_list(
util::ShM<NameID, osrm::storage::MemorySetting::SharedMemory>::vector name_id_list(
name_id_list_ptr, data_layout.num_entries[storage::DataLayout::NAME_ID_LIST]);
m_name_ID_list = std::move(name_id_list);
const auto entry_class_id_list_ptr =
data_layout.GetBlockPtr<EntryClassID>(memory_block, storage::DataLayout::ENTRY_CLASSID);
typename util::ShM<EntryClassID, true>::vector entry_class_id_list(
typename util::ShM<EntryClassID, osrm::storage::MemorySetting::SharedMemory>::vector entry_class_id_list(
entry_class_id_list_ptr, data_layout.num_entries[storage::DataLayout::ENTRY_CLASSID]);
m_entry_class_id_list = std::move(entry_class_id_list);
const auto pre_turn_bearing_ptr = data_layout.GetBlockPtr<util::guidance::TurnBearing>(
memory_block, storage::DataLayout::PRE_TURN_BEARING);
typename util::ShM<util::guidance::TurnBearing, true>::vector pre_turn_bearing(
typename util::ShM<util::guidance::TurnBearing, osrm::storage::MemorySetting::SharedMemory>::vector pre_turn_bearing(
pre_turn_bearing_ptr, data_layout.num_entries[storage::DataLayout::PRE_TURN_BEARING]);
m_pre_turn_bearing = std::move(pre_turn_bearing);
const auto post_turn_bearing_ptr = data_layout.GetBlockPtr<util::guidance::TurnBearing>(
memory_block, storage::DataLayout::POST_TURN_BEARING);
typename util::ShM<util::guidance::TurnBearing, true>::vector post_turn_bearing(
typename util::ShM<util::guidance::TurnBearing, osrm::storage::MemorySetting::SharedMemory>::vector post_turn_bearing(
post_turn_bearing_ptr, data_layout.num_entries[storage::DataLayout::POST_TURN_BEARING]);
m_post_turn_bearing = std::move(post_turn_bearing);
}
@ -380,7 +381,7 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
auto via_geometry_list_ptr =
data_layout.GetBlockPtr<GeometryID>(memory_block, storage::DataLayout::VIA_NODE_LIST);
util::ShM<GeometryID, true>::vector via_geometry_list(
util::ShM<GeometryID, osrm::storage::MemorySetting::SharedMemory>::vector via_geometry_list(
via_geometry_list_ptr, data_layout.num_entries[storage::DataLayout::VIA_NODE_LIST]);
m_via_geometry_list = std::move(via_geometry_list);
}
@ -398,14 +399,14 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
auto offsets_ptr = data_layout.GetBlockPtr<std::uint32_t>(
memory_block, storage::DataLayout::LANE_DESCRIPTION_OFFSETS);
util::ShM<std::uint32_t, true>::vector offsets(
util::ShM<std::uint32_t, osrm::storage::MemorySetting::SharedMemory>::vector offsets(
offsets_ptr, data_layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_OFFSETS]);
m_lane_description_offsets = std::move(offsets);
auto masks_ptr = data_layout.GetBlockPtr<extractor::guidance::TurnLaneType::Mask>(
memory_block, storage::DataLayout::LANE_DESCRIPTION_MASKS);
util::ShM<extractor::guidance::TurnLaneType::Mask, true>::vector masks(
util::ShM<extractor::guidance::TurnLaneType::Mask, osrm::storage::MemorySetting::SharedMemory>::vector masks(
masks_ptr, data_layout.num_entries[storage::DataLayout::LANE_DESCRIPTION_MASKS]);
m_lane_description_masks = std::move(masks);
}
@ -414,12 +415,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
auto turn_weight_penalties_ptr = data_layout.GetBlockPtr<TurnPenalty>(
memory_block, storage::DataLayout::TURN_WEIGHT_PENALTIES);
m_turn_weight_penalties = util::ShM<TurnPenalty, true>::vector(
m_turn_weight_penalties = util::ShM<TurnPenalty, osrm::storage::MemorySetting::SharedMemory>::vector(
turn_weight_penalties_ptr,
data_layout.num_entries[storage::DataLayout::TURN_WEIGHT_PENALTIES]);
auto turn_duration_penalties_ptr = data_layout.GetBlockPtr<TurnPenalty>(
memory_block, storage::DataLayout::TURN_DURATION_PENALTIES);
m_turn_duration_penalties = util::ShM<TurnPenalty, true>::vector(
m_turn_duration_penalties = util::ShM<TurnPenalty, osrm::storage::MemorySetting::SharedMemory>::vector(
turn_duration_penalties_ptr,
data_layout.num_entries[storage::DataLayout::TURN_DURATION_PENALTIES]);
}
@ -428,42 +429,42 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
auto geometries_index_ptr =
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::GEOMETRIES_INDEX);
util::ShM<unsigned, true>::vector geometry_begin_indices(
util::ShM<unsigned, osrm::storage::MemorySetting::SharedMemory>::vector geometry_begin_indices(
geometries_index_ptr, data_layout.num_entries[storage::DataLayout::GEOMETRIES_INDEX]);
auto geometries_node_list_ptr = data_layout.GetBlockPtr<NodeID>(
memory_block, storage::DataLayout::GEOMETRIES_NODE_LIST);
util::ShM<NodeID, true>::vector geometry_node_list(
util::ShM<NodeID, osrm::storage::MemorySetting::SharedMemory>::vector geometry_node_list(
geometries_node_list_ptr,
data_layout.num_entries[storage::DataLayout::GEOMETRIES_NODE_LIST]);
auto geometries_fwd_weight_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
memory_block, storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST);
util::ShM<EdgeWeight, true>::vector geometry_fwd_weight_list(
util::ShM<EdgeWeight, osrm::storage::MemorySetting::SharedMemory>::vector geometry_fwd_weight_list(
geometries_fwd_weight_list_ptr,
data_layout.num_entries[storage::DataLayout::GEOMETRIES_FWD_WEIGHT_LIST]);
auto geometries_rev_weight_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
memory_block, storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST);
util::ShM<EdgeWeight, true>::vector geometry_rev_weight_list(
util::ShM<EdgeWeight, osrm::storage::MemorySetting::SharedMemory>::vector geometry_rev_weight_list(
geometries_rev_weight_list_ptr,
data_layout.num_entries[storage::DataLayout::GEOMETRIES_REV_WEIGHT_LIST]);
auto geometries_fwd_duration_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
memory_block, storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST);
util::ShM<EdgeWeight, true>::vector geometry_fwd_duration_list(
util::ShM<EdgeWeight, osrm::storage::MemorySetting::SharedMemory>::vector geometry_fwd_duration_list(
geometries_fwd_duration_list_ptr,
data_layout.num_entries[storage::DataLayout::GEOMETRIES_FWD_DURATION_LIST]);
auto geometries_rev_duration_list_ptr = data_layout.GetBlockPtr<EdgeWeight>(
memory_block, storage::DataLayout::GEOMETRIES_REV_DURATION_LIST);
util::ShM<EdgeWeight, true>::vector geometry_rev_duration_list(
util::ShM<EdgeWeight, osrm::storage::MemorySetting::SharedMemory>::vector geometry_rev_duration_list(
geometries_rev_duration_list_ptr,
data_layout.num_entries[storage::DataLayout::GEOMETRIES_REV_DURATION_LIST]);
auto datasources_list_ptr = data_layout.GetBlockPtr<DatasourceID>(
memory_block, storage::DataLayout::DATASOURCES_LIST);
util::ShM<DatasourceID, true>::vector datasources_list(
util::ShM<DatasourceID, osrm::storage::MemorySetting::SharedMemory>::vector datasources_list(
datasources_list_ptr, data_layout.num_entries[storage::DataLayout::DATASOURCES_LIST]);
segment_data = extractor::SegmentDataView{std::move(geometry_begin_indices),
@ -482,13 +483,13 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
auto bearing_class_id_ptr = data_layout.GetBlockPtr<BearingClassID>(
memory_block, storage::DataLayout::BEARING_CLASSID);
typename util::ShM<BearingClassID, true>::vector bearing_class_id_table(
typename util::ShM<BearingClassID, osrm::storage::MemorySetting::SharedMemory>::vector bearing_class_id_table(
bearing_class_id_ptr, data_layout.num_entries[storage::DataLayout::BEARING_CLASSID]);
m_bearing_class_id_table = std::move(bearing_class_id_table);
auto bearing_class_ptr = data_layout.GetBlockPtr<DiscreteBearing>(
memory_block, storage::DataLayout::BEARING_VALUES);
typename util::ShM<DiscreteBearing, true>::vector bearing_class_table(
typename util::ShM<DiscreteBearing, osrm::storage::MemorySetting::SharedMemory>::vector bearing_class_table(
bearing_class_ptr, data_layout.num_entries[storage::DataLayout::BEARING_VALUES]);
m_bearing_values_table = std::move(bearing_class_table);
@ -496,17 +497,17 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
data_layout.GetBlockPtr<unsigned>(memory_block, storage::DataLayout::BEARING_OFFSETS);
auto blocks_ptr =
data_layout.GetBlockPtr<IndexBlock>(memory_block, storage::DataLayout::BEARING_BLOCKS);
util::ShM<unsigned, true>::vector bearing_offsets(
util::ShM<unsigned, osrm::storage::MemorySetting::SharedMemory>::vector bearing_offsets(
offsets_ptr, data_layout.num_entries[storage::DataLayout::BEARING_OFFSETS]);
util::ShM<IndexBlock, true>::vector bearing_blocks(
util::ShM<IndexBlock, osrm::storage::MemorySetting::SharedMemory>::vector bearing_blocks(
blocks_ptr, data_layout.num_entries[storage::DataLayout::BEARING_BLOCKS]);
m_bearing_ranges_table = std::make_unique<util::RangeTable<16, true>>(
m_bearing_ranges_table = std::make_unique<util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>>(
bearing_offsets, bearing_blocks, static_cast<unsigned>(m_bearing_values_table.size()));
auto entry_class_ptr = data_layout.GetBlockPtr<util::guidance::EntryClass>(
memory_block, storage::DataLayout::ENTRY_CLASS);
typename util::ShM<util::guidance::EntryClass, true>::vector entry_class_table(
typename util::ShM<util::guidance::EntryClass, osrm::storage::MemorySetting::SharedMemory>::vector entry_class_table(
entry_class_ptr, data_layout.num_entries[storage::DataLayout::ENTRY_CLASS]);
m_entry_class_table = std::move(entry_class_table);
}
@ -929,14 +930,14 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
memory_block, storage::DataLayout::MLD_PARTITION);
auto partition_entries_count =
data_layout.GetBlockEntries(storage::DataLayout::MLD_PARTITION);
util::ShM<PartitionID, true>::vector partition(mld_partition_ptr,
util::ShM<PartitionID, osrm::storage::MemorySetting::SharedMemory>::vector partition(mld_partition_ptr,
partition_entries_count);
auto mld_chilren_ptr = data_layout.GetBlockPtr<CellID>(
memory_block, storage::DataLayout::MLD_CELL_TO_CHILDREN);
auto children_entries_count =
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_TO_CHILDREN);
util::ShM<CellID, true>::vector cell_to_children(mld_chilren_ptr,
util::ShM<CellID, osrm::storage::MemorySetting::SharedMemory>::vector cell_to_children(mld_chilren_ptr,
children_entries_count);
mld_partition =
@ -969,14 +970,14 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
auto cell_level_offsets_entries_count =
data_layout.GetBlockEntries(storage::DataLayout::MLD_CELL_LEVEL_OFFSETS);
util::ShM<EdgeWeight, true>::vector weights(mld_cell_weights_ptr, weight_entries_count);
util::ShM<NodeID, true>::vector source_boundary(mld_source_boundary_ptr,
util::ShM<EdgeWeight, osrm::storage::MemorySetting::SharedMemory>::vector weights(mld_cell_weights_ptr, weight_entries_count);
util::ShM<NodeID, osrm::storage::MemorySetting::SharedMemory>::vector source_boundary(mld_source_boundary_ptr,
source_boundary_entries_count);
util::ShM<NodeID, true>::vector destination_boundary(
util::ShM<NodeID, osrm::storage::MemorySetting::SharedMemory>::vector destination_boundary(
mld_destination_boundary_ptr, destination_boundary_entries_count);
util::ShM<partition::CellStorageView::CellData, true>::vector cells(
util::ShM<partition::CellStorageView::CellData, osrm::storage::MemorySetting::SharedMemory>::vector cells(
mld_cells_ptr, cells_entries_counts);
util::ShM<std::uint64_t, true>::vector level_offsets(mld_cell_level_offsets_ptr,
util::ShM<std::uint64_t, osrm::storage::MemorySetting::SharedMemory>::vector level_offsets(mld_cell_level_offsets_ptr,
cell_level_offsets_entries_count);
mld_cell_storage = partition::CellStorageView{std::move(weights),
@ -997,11 +998,11 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>
auto graph_node_to_offset_ptr = data_layout.GetBlockPtr<QueryGraph::EdgeOffset>(
memory_block, storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET);
util::ShM<GraphNode, true>::vector node_list(
util::ShM<GraphNode, osrm::storage::MemorySetting::SharedMemory>::vector node_list(
graph_nodes_ptr, data_layout.num_entries[storage::DataLayout::MLD_GRAPH_NODE_LIST]);
util::ShM<GraphEdge, true>::vector edge_list(
util::ShM<GraphEdge, osrm::storage::MemorySetting::SharedMemory>::vector edge_list(
graph_edges_ptr, data_layout.num_entries[storage::DataLayout::MLD_GRAPH_EDGE_LIST]);
util::ShM<QueryGraph::EdgeOffset, true>::vector node_to_offset(
util::ShM<QueryGraph::EdgeOffset, osrm::storage::MemorySetting::SharedMemory>::vector node_to_offset(
graph_node_to_offset_ptr,
data_layout.num_entries[storage::DataLayout::MLD_GRAPH_NODE_TO_OFFSET]);

View File

@ -4,6 +4,8 @@
#include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp"
#include "storage/shared_memory.hpp"
#include <boost/filesystem/path.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/iterator_range.hpp>
@ -22,24 +24,24 @@ class CompressedEdgeContainer;
namespace detail
{
template <bool UseShareMemory> class SegmentDataContainerImpl;
template <osrm::storage::MemorySetting MemorySetting> class SegmentDataContainerImpl;
}
namespace io
{
template <bool UseShareMemory>
template <osrm::storage::MemorySetting MemorySetting>
inline void read(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
template <bool UseShareMemory>
detail::SegmentDataContainerImpl<MemorySetting> &segment_data);
template <osrm::storage::MemorySetting MemorySetting>
inline void write(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
const detail::SegmentDataContainerImpl<MemorySetting> &segment_data);
}
namespace detail
{
template <bool UseShareMemory> class SegmentDataContainerImpl
template <osrm::storage::MemorySetting MemorySetting> class SegmentDataContainerImpl
{
template <typename T> using Vector = typename util::ShM<T, UseShareMemory>::vector;
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
friend CompressedEdgeContainer;
@ -189,11 +191,11 @@ template <bool UseShareMemory> class SegmentDataContainerImpl
auto GetNumberOfSegments() const { return fwd_weights.size(); }
friend void
io::read<UseShareMemory>(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
io::read<MemorySetting>(const boost::filesystem::path &path,
detail::SegmentDataContainerImpl<MemorySetting> &segment_data);
friend void
io::write<UseShareMemory>(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<UseShareMemory> &segment_data);
io::write<MemorySetting>(const boost::filesystem::path &path,
const detail::SegmentDataContainerImpl<MemorySetting> &segment_data);
private:
Vector<std::uint32_t> index;
@ -206,8 +208,8 @@ template <bool UseShareMemory> class SegmentDataContainerImpl
};
}
using SegmentDataView = detail::SegmentDataContainerImpl<true>;
using SegmentDataContainer = detail::SegmentDataContainerImpl<false>;
using SegmentDataView = detail::SegmentDataContainerImpl<osrm::storage::MemorySetting::SharedMemory>;
using SegmentDataContainer = detail::SegmentDataContainerImpl<osrm::storage::MemorySetting::InternalMemory>;
}
}

View File

@ -10,6 +10,7 @@
#include "util/typedefs.hpp"
#include "storage/io.hpp"
#include "storage/shared_memory.hpp"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator_range.hpp>
@ -26,24 +27,24 @@ namespace partition
{
namespace detail
{
template <bool UseShareMemory> class CellStorageImpl;
template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl;
}
using CellStorage = detail::CellStorageImpl<false>;
using CellStorageView = detail::CellStorageImpl<true>;
using CellStorage = detail::CellStorageImpl<osrm::storage::MemorySetting::InternalMemory>;
using CellStorageView = detail::CellStorageImpl<osrm::storage::MemorySetting::SharedMemory>;
namespace io
{
template <bool UseShareMemory>
template <osrm::storage::MemorySetting MemorySetting>
inline void read(const boost::filesystem::path &path,
detail::CellStorageImpl<UseShareMemory> &storage);
template <bool UseShareMemory>
detail::CellStorageImpl<MemorySetting> &storage);
template <osrm::storage::MemorySetting MemorySetting>
inline void write(const boost::filesystem::path &path,
const detail::CellStorageImpl<UseShareMemory> &storage);
const detail::CellStorageImpl<MemorySetting> &storage);
}
namespace detail
{
template <bool UseShareMemory> class CellStorageImpl
template <osrm::storage::MemorySetting MemorySetting> class CellStorageImpl
{
public:
using WeightOffset = std::uint32_t;
@ -65,7 +66,7 @@ template <bool UseShareMemory> class CellStorageImpl
};
private:
template <typename T> using Vector = typename util::ShM<T, UseShareMemory>::vector;
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
// Implementation of the cell view. We need a template parameter here
// because we need to derive a read-only and read-write view from this.
@ -185,7 +186,7 @@ template <bool UseShareMemory> class CellStorageImpl
CellStorageImpl() {}
template <typename GraphT, typename = std::enable_if<!UseShareMemory>>
template <typename GraphT, typename = std::enable_if<MemorySetting == osrm::storage::MemorySetting::InternalMemory>>
CellStorageImpl(const partition::MultiLevelPartition &partition, const GraphT &base_graph)
{
// pre-allocate storge for CellData so we can have random access to it by cell id
@ -314,7 +315,7 @@ template <bool UseShareMemory> class CellStorageImpl
weights.resize(weight_offset + 1, INVALID_EDGE_WEIGHT);
}
template <typename = std::enable_if<UseShareMemory>>
template <typename = std::enable_if<MemorySetting == osrm::storage::MemorySetting::SharedMemory>>
CellStorageImpl(Vector<EdgeWeight> weights_,
Vector<NodeID> source_boundary_,
Vector<NodeID> destination_boundary_,
@ -339,7 +340,7 @@ template <bool UseShareMemory> class CellStorageImpl
destination_boundary.empty() ? nullptr : destination_boundary.data()};
}
template <typename = std::enable_if<!UseShareMemory>> Cell GetCell(LevelID level, CellID id)
template <typename = std::enable_if<MemorySetting == osrm::storage::MemorySetting::InternalMemory>> Cell GetCell(LevelID level, CellID id)
{
const auto level_index = LevelIDToIndex(level);
BOOST_ASSERT(level_index < level_to_cell_offset.size());
@ -350,10 +351,10 @@ template <bool UseShareMemory> class CellStorageImpl
cells[cell_index], weights.data(), source_boundary.data(), destination_boundary.data()};
}
friend void io::read<UseShareMemory>(const boost::filesystem::path &path,
detail::CellStorageImpl<UseShareMemory> &storage);
friend void io::write<UseShareMemory>(const boost::filesystem::path &path,
const detail::CellStorageImpl<UseShareMemory> &storage);
friend void io::read<MemorySetting>(const boost::filesystem::path &path,
detail::CellStorageImpl<MemorySetting> &storage);
friend void io::write<MemorySetting>(const boost::filesystem::path &path,
const detail::CellStorageImpl<MemorySetting> &storage);
private:
Vector<EdgeWeight> weights;

View File

@ -7,6 +7,7 @@
#include "partition/multi_level_partition.hpp"
#include "storage/io.hpp"
#include "storage/shared_memory.hpp"
namespace osrm
{
@ -15,9 +16,9 @@ namespace partition
namespace io
{
template <typename EdgeDataT, bool UseSharedMemory>
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
inline void read(const boost::filesystem::path &path,
MultiLevelGraph<EdgeDataT, UseSharedMemory> &graph)
MultiLevelGraph<EdgeDataT, MemorySetting> &graph)
{
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
storage::io::FileReader reader{path, fingerprint};
@ -27,9 +28,9 @@ inline void read(const boost::filesystem::path &path,
reader.DeserializeVector(graph.edge_to_level);
}
template <typename EdgeDataT, bool UseSharedMemory>
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
inline void write(const boost::filesystem::path &path,
const MultiLevelGraph<EdgeDataT, UseSharedMemory> &graph)
const MultiLevelGraph<EdgeDataT, MemorySetting> &graph)
{
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
storage::io::FileWriter writer{path, fingerprint};

View File

@ -3,6 +3,8 @@
#include "partition/multi_level_partition.hpp"
#include "storage/shared_memory.hpp"
#include "util/static_graph.hpp"
#include <tbb/parallel_sort.h>
@ -14,24 +16,24 @@ namespace osrm
{
namespace partition
{
template <typename EdgeDataT, bool UseSharedMemory> class MultiLevelGraph;
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting> class MultiLevelGraph;
namespace io
{
template <typename EdgeDataT, bool UseSharedMemory>
void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, UseSharedMemory> &graph);
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
void read(const boost::filesystem::path &path, MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
template <typename EdgeDataT, bool UseSharedMemory>
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
void write(const boost::filesystem::path &path,
const MultiLevelGraph<EdgeDataT, UseSharedMemory> &graph);
const MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
}
template <typename EdgeDataT, bool UseSharedMemory>
class MultiLevelGraph : public util::StaticGraph<EdgeDataT, UseSharedMemory>
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting>
class MultiLevelGraph : public util::StaticGraph<EdgeDataT, MemorySetting>
{
private:
using SuperT = util::StaticGraph<EdgeDataT, UseSharedMemory>;
template <typename T> using Vector = typename util::ShM<T, UseSharedMemory>::vector;
using SuperT = util::StaticGraph<EdgeDataT, MemorySetting>;
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
public:
// We limit each node to have 255 edges
@ -190,11 +192,11 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, UseSharedMemory>
}
friend void
io::read<EdgeDataT, UseSharedMemory>(const boost::filesystem::path &path,
MultiLevelGraph<EdgeDataT, UseSharedMemory> &graph);
io::read<EdgeDataT, MemorySetting>(const boost::filesystem::path &path,
MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
friend void
io::write<EdgeDataT, UseSharedMemory>(const boost::filesystem::path &path,
const MultiLevelGraph<EdgeDataT, UseSharedMemory> &graph);
io::write<EdgeDataT, MemorySetting>(const boost::filesystem::path &path,
const MultiLevelGraph<EdgeDataT, MemorySetting> &graph);
Vector<EdgeOffset> node_to_edge_offset;
};

View File

@ -8,6 +8,7 @@
#include "util/typedefs.hpp"
#include "storage/io.hpp"
#include "storage/shared_memory.hpp"
#include <algorithm>
#include <array>
@ -25,31 +26,31 @@ namespace partition
{
namespace detail
{
template <bool UseShareMemory> class MultiLevelPartitionImpl;
template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionImpl;
}
using MultiLevelPartition = detail::MultiLevelPartitionImpl<false>;
using MultiLevelPartitionView = detail::MultiLevelPartitionImpl<true>;
using MultiLevelPartition = detail::MultiLevelPartitionImpl<osrm::storage::MemorySetting::InternalMemory>;
using MultiLevelPartitionView = detail::MultiLevelPartitionImpl<osrm::storage::MemorySetting::SharedMemory>;
namespace io
{
template <bool UseShareMemory>
template <osrm::storage::MemorySetting MemorySetting>
void read(const boost::filesystem::path &file,
detail::MultiLevelPartitionImpl<UseShareMemory> &mlp);
template <bool UseShareMemory>
detail::MultiLevelPartitionImpl<MemorySetting> &mlp);
template <osrm::storage::MemorySetting MemorySetting>
void write(const boost::filesystem::path &file,
const detail::MultiLevelPartitionImpl<UseShareMemory> &mlp);
const detail::MultiLevelPartitionImpl<MemorySetting> &mlp);
}
namespace detail
{
template <bool UseShareMemory> class MultiLevelPartitionImpl final
template <osrm::storage::MemorySetting MemorySetting> class MultiLevelPartitionImpl final
{
// we will support at most 16 levels
static const constexpr std::uint8_t MAX_NUM_LEVEL = 16;
static const constexpr std::uint8_t NUM_PARTITION_BITS = sizeof(PartitionID) * CHAR_BIT;
template <typename T> using Vector = typename util::ShM<T, UseShareMemory>::vector;
template <typename T> using Vector = typename util::ShM<T, MemorySetting>::vector;
public:
// Contains all data necessary to describe the level hierarchy
@ -68,7 +69,7 @@ template <bool UseShareMemory> class MultiLevelPartitionImpl final
// cell_sizes is index by level (starting at 0, the base graph).
// However level 0 always needs to have cell size 1, since it is the
// basegraph.
template <typename = typename std::enable_if<!UseShareMemory>>
template <typename = typename std::enable_if<MemorySetting == osrm::storage::MemorySetting::InternalMemory>>
MultiLevelPartitionImpl(const std::vector<std::vector<CellID>> &partitions,
const std::vector<std::uint32_t> &lidx_to_num_cells)
: level_data(MakeLevelData(lidx_to_num_cells))
@ -76,7 +77,7 @@ template <bool UseShareMemory> class MultiLevelPartitionImpl final
InitializePartitionIDs(partitions);
}
template <typename = typename std::enable_if<UseShareMemory>>
template <typename = typename std::enable_if<MemorySetting == osrm::storage::MemorySetting::SharedMemory>>
MultiLevelPartitionImpl(LevelData level_data,
Vector<PartitionID> partition_,
Vector<CellID> cell_to_children_)
@ -134,9 +135,9 @@ template <bool UseShareMemory> class MultiLevelPartitionImpl final
return cell_to_children[offset + cell + 1];
}
friend void io::read<UseShareMemory>(const boost::filesystem::path &file,
friend void io::read<MemorySetting>(const boost::filesystem::path &file,
MultiLevelPartitionImpl &mlp);
friend void io::write<UseShareMemory>(const boost::filesystem::path &file,
friend void io::write<MemorySetting>(const boost::filesystem::path &file,
const MultiLevelPartitionImpl &mlp);
private:

View File

@ -30,6 +30,12 @@ namespace osrm
namespace storage
{
enum class MemorySetting
{
SharedMemory,
InternalMemory
};
struct OSRMLockFile
{
boost::filesystem::path operator()()

View File

@ -4,6 +4,8 @@
#include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp"
#include "storage/shared_memory.hpp"
#include <cmath>
#include <vector>
@ -20,7 +22,7 @@ namespace util
* NOTE: this type is templated for future use, but will require a slight refactor to
* configure BITSIZE and ELEMSIZE
*/
template <typename T, bool UseSharedMemory = false> class PackedVector
template <typename T, osrm::storage::MemorySetting MemorySetting = osrm::storage::MemorySetting::InternalMemory> class PackedVector
{
static const constexpr std::size_t BITSIZE = 33;
static const constexpr std::size_t ELEMSIZE = 64;
@ -120,20 +122,20 @@ template <typename T, bool UseSharedMemory = false> class PackedVector
std::size_t size() const { return num_elements; }
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void reserve(typename std::enable_if<!enabled, std::size_t>::type capacity)
{
vec.reserve(elements_to_blocks(capacity));
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void reset(typename std::enable_if<enabled, std::uint64_t>::type *ptr,
typename std::enable_if<enabled, std::size_t>::type size)
{
vec.reset(ptr, size);
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void set_number_of_entries(typename std::enable_if<enabled, std::size_t>::type count)
{
num_elements = count;
@ -145,44 +147,44 @@ template <typename T, bool UseSharedMemory = false> class PackedVector
}
private:
typename util::ShM<std::uint64_t, UseSharedMemory>::vector vec;
typename util::ShM<std::uint64_t, MemorySetting>::vector vec;
std::size_t num_elements = 0;
signed cursor = -1;
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void replace_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem)
{
vec[cursor] = last_elem;
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void replace_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem)
{
vec.back() = last_elem;
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void add_last_elem(typename std::enable_if<enabled, std::uint64_t>::type last_elem)
{
vec[cursor + 1] = last_elem;
cursor++;
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
void add_last_elem(typename std::enable_if<!enabled, std::uint64_t>::type last_elem)
{
vec.push_back(last_elem);
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
std::uint64_t vec_back(typename std::enable_if<enabled>::type * = nullptr)
{
return vec[cursor];
}
template <bool enabled = UseSharedMemory>
template <bool enabled = (MemorySetting == osrm::storage::MemorySetting::SharedMemory)>
std::uint64_t vec_back(typename std::enable_if<!enabled>::type * = nullptr)
{
return vec.back();

View File

@ -3,6 +3,7 @@
#include "storage/io.hpp"
#include "util/integer_range.hpp"
#include "storage/shared_memory.hpp"
#include "util/shared_memory_vector_wrapper.hpp"
#include <array>
@ -18,13 +19,13 @@ namespace util
* and otherwise the compiler gets confused.
*/
template <unsigned BLOCK_SIZE = 16, bool USE_SHARED_MEMORY = false> class RangeTable;
template <unsigned BLOCK_SIZE = 16, osrm::storage::MemorySetting MemorySetting = osrm::storage::MemorySetting::InternalMemory> class RangeTable;
template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY>
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY> &table);
template <unsigned BLOCK_SIZE, osrm::storage::MemorySetting MemorySetting>
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, MemorySetting> &table);
template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY>
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY> &table);
template <unsigned BLOCK_SIZE, osrm::storage::MemorySetting MemorySetting>
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, MemorySetting> &table);
/**
* Stores adjacent ranges in a compressed format.
@ -35,12 +36,12 @@ std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, USE_SHARED_MEM
* But each block consists of an absolute value and BLOCK_SIZE differential values.
* So the effective block size is sizeof(unsigned) + BLOCK_SIZE.
*/
template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable
template <unsigned BLOCK_SIZE, osrm::storage::MemorySetting MemorySetting> class RangeTable
{
public:
using BlockT = std::array<unsigned char, BLOCK_SIZE>;
using BlockContainerT = typename ShM<BlockT, USE_SHARED_MEMORY>::vector;
using OffsetContainerT = typename ShM<unsigned, USE_SHARED_MEMORY>::vector;
using BlockContainerT = typename ShM<BlockT, MemorySetting>::vector;
using OffsetContainerT = typename ShM<unsigned, MemorySetting>::vector;
using RangeT = range<unsigned>;
friend std::ostream &operator<<<>(std::ostream &out, const RangeTable &table);
@ -212,8 +213,8 @@ template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable
unsigned sum_lengths;
};
template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY>
unsigned RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY>::PrefixSumAtIndex(int index,
template <unsigned BLOCK_SIZE, osrm::storage::MemorySetting MemorySetting>
unsigned RangeTable<BLOCK_SIZE, MemorySetting>::PrefixSumAtIndex(int index,
const BlockT &block) const
{
// this loop looks inefficent, but a modern compiler
@ -227,8 +228,8 @@ unsigned RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY>::PrefixSumAtIndex(int index,
return sum;
}
template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY>
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY> &table)
template <unsigned BLOCK_SIZE, osrm::storage::MemorySetting MemorySetting>
std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, MemorySetting> &table)
{
// write number of block
const unsigned number_of_blocks = table.diff_blocks.size();
@ -243,8 +244,8 @@ std::ostream &operator<<(std::ostream &out, const RangeTable<BLOCK_SIZE, USE_SHA
return out;
}
template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY>
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, USE_SHARED_MEMORY> &table)
template <unsigned BLOCK_SIZE, osrm::storage::MemorySetting MemorySetting>
std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, MemorySetting> &table)
{
// read number of block
unsigned number_of_blocks;

View File

@ -3,6 +3,8 @@
#include "util/log.hpp"
#include "storage/shared_memory.hpp"
#include <boost/assert.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/reverse_iterator.hpp>
@ -130,7 +132,7 @@ template <typename DataT> class SharedMemoryWrapper
friend void swap(SharedMemoryWrapper<T> &, SharedMemoryWrapper<T> &) noexcept;
};
template <> class SharedMemoryWrapper<bool>
template <> class SharedMemoryWrapper<osrm::storage::MemorySetting>
{
private:
unsigned *m_ptr;
@ -173,9 +175,9 @@ void swap(SharedMemoryWrapper<DataT> &lhs, SharedMemoryWrapper<DataT> &rhs) noex
std::swap(lhs.m_size, rhs.m_size);
}
template <typename DataT, bool UseSharedMemory> struct ShM
template <typename DataT, osrm::storage::MemorySetting MemorySetting> struct ShM
{
using vector = typename std::conditional<UseSharedMemory,
using vector = typename std::conditional<MemorySetting == osrm::storage::MemorySetting::SharedMemory,
SharedMemoryWrapper<DataT>,
std::vector<DataT>>::type;
};

View File

@ -7,6 +7,8 @@
#include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp"
#include "storage/shared_memory.hpp"
#include <boost/assert.hpp>
#include <algorithm>
@ -97,7 +99,7 @@ EntryT edgeToEntry(const OtherEdge &from, std::false_type)
} // namespace static_graph_details
template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
template <typename EdgeDataT, osrm::storage::MemorySetting MemorySetting = osrm::storage::MemorySetting::InternalMemory> class StaticGraph
{
public:
using InputEdge = static_graph_details::SortableEdgeWithData<EdgeDataT>;
@ -122,8 +124,8 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
InitializeFromSortedEdgeRange(nodes, edges.begin(), edges.end());
}
StaticGraph(typename ShM<NodeArrayEntry, UseSharedMemory>::vector node_array_,
typename ShM<EdgeArrayEntry, UseSharedMemory>::vector edge_array_)
StaticGraph(typename ShM<NodeArrayEntry, MemorySetting>::vector node_array_,
typename ShM<EdgeArrayEntry, MemorySetting>::vector edge_array_)
: node_array(std::move(node_array_)), edge_array(std::move(edge_array_))
{
BOOST_ASSERT(!node_array.empty());
@ -258,8 +260,8 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
NodeIterator number_of_nodes;
EdgeIterator number_of_edges;
typename ShM<NodeArrayEntry, UseSharedMemory>::vector node_array;
typename ShM<EdgeArrayEntry, UseSharedMemory>::vector edge_array;
typename ShM<NodeArrayEntry, MemorySetting>::vector node_array;
typename ShM<EdgeArrayEntry, MemorySetting>::vector edge_array;
};
} // namespace util

View File

@ -15,6 +15,8 @@
#include "osrm/coordinate.hpp"
#include "storage/shared_memory.hpp"
#include <boost/assert.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
@ -52,7 +54,7 @@ namespace util
// are computed, this means the internal distance metric doesn not represent meters!
template <class EdgeDataT,
class CoordinateListT = std::vector<Coordinate>,
bool UseSharedMemory = false,
osrm::storage::MemorySetting MemorySetting = osrm::storage::MemorySetting::InternalMemory,
std::uint32_t BRANCHING_FACTOR = 128,
std::uint32_t LEAF_PAGE_SIZE = 4096>
class StaticRTree
@ -152,12 +154,12 @@ class StaticRTree
Coordinate fixed_projected_coordinate;
};
typename ShM<TreeNode, UseSharedMemory>::vector m_search_tree;
typename ShM<TreeNode, MemorySetting>::vector m_search_tree;
const CoordinateListT &m_coordinate_list;
boost::iostreams::mapped_file_source m_leaves_region;
// read-only view of leaves
typename ShM<const LeafNode, true>::vector m_leaves;
typename ShM<const LeafNode, osrm::storage::MemorySetting::SharedMemory>::vector m_leaves;
public:
StaticRTree(const StaticRTree &) = delete;

View File

@ -28,7 +28,7 @@ constexpr int32_t WORLD_MAX_LON = 180 * COORDINATE_PRECISION;
using RTreeLeaf = extractor::EdgeBasedNode;
using BenchStaticRTree =
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, false>::vector, false>;
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, osrm::storage::MemorySetting::InternalMemory>::vector, osrm::storage::MemorySetting::InternalMemory>;
std::vector<util::Coordinate> loadCoordinates(const boost::filesystem::path &nodes_file)
{

View File

@ -8,6 +8,8 @@
#include "partition/io.hpp"
#include "partition/multi_level_partition.hpp"
#include "storage/shared_memory.hpp"
#include "updater/updater.hpp"
#include "util/log.hpp"
@ -83,7 +85,7 @@ auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
auto tidied =
partition::prepareEdgesForUsageInGraph<StaticEdgeBasedGraphEdge>(std::move(directed));
auto edge_based_graph =
std::make_unique<partition::MultiLevelGraph<EdgeBasedGraphEdgeData, false>>(
std::make_unique<partition::MultiLevelGraph<EdgeBasedGraphEdgeData, osrm::storage::MemorySetting::InternalMemory>>(
mlp, num_nodes, std::move(tidied));
util::Log() << "Loaded edge based graph for mapping partition ids: "

View File

@ -56,7 +56,7 @@ namespace storage
using RTreeLeaf = engine::datafacade::BaseDataFacade::RTreeLeaf;
using RTreeNode =
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, true>::vector, true>::TreeNode;
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, osrm::storage::MemorySetting::SharedMemory>::vector, osrm::storage::MemorySetting::SharedMemory>::TreeNode;
using QueryGraph = util::StaticGraph<contractor::QueryEdge::EdgeData>;
using EdgeBasedGraph = util::StaticGraph<extractor::EdgeBasedEdge::EdgeData>;
@ -364,12 +364,12 @@ void Storage::PopulateLayout(DataLayout &layout)
intersection_file.Skip<std::uint32_t>(1); // sum_lengths
layout.SetBlockSize<unsigned>(DataLayout::BEARING_OFFSETS, bearing_blocks);
layout.SetBlockSize<typename util::RangeTable<16, true>::BlockT>(DataLayout::BEARING_BLOCKS,
layout.SetBlockSize<typename util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>::BlockT>(DataLayout::BEARING_BLOCKS,
bearing_blocks);
// No need to read the data
intersection_file.Skip<unsigned>(bearing_blocks);
intersection_file.Skip<typename util::RangeTable<16, true>::BlockT>(bearing_blocks);
intersection_file.Skip<typename util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>::BlockT>(bearing_blocks);
const auto num_bearings = intersection_file.ReadElementCount64();
@ -694,7 +694,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
layout.GetBlockPtr<util::Coordinate, true>(memory_ptr, DataLayout::COORDINATE_LIST);
const auto osmnodeid_ptr =
layout.GetBlockPtr<std::uint64_t, true>(memory_ptr, DataLayout::OSM_NODE_ID_LIST);
util::PackedVector<OSMNodeID, true> osmnodeid_list;
util::PackedVector<OSMNodeID, osrm::storage::MemorySetting::SharedMemory> osmnodeid_list;
osmnodeid_list.reset(osmnodeid_ptr, layout.num_entries[DataLayout::OSM_NODE_ID_LIST]);
@ -803,7 +803,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
intersection_file.Skip<std::uint32_t>(1); // sum_lengths
std::vector<unsigned> bearing_offsets_data(bearing_blocks);
std::vector<typename util::RangeTable<16, true>::BlockT> bearing_blocks_data(
std::vector<typename util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>::BlockT> bearing_blocks_data(
bearing_blocks);
intersection_file.ReadInto(bearing_offsets_data.data(), bearing_blocks);
@ -844,7 +844,7 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
if (layout.GetBlockSize(DataLayout::BEARING_BLOCKS) > 0)
{
const auto bearing_blocks_ptr =
layout.GetBlockPtr<typename util::RangeTable<16, true>::BlockT, true>(
layout.GetBlockPtr<typename util::RangeTable<16, osrm::storage::MemorySetting::SharedMemory>::BlockT, true>(
memory_ptr, DataLayout::BEARING_BLOCKS);
BOOST_ASSERT(
static_cast<std::size_t>(layout.GetBlockSize(DataLayout::BEARING_BLOCKS)) >=

View File

@ -38,7 +38,7 @@ auto makeGraph(const MultiLevelPartition &mlp, const std::vector<MockEdge> &mock
edges.push_back(Edge{m.target, m.start, m.weight, false, true});
}
std::sort(edges.begin(), edges.end());
return partition::MultiLevelGraph<EdgeData, false>(mlp, max_id + 1, edges);
return partition::MultiLevelGraph<EdgeData, osrm::storage::MemorySetting::InternalMemory>(mlp, max_id + 1, edges);
}
}

View File

@ -38,7 +38,7 @@ auto makeGraph(const MultiLevelPartition &mlp, const std::vector<MockEdge> &mock
edges.push_back(Edge{m.target, m.source, false, true});
}
std::sort(edges.begin(), edges.end());
return MultiLevelGraph<EdgeData, false>(mlp, max_id + 1, edges);
return MultiLevelGraph<EdgeData, osrm::storage::MemorySetting::InternalMemory>(mlp, max_id + 1, edges);
}
}

View File

@ -12,7 +12,7 @@ using namespace osrm::util;
// Verify that the packed vector behaves as expected
BOOST_AUTO_TEST_CASE(insert_and_retrieve_packed_test)
{
PackedVector<OSMNodeID, false> packed_ids;
PackedVector<OSMNodeID, osrm::storage::MemorySetting::InternalMemory> packed_ids;
std::vector<OSMNodeID> original_ids;
const constexpr std::size_t num_test_cases = 399;
@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(insert_and_retrieve_packed_test)
BOOST_AUTO_TEST_CASE(packed_vector_capacity_test)
{
PackedVector<OSMNodeID, false> packed_vec;
PackedVector<OSMNodeID, osrm::storage::MemorySetting::InternalMemory> packed_vec;
const std::size_t original_size = packed_vec.capacity();
std::vector<OSMNodeID> dummy_vec;

View File

@ -13,7 +13,7 @@ using namespace osrm;
using namespace osrm::util;
constexpr unsigned BLOCK_SIZE = 16;
typedef RangeTable<BLOCK_SIZE, false> TestRangeTable;
typedef RangeTable<BLOCK_SIZE, osrm::storage::MemorySetting::InternalMemory> TestRangeTable;
void ConstructionTest(stxxl::vector<unsigned> lengths, std::vector<unsigned> offsets)
{

View File

@ -70,8 +70,8 @@ template <unsigned NUM_NODES, unsigned NUM_EDGES> struct RandomArrayEntryFixture
std::shuffle(order.begin(), order.end(), g);
}
typename ShM<TestNodeArrayEntry, false>::vector nodes;
typename ShM<TestEdgeArrayEntry, false>::vector edges;
typename ShM<TestNodeArrayEntry, osrm::storage::MemorySetting::InternalMemory>::vector nodes;
typename ShM<TestEdgeArrayEntry, osrm::storage::MemorySetting::InternalMemory>::vector edges;
std::vector<unsigned> lengths;
std::vector<unsigned> order;
};

View File

@ -42,10 +42,10 @@ constexpr uint32_t TEST_LEAF_NODE_SIZE = 64;
using TestData = extractor::EdgeBasedNode;
using TestStaticRTree = StaticRTree<TestData,
std::vector<Coordinate>,
false,
osrm::storage::MemorySetting::InternalMemory,
TEST_BRANCHING_FACTOR,
TEST_LEAF_NODE_SIZE>;
using MiniStaticRTree = StaticRTree<TestData, std::vector<Coordinate>, false, 2, 128>;
using MiniStaticRTree = StaticRTree<TestData, std::vector<Coordinate>, osrm::storage::MemorySetting::InternalMemory, 2, 128>;
// Choosen by a fair W20 dice roll (this value is completely arbitrary)
constexpr unsigned RANDOM_SEED = 42;
@ -273,7 +273,7 @@ void construction_test(const std::string &prefix, FixtureT *fixture)
BOOST_FIXTURE_TEST_CASE(construct_tiny, TestRandomGraphFixture_10_30)
{
using TinyTestTree = StaticRTree<TestData, std::vector<Coordinate>, false, 2, 64>;
using TinyTestTree = StaticRTree<TestData, std::vector<Coordinate>, osrm::storage::MemorySetting::InternalMemory, 2, 64>;
construction_test<TinyTestTree>("test_tiny", this);
}