From 26879ca91a9f0e3a47c0ca2a8a8421aa49e65aec Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 5 Jun 2016 11:29:49 +0200 Subject: [PATCH 1/9] Make build directory configurable via OSRM_BUILD_DIR in tests --- features/support/env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/support/env.js b/features/support/env.js index 32ff82d04..c99d54403 100644 --- a/features/support/env.js +++ b/features/support/env.js @@ -21,7 +21,7 @@ module.exports = function () { this.DEFAULT_GRID_SIZE = 100; // meters this.PROFILES_PATH = path.resolve(this.ROOT_FOLDER, 'profiles'); this.FIXTURES_PATH = path.resolve(this.ROOT_FOLDER, 'unit_tests/fixtures'); - this.BIN_PATH = path.resolve(this.ROOT_FOLDER, 'build'); + this.BIN_PATH = process.env.OSRM_BUILD_DIR && process.env.OSRM_BUILD_DIR || path.resolve(this.ROOT_FOLDER, 'build'); this.DEFAULT_INPUT_FORMAT = 'osm'; this.DEFAULT_ORIGIN = [1,1]; this.DEFAULT_LOAD_METHOD = 'datastore'; From ae06300c17428a1f49446c333a637a81ec6d8278 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 5 Jun 2016 18:32:27 +0200 Subject: [PATCH 2/9] Fix unused variables warnings in crc32 --- include/contractor/crc32_processor.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/contractor/crc32_processor.hpp b/include/contractor/crc32_processor.hpp index cba99a949..4130ed583 100644 --- a/include/contractor/crc32_processor.hpp +++ b/include/contractor/crc32_processor.hpp @@ -82,6 +82,9 @@ class IteratorbasedCRC32 : "0"(crc), "c"(*str)); ++str; } +#else + (void)str; + (void)len; #endif return crc; } @@ -95,8 +98,11 @@ class IteratorbasedCRC32 } #if defined(__MINGW64__) || defined(_MSC_VER) || !defined(__x86_64__) - inline void - __get_cpuid(int param, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) const + inline void __get_cpuid(int /*param*/, + unsigned * /*eax*/, + unsigned * /*ebx*/, + unsigned *ecx, + unsigned * /*edx*/) const { *ecx = 0; } From 911d1e81b60e7648b74390e6ee296371169ac9ef Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sat, 4 Jun 2016 08:31:18 +0200 Subject: [PATCH 3/9] Make explicit promotion to int64_t to avoid incorrect promotions for 32 bit size_t --- include/engine/routing_algorithms/alternative_path.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/engine/routing_algorithms/alternative_path.hpp b/include/engine/routing_algorithms/alternative_path.hpp index df5cfd89f..8bffd260e 100644 --- a/include/engine/routing_algorithms/alternative_path.hpp +++ b/include/engine/routing_algorithms/alternative_path.hpp @@ -546,8 +546,8 @@ class AlternativeRouting final } } - via_path_index = partially_unpacked_via_path.size() - 1; - shortest_path_index = partially_unpacked_shortest_path.size() - 1; + via_path_index = static_cast(partially_unpacked_via_path.size()) - 1; + shortest_path_index = static_cast(partially_unpacked_shortest_path.size()) - 1; for (; via_path_index > 0 && shortest_path_index > 0; --via_path_index, --shortest_path_index) { From 3881ead8e58a6366edcb9e46b2fddfa0eb18b8e4 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 5 Jun 2016 14:10:36 +0200 Subject: [PATCH 4/9] Fix rounding issue due to non-associative floating arithmetic Failing test features/car/traffic_turn_penalties.feature:33 Tables were not identical: from | to | route | speed | time | a | h | ad,dhk,dhk | 63 km/h | 11.5s +-1 | | i | g | fim,fg,fg | 59 km/h | 12s +-1 | | (-) a | (-) e | (-) ad,de,de | (-) 57 km/h | (-) 12.5s +-1 | | (+) a | (+) e | (+) ad,de,de | (+) 58 km/h | (+) 12.5s +-1 | | c | g | cd,de,ef,fg,fg | 63 km/h | 23s +-1 | | p | g | mp,fim,fg,fg | 61 km/h | 23.5s +-1 | | a | l | ad,dhk,kl,kl | 60 km/h | 24s +-1 | | l | e | kl,dhk,de,de | 59 km/h | 24.5s +-1 | | g | n | fg,fim,mn,mn | 57 km/h | 25s +-1 | --- src/util/coordinate_calculation.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index 7dafb784a..89266feaa 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -276,10 +276,13 @@ Coordinate interpolateLinear(double factor, const Coordinate from, const Coordin { BOOST_ASSERT(0 <= factor && factor <= 1.0); - FixedLongitude interpolated_lon(((1. - factor) * static_cast(from.lon)) + - (factor * static_cast(to.lon))); - FixedLatitude interpolated_lat(((1. - factor) * static_cast(from.lat)) + - (factor * static_cast(to.lat))); + const auto from_lon = static_cast(from.lon); + const auto from_lat = static_cast(from.lat); + const auto to_lon = static_cast(to.lon); + const auto to_lat = static_cast(to.lat); + + FixedLongitude interpolated_lon(from_lon + factor * (to_lon - from_lon)); + FixedLatitude interpolated_lat(from_lat + factor * (to_lat - from_lat)); return {std::move(interpolated_lon), std::move(interpolated_lat)}; } From 543e4fb57db9a22bc83461eb97480b7d78d3ea4d Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 5 Jun 2016 18:04:43 +0200 Subject: [PATCH 5/9] Fix rounding issue in query coordinates by using toFixed that internally uses boost::numeric_cast instead of static_cast --- include/server/api/base_parameters_grammar.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/server/api/base_parameters_grammar.hpp b/include/server/api/base_parameters_grammar.hpp index a0399706c..912d7bf5f 100644 --- a/include/server/api/base_parameters_grammar.hpp +++ b/include/server/api/base_parameters_grammar.hpp @@ -111,15 +111,15 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar qi::_1, qi::_2)]; - location_rule = (double_ > qi::lit(',') > - double_)[qi::_val = ph::bind( - [](double lon, double lat) { - return util::Coordinate( - util::FixedLongitude(lon * COORDINATE_PRECISION), - util::FixedLatitude(lat * COORDINATE_PRECISION)); - }, - qi::_1, - qi::_2)]; + location_rule = + (double_ > qi::lit(',') > + double_)[qi::_val = ph::bind( + [](double lon, double lat) { + return util::Coordinate(util::toFixed(util::FloatLongitude(lon)), + util::toFixed(util::FloatLatitude(lat))); + }, + qi::_1, + qi::_2)]; polyline_rule = qi::as_string[qi::lit("polyline(") > +polyline_chars > ')'] [qi::_val = ph::bind( From 57c9525e5c79f0757180fd804f86564cdc6f0f36 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 5 Jun 2016 23:42:21 +0200 Subject: [PATCH 6/9] Added i686 Travis build --- .travis.yml | 5 +++++ CMakeLists.txt | 2 +- scripts/travis/before_install.i686.sh | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 scripts/travis/before_install.i686.sh diff --git a/.travis.yml b/.travis.yml index 815e15e36..b631b7eea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,6 +71,10 @@ matrix: packages: ['g++-5', 'libbz2-dev', 'libstxxl-dev', 'libstxxl1', 'libxml2-dev', 'libzip-dev', 'lua5.1', 'liblua5.1-0-dev', 'libtbb-dev', 'libgdal-dev', 'libluabind-dev', 'libboost-all-dev', 'ccache'] env: CCOMPILER='gcc-5' CXXCOMPILER='g++-5' BUILD_TYPE='Release' + - os: linux + compiler: "gcc-5-release-i686" + env: TARGET_ARCH='i686' CCOMPILER='gcc-5' CXXCOMPILER='g++-5' BUILD_TYPE='Release' + # Disabled because of CI slowness #- os: linux #- compiler: gcc @@ -114,6 +118,7 @@ matrix: #- env: CCOMPILER='clang-3.8' CXXCOMPILER='clang++-3.8' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON before_install: + - if [[ ! -z $TARGET_ARCH ]] ; then source ./scripts/travis/before_install.$TARGET_ARCH.sh ; fi - if [[ $(uname -s) == 'Darwin' ]]; then sudo mdutil -i off /; fi; - source ./scripts/install_node.sh 4 - npm install diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d02a1733..c837aadf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(bitness 64) message(STATUS "Building on a 64 bit system") else() - message(WARNING "Building on a 32 bit system is unsupported") + message(STATUS "Building on a 32 bit system") endif() if(WIN32 AND MSVC_VERSION LESS 1900) diff --git a/scripts/travis/before_install.i686.sh b/scripts/travis/before_install.i686.sh new file mode 100644 index 000000000..ce8414b43 --- /dev/null +++ b/scripts/travis/before_install.i686.sh @@ -0,0 +1,10 @@ +#!/bin/sh -ex + +## Generate code for 32-bit ABI with default for x86_84 fpmath +export CFLAGS='-m32 -msse2 -mfpmath=sse' +export CXXFLAGS='-m32 -msse2 -mfpmath=sse' + +sudo dpkg --add-architecture i386 +sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test && ( sudo apt-get update -qq --yes || true ) + +sudo apt-get install -qq --yes --force-yes g++-5-multilib libxml2-dev:i386 libexpat1-dev:i386 libzip-dev:i386 libbz2-dev:i386 libstxxl-dev:i386 libtbb-dev:i386 lua5.2:i386 liblua5.2-dev:i386 libluabind-dev:i386 libboost-date-time-dev:i386 libboost-filesystem-dev:i386 libboost-iostreams-dev:i386 libboost-program-options-dev:i386 libboost-regex-dev:i386 libboost-system-dev:i386 libboost-thread-dev:i386 libboost-test-dev:i386 From 6e4f6fec91bb6bf405778dfde746125bd5c8a4ee Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Wed, 8 Jun 2016 21:45:04 +0200 Subject: [PATCH 7/9] Added armhf Travis build --- .travis.yml | 5 +++++ scripts/travis/before_install.armhf.sh | 28 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 scripts/travis/before_install.armhf.sh diff --git a/.travis.yml b/.travis.yml index b631b7eea..90e3d1551 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,6 +75,10 @@ matrix: compiler: "gcc-5-release-i686" env: TARGET_ARCH='i686' CCOMPILER='gcc-5' CXXCOMPILER='g++-5' BUILD_TYPE='Release' + - os: linux + compiler: "gcc-4.8-release-armhf" + env: TARGET_ARCH='armhf' CCOMPILER='arm-linux-gnueabihf-gcc-4.8' CXXCOMPILER='arm-linux-gnueabihf-g++-4.8' BUILD_TYPE='Release' + # Disabled because of CI slowness #- os: linux #- compiler: gcc @@ -166,6 +170,7 @@ install: - popd script: + - if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi - echo "travis_fold:start:BENCHMARK" - make -C test/data benchmark - echo "travis_fold:end:BENCHMARK" diff --git a/scripts/travis/before_install.armhf.sh b/scripts/travis/before_install.armhf.sh new file mode 100644 index 000000000..b90ca422a --- /dev/null +++ b/scripts/travis/before_install.armhf.sh @@ -0,0 +1,28 @@ +#!/bin/sh -ex + +# workaround for gcc4.8 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55642 +export CXXFLAGS=-Wa,-mimplicit-it=thumb + +UBUNTU_RELEASE=$(lsb_release -sc) + +sudo dpkg --add-architecture armhf + +sudo tee -a /etc/apt/sources.list > /dev/null < Date: Sat, 11 Jun 2016 17:23:29 +0200 Subject: [PATCH 8/9] Fix platform-independent data in data files --- include/contractor/contractor.hpp | 2 +- .../engine/datafacade/internal_datafacade.hpp | 4 +- .../extractor/edge_based_graph_factory.hpp | 2 +- include/extractor/extractor.hpp | 4 +- include/util/dynamic_graph.hpp | 4 +- include/util/node_based_graph.hpp | 5 +-- include/util/typedefs.hpp | 18 ++++---- src/contractor/contractor.cpp | 44 +++++++++---------- src/extractor/edge_based_graph_factory.cpp | 2 +- src/extractor/extraction_containers.cpp | 12 ++--- src/extractor/extractor.cpp | 10 ++--- 11 files changed, 52 insertions(+), 55 deletions(-) diff --git a/include/contractor/contractor.hpp b/include/contractor/contractor.hpp index 66f99807d..3c9dff9c0 100644 --- a/include/contractor/contractor.hpp +++ b/include/contractor/contractor.hpp @@ -78,7 +78,7 @@ class Contractor private: ContractorConfig config; - std::size_t + EdgeID LoadEdgeExpandedGraph(const std::string &edge_based_graph_path, util::DeallocatingVector &edge_based_edge_list, const std::string &edge_segment_lookup_path, diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 476ab179b..bd45888ca 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -251,9 +251,9 @@ class InternalDataFacade final : public BaseDataFacade } BOOST_ASSERT(datasources_stream); - std::size_t number_of_datasources = 0; + std::uint64_t number_of_datasources = 0; datasources_stream.read(reinterpret_cast(&number_of_datasources), - sizeof(std::size_t)); + sizeof(number_of_datasources)); if (number_of_datasources > 0) { m_datasource_list.resize(number_of_datasources); diff --git a/include/extractor/edge_based_graph_factory.hpp b/include/extractor/edge_based_graph_factory.hpp index 0280501f9..afe52ea79 100644 --- a/include/extractor/edge_based_graph_factory.hpp +++ b/include/extractor/edge_based_graph_factory.hpp @@ -104,7 +104,7 @@ class EdgeBasedGraphFactory //! list of edge based nodes (compressed segments) std::vector m_edge_based_node_list; util::DeallocatingVector m_edge_based_edge_list; - unsigned m_max_edge_id; + EdgeID m_max_edge_id; const std::vector &m_node_info_list; std::shared_ptr m_node_based_graph; diff --git a/include/extractor/extractor.hpp b/include/extractor/extractor.hpp index b92952334..fa355c814 100644 --- a/include/extractor/extractor.hpp +++ b/include/extractor/extractor.hpp @@ -54,7 +54,7 @@ class Extractor private: ExtractorConfig config; - std::pair + std::pair BuildEdgeExpandedGraph(lua_State *lua_state, const ProfileProperties &profile_properties, std::vector &internal_to_external_node_map, @@ -79,7 +79,7 @@ class Extractor std::vector &internal_to_external_node_map); void WriteEdgeBasedGraph(const std::string &output_file_filename, - const size_t max_edge_id, + const EdgeID max_edge_id, util::DeallocatingVector const &edge_based_edge_list); void WriteIntersectionClassificationData( diff --git a/include/util/dynamic_graph.hpp b/include/util/dynamic_graph.hpp index 7df32a9fc..e47990b4d 100644 --- a/include/util/dynamic_graph.hpp +++ b/include/util/dynamic_graph.hpp @@ -24,8 +24,8 @@ template class DynamicGraph { public: using EdgeData = EdgeDataT; - using NodeIterator = unsigned; - using EdgeIterator = unsigned; + using NodeIterator = std::uint32_t; + using EdgeIterator = std::uint32_t; using EdgeRange = range; class InputEdge diff --git a/include/util/node_based_graph.hpp b/include/util/node_based_graph.hpp index e2ac56442..801e9b61c 100644 --- a/include/util/node_based_graph.hpp +++ b/include/util/node_based_graph.hpp @@ -64,7 +64,7 @@ using NodeBasedDynamicGraph = DynamicGraph; /// Since DynamicGraph expects directed edges, we need to insert /// two edges for undirected edges. inline std::shared_ptr -NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, +NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes, const std::vector &input_edge_list) { auto edges_list = directedEdgesFromCompressed( @@ -84,8 +84,7 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes, tbb::parallel_sort(edges_list.begin(), edges_list.end()); - auto graph = std::make_shared( - static_cast(number_of_nodes), edges_list); + auto graph = std::make_shared(number_of_nodes, edges_list); return graph; } diff --git a/include/util/typedefs.hpp b/include/util/typedefs.hpp index 423d306a7..37b832a2f 100644 --- a/include/util/typedefs.hpp +++ b/include/util/typedefs.hpp @@ -54,10 +54,10 @@ static const OSMWayID MIN_OSM_WAYID = OSMWayID(std::numeric_limits::max(); @@ -67,13 +67,13 @@ using DiscreteBearing = std::uint16_t; using EntryClassID = std::uint16_t; static const EntryClassID INVALID_ENTRY_CLASSID = std::numeric_limits::max(); -static const NodeID SPECIAL_NODEID = std::numeric_limits::max(); -static const NodeID SPECIAL_SEGMENTID = std::numeric_limits::max(); -static const EdgeID SPECIAL_EDGEID = std::numeric_limits::max(); -static const unsigned INVALID_NAMEID = std::numeric_limits::max(); -static const unsigned EMPTY_NAMEID = 0; +static const NodeID SPECIAL_NODEID = std::numeric_limits::max(); +static const NodeID SPECIAL_SEGMENTID = std::numeric_limits::max() >> 1; +static const EdgeID SPECIAL_EDGEID = std::numeric_limits::max(); +static const NameID INVALID_NAMEID = std::numeric_limits::max(); +static const NameID EMPTY_NAMEID = 0; static const unsigned INVALID_COMPONENTID = 0; -static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits::max(); +static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits::max(); struct SegmentID { diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index c4adcefd7..6b826f9e0 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -93,17 +93,17 @@ int Contractor::Run() util::DeallocatingVector edge_based_edge_list; - std::size_t max_edge_id = LoadEdgeExpandedGraph(config.edge_based_graph_path, - edge_based_edge_list, - config.edge_segment_lookup_path, - config.edge_penalty_path, - config.segment_speed_lookup_paths, - config.turn_penalty_lookup_paths, - config.node_based_graph_path, - config.geometry_path, - config.datasource_names_path, - config.datasource_indexes_path, - config.rtree_leaf_path); + EdgeID max_edge_id = LoadEdgeExpandedGraph(config.edge_based_graph_path, + edge_based_edge_list, + config.edge_segment_lookup_path, + config.edge_penalty_path, + config.segment_speed_lookup_paths, + config.turn_penalty_lookup_paths, + config.node_based_graph_path, + config.geometry_path, + config.datasource_names_path, + config.datasource_indexes_path, + config.rtree_leaf_path); // Contracting the edge-expanded graph @@ -349,7 +349,7 @@ parse_turn_penalty_lookup_from_csv_files(const std::vector &turn_pe } } // anon ns -std::size_t Contractor::LoadEdgeExpandedGraph( +EdgeID Contractor::LoadEdgeExpandedGraph( std::string const &edge_based_graph_filename, util::DeallocatingVector &edge_based_edge_list, const std::string &edge_segment_lookup_filename, @@ -392,12 +392,10 @@ std::size_t Contractor::LoadEdgeExpandedGraph( input_stream.read((char *)&fingerprint_loaded, sizeof(util::FingerPrint)); fingerprint_loaded.TestContractor(fingerprint_valid); - // TODO std::size_t can vary on systems. Our files are not transferable, but we might want to - // consider using a fixed size type for I/O - std::size_t number_of_edges = 0; - std::size_t max_edge_id = SPECIAL_EDGEID; - input_stream.read((char *)&number_of_edges, sizeof(std::size_t)); - input_stream.read((char *)&max_edge_id, sizeof(std::size_t)); + std::uint64_t number_of_edges = 0; + EdgeID max_edge_id = SPECIAL_EDGEID; + input_stream.read((char *)&number_of_edges, sizeof(number_of_edges)); + input_stream.read((char *)&max_edge_id, sizeof(max_edge_id)); edge_based_edge_list.resize(number_of_edges); util::SimpleLogger().Write() << "Reading " << number_of_edges @@ -686,7 +684,7 @@ std::size_t Contractor::LoadEdgeExpandedGraph( { throw util::exception("Failed to open " + datasource_indexes_filename + " for writing"); } - auto number_of_datasource_entries = m_geometry_datasource.size(); + std::uint64_t number_of_datasource_entries = m_geometry_datasource.size(); datasource_stream.write(reinterpret_cast(&number_of_datasource_entries), sizeof(number_of_datasource_entries)); if (number_of_datasource_entries > 0) @@ -861,8 +859,8 @@ Contractor::WriteContractedGraph(unsigned max_node_id, const util::FingerPrint fingerprint = util::FingerPrint::GetValid(); boost::filesystem::ofstream hsgr_output_stream(config.graph_output_path, std::ios::binary); hsgr_output_stream.write((char *)&fingerprint, sizeof(util::FingerPrint)); - const unsigned max_used_node_id = [&contracted_edge_list] { - unsigned tmp_max = 0; + const NodeID max_used_node_id = [&contracted_edge_list] { + NodeID tmp_max = 0; for (const QueryEdge &edge : contracted_edge_list) { BOOST_ASSERT(SPECIAL_NODEID != edge.source); @@ -928,7 +926,7 @@ Contractor::WriteContractedGraph(unsigned max_node_id, // serialize all edges util::SimpleLogger().Write() << "Building edge array"; - int number_of_used_edges = 0; + std::size_t number_of_used_edges = 0; util::StaticGraph::EdgeArrayEntry current_edge; for (const auto edge : util::irange(0UL, contracted_edge_list.size())) @@ -970,7 +968,7 @@ Contractor::WriteContractedGraph(unsigned max_node_id, \brief Build contracted graph. */ void Contractor::ContractGraph( - const unsigned max_edge_id, + const EdgeID max_edge_id, util::DeallocatingVector &edge_based_edge_list, util::DeallocatingVector &contracted_edge_list, std::vector &&node_weights, diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index a9c4d3bf2..f3fbe2ef2 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -83,7 +83,7 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodeWeights(std::vector &out swap(m_edge_based_node_weights, output_node_weights); } -unsigned EdgeBasedGraphFactory::GetHighestEdgeID() { return m_max_edge_id; } +EdgeID EdgeBasedGraphFactory::GetHighestEdgeID() { return m_max_edge_id; } void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v) { diff --git a/src/extractor/extraction_containers.cpp b/src/extractor/extraction_containers.cpp index 138552ae7..e8348da4e 100644 --- a/src/extractor/extraction_containers.cpp +++ b/src/extractor/extraction_containers.cpp @@ -167,7 +167,7 @@ void ExtractionContainers::PrepareNodes() // handle > uint32_t actual usable nodes. This should be OK for a while // because we usually route on a *lot* less than 2^32 of the OSM // graph nodes. - std::size_t internal_id = 0; + std::uint64_t internal_id = 0; // compute the intersection of nodes that were referenced and nodes we actually have while (node_iter != all_nodes_list_end && ref_iter != used_node_id_list_end) @@ -479,11 +479,11 @@ void ExtractionContainers::WriteEdges(std::ofstream &file_out_stream) const std::cout << "[extractor] Writing used edges ... " << std::flush; TIMER_START(write_edges); // Traverse list of edges and nodes in parallel and set target coord - std::size_t used_edges_counter = 0; - unsigned used_edges_counter_buffer = 0; + std::uint64_t used_edges_counter = 0; + std::uint32_t used_edges_counter_buffer = 0; auto start_position = file_out_stream.tellp(); - file_out_stream.write((char *)&used_edges_counter_buffer, sizeof(unsigned)); + file_out_stream.write((char *)&used_edges_counter_buffer, sizeof(used_edges_counter_buffer)); for (const auto &edge : all_edges_list) { @@ -508,10 +508,10 @@ void ExtractionContainers::WriteEdges(std::ofstream &file_out_stream) const std::cout << "[extractor] setting number of edges ... " << std::flush; - used_edges_counter_buffer = boost::numeric_cast(used_edges_counter); + used_edges_counter_buffer = boost::numeric_cast(used_edges_counter); file_out_stream.seekp(start_position); - file_out_stream.write((char *)&used_edges_counter_buffer, sizeof(unsigned)); + file_out_stream.write((char *)&used_edges_counter_buffer, sizeof(used_edges_counter_buffer)); std::cout << "ok" << std::endl; util::SimpleLogger().Write() << "Processed " << used_edges_counter << " edges"; diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 1406bdbb3..1afcd2090 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -475,7 +475,7 @@ Extractor::LoadNodeBasedGraph(std::unordered_set &barrier_nodes, /** \brief Building an edge-expanded graph from node-based input and turn restrictions */ -std::pair +std::pair Extractor::BuildEdgeExpandedGraph(lua_State *lua_state, const ProfileProperties &profile_properties, std::vector &internal_to_external_node_map, @@ -600,7 +600,7 @@ void Extractor::BuildRTree(std::vector node_based_edge_list, void Extractor::WriteEdgeBasedGraph( std::string const &output_file_filename, - size_t const max_edge_id, + EdgeID const max_edge_id, util::DeallocatingVector const &edge_based_edge_list) { @@ -613,9 +613,9 @@ void Extractor::WriteEdgeBasedGraph( << std::flush; TIMER_START(write_edges); - size_t number_of_used_edges = edge_based_edge_list.size(); - file_out_stream.write((char *)&number_of_used_edges, sizeof(size_t)); - file_out_stream.write((char *)&max_edge_id, sizeof(size_t)); + std::uint64_t number_of_used_edges = edge_based_edge_list.size(); + file_out_stream.write((char *)&number_of_used_edges, sizeof(number_of_used_edges)); + file_out_stream.write((char *)&max_edge_id, sizeof(max_edge_id)); for (const auto &edge : edge_based_edge_list) { From 04e334e3e2f25b8fa7a2946c55f273395e4acfce Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Sun, 12 Jun 2016 18:05:21 +0200 Subject: [PATCH 9/9] Make storage blocks aligned to 4 bytes for ARM NEON/VFP instructions Aligned blocks prevent bus errors in NEON/VFP instructions. Block pointers are aligned to 4 bytes, that is guaranteed by aligned mmaped-pointers, the 4 bytes size of the CANARY block and aligned sizes of blocks. --- include/storage/shared_datatype.hpp | 13 +++++++++---- src/storage/storage.cpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/storage/shared_datatype.hpp b/include/storage/shared_datatype.hpp index 866fc369a..1be9fffea 100644 --- a/include/storage/shared_datatype.hpp +++ b/include/storage/shared_datatype.hpp @@ -14,7 +14,7 @@ namespace storage { // Added at the start and end of each block as sanity check -const constexpr char CANARY[] = "OSRM"; +const constexpr char CANARY[4] = {'O', 'S', 'R', 'M'}; struct SharedDataLayout { @@ -63,15 +63,20 @@ struct SharedDataLayout entry_size[bid] = sizeof(T); } + inline uint64_t AlignBlockSize(uint64_t block_size) const + { + const uint64_t alignment = 4; + return (block_size + (alignment - 1)) & ~(alignment - 1); + } + inline uint64_t GetBlockSize(BlockID bid) const { // special bit encoding if (bid == CORE_MARKER) { - return (num_entries[bid] / 32 + 1) * entry_size[bid]; + return AlignBlockSize((num_entries[bid] / 32 + 1) * entry_size[bid]); } - - return num_entries[bid] * entry_size[bid]; + return AlignBlockSize(num_entries[bid] * entry_size[bid]); } inline uint64_t GetSizeOfLayout() const diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index ca519d207..40309acc1 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -426,7 +426,7 @@ int Storage::Run() unsigned temp_length; name_stream.read((char *)&temp_length, sizeof(unsigned)); - BOOST_ASSERT_MSG(temp_length == + BOOST_ASSERT_MSG(shared_layout_ptr->AlignBlockSize(temp_length) == shared_layout_ptr->GetBlockSize(SharedDataLayout::NAME_CHAR_LIST), "Name file corrupted!");