Run clang-format

This commit is contained in:
Patrick Niklaus 2017-03-05 22:57:08 +00:00 committed by Patrick Niklaus
parent fc9b5938e6
commit 6cb401b1ff
7 changed files with 89 additions and 30 deletions

View File

@ -4,8 +4,8 @@
#include "contractor/query_edge.hpp"
#include "engine/algorithm.hpp"
#include "partition/multi_level_partition.hpp"
#include "partition/cell_storage.hpp"
#include "partition/multi_level_partition.hpp"
#include "util/integer_range.hpp"

View File

@ -17,7 +17,6 @@ using Partition = std::vector<CellID>;
std::tuple<std::vector<Partition>, std::vector<std::uint32_t>>
bisectionToPartition(const std::vector<BisectionID> &node_to_bisection_id,
const std::vector<std::size_t> &max_cell_sizes);
}
}

View File

@ -1,8 +1,8 @@
#ifndef OSRM_PARTITION_IO_HPP
#define OSRM_PARTITION_IO_HPP
#include "partition/multi_level_partition.hpp"
#include "partition/cell_storage.hpp"
#include "partition/multi_level_partition.hpp"
#include "storage/io.hpp"
@ -36,7 +36,6 @@ inline void write(const boost::filesystem::path &path, const partition::CellStor
writer.SerializeVector(storage.cells);
writer.SerializeVector(storage.level_to_cell_offset);
}
}
}
}

View File

@ -3,9 +3,9 @@
#include "util/exception.hpp"
#include "util/for_each_pair.hpp"
#include "util/msb.hpp"
#include "util/shared_memory_vector_wrapper.hpp"
#include "util/typedefs.hpp"
#include "util/msb.hpp"
#include "storage/io.hpp"

View File

@ -37,7 +37,6 @@ inline std::size_t msb(std::uint32_t v)
return 31UL - __builtin_clz(v);
}
#endif
}
}

View File

@ -64,7 +64,8 @@ void partitionLevel(const std::vector<BisectionID> &node_to_bisection_id,
auto &cell = cells[cell_index];
BOOST_ASSERT(cell.depth < NUM_BISECTION_BITS);
// Go over all nodes and sum up the bits to determine at which position the first one bit is
// Go over all nodes and sum up the bits to determine at which position the first one
// bit is
BisectionID sum =
std::accumulate(permutation.begin() + cell.begin,
permutation.begin() + cell.end,
@ -75,7 +76,8 @@ void partitionLevel(const std::vector<BisectionID> &node_to_bisection_id,
// masks all bit strictly higher then cell.depth
const BisectionID mask = (1UL << (NUM_BISECTION_BITS - cell.depth)) - 1;
const auto masked_sum = sum & mask;
// we can't split the cell anymore, but it also doesn't conform to the max size constraint
// we can't split the cell anymore, but it also doesn't conform to the max size
// constraint
// -> we need to remove it from the optimization
if (masked_sum == 0)
{
@ -117,7 +119,8 @@ bisectionToPartition(const std::vector<BisectionID> &node_to_bisection_id,
std::iota(permutation.begin(), permutation.end(), 0);
std::vector<CellBisection> cells;
cells.push_back(CellBisection{0, static_cast<std::uint32_t>(node_to_bisection_id.size()), 0, false});
cells.push_back(
CellBisection{0, static_cast<std::uint32_t>(node_to_bisection_id.size()), 0, false});
std::vector<Partition> partitions(max_cell_sizes.size());
std::vector<std::uint32_t> num_cells(max_cell_sizes.size());

View File

@ -33,7 +33,22 @@ BOOST_AUTO_TEST_CASE(unsplitable_case)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*/
const std::vector<BisectionID> ids_1 = {
0b000, 0b000, 0b001, 0b001, 0b010, 0b010, 0b011, 0b011, 0b100, 0b100, 0b100, 0b100, 0b100, 0b100, 0b100, 0b100,
0b000,
0b000,
0b001,
0b001,
0b010,
0b010,
0b011,
0b011,
0b100,
0b100,
0b100,
0b100,
0b100,
0b100,
0b100,
0b100,
};
// If cell sizes are not a factor of two we will see sub-optimal results like below
@ -44,22 +59,22 @@ BOOST_AUTO_TEST_CASE(unsplitable_case)
CHECK_EQUAL_RANGE(reference_num_cells, num_cells);
// Four cells of size 2 and one of size 4 (could not be split)
const std::vector<CellID> reference_l1{partitions[0][0], // 0
partitions[0][0], // 1
partitions[0][2], // 2
partitions[0][2], // 3
partitions[0][4], // 4
partitions[0][4], // 5
partitions[0][6], // 6
partitions[0][6], // 7
partitions[0][8], // 8
partitions[0][8], // 9
partitions[0][8], // 10
partitions[0][8], // 11
partitions[0][8], // 12
partitions[0][8], // 13
partitions[0][8], // 14
partitions[0][8]}; // 15
const std::vector<CellID> reference_l1{partitions[0][0], // 0
partitions[0][0], // 1
partitions[0][2], // 2
partitions[0][2], // 3
partitions[0][4], // 4
partitions[0][4], // 5
partitions[0][6], // 6
partitions[0][6], // 7
partitions[0][8], // 8
partitions[0][8], // 9
partitions[0][8], // 10
partitions[0][8], // 11
partitions[0][8], // 12
partitions[0][8], // 13
partitions[0][8], // 14
partitions[0][8]}; // 15
// Two cells of size 4 and one of size 8
const std::vector<CellID> reference_l2{partitions[1][0], // 0
partitions[1][0], // 1
@ -204,7 +219,18 @@ BOOST_AUTO_TEST_CASE(power_of_two_case)
// Inserting zeros at bit position 0, and 2 should not change the result
const std::vector<BisectionID> ids_2 = {
0b00000, 0b00000, 0b00010, 0b00010, 0b00100, 0b00100, 0b00110, 0b00110, 0b10000, 0b10000, 0b10010, 0b10010,
0b00000,
0b00000,
0b00010,
0b00010,
0b00100,
0b00100,
0b00110,
0b00110,
0b10000,
0b10000,
0b10010,
0b10010,
};
std::tie(partitions, num_cells) = bisectionToPartition(ids_2, {2, 4, 8, 16});
CHECK_EQUAL_RANGE(reference_l1, partitions[0]);
@ -214,7 +240,18 @@ BOOST_AUTO_TEST_CASE(power_of_two_case)
// Inserting a prefix should not change anything
const std::vector<BisectionID> ids_3 = {
0b101000, 0b101000, 0b101001, 0b101001, 0b101010, 0b101010, 0b101011, 0b101011, 0b101100, 0b101100, 0b101101, 0b101101,
0b101000,
0b101000,
0b101001,
0b101001,
0b101010,
0b101010,
0b101011,
0b101011,
0b101100,
0b101100,
0b101101,
0b101101,
};
std::tie(partitions, num_cells) = bisectionToPartition(ids_3, {2, 4, 8, 16});
CHECK_EQUAL_RANGE(reference_l1, partitions[0]);
@ -309,7 +346,18 @@ BOOST_AUTO_TEST_CASE(non_factor_two_case)
// Inserting zeros at bit position 0, and 2 should not change the result
const std::vector<BisectionID> ids_2 = {
0b00000, 0b00000, 0b00010, 0b00010, 0b00100, 0b00100, 0b00110, 0b00110, 0b10000, 0b10000, 0b10010, 0b10010,
0b00000,
0b00000,
0b00010,
0b00010,
0b00100,
0b00100,
0b00110,
0b00110,
0b10000,
0b10000,
0b10010,
0b10010,
};
std::tie(partitions, num_cells) = bisectionToPartition(ids_2, {2, 4, 6, 12});
CHECK_EQUAL_RANGE(reference_l1, partitions[0]);
@ -319,7 +367,18 @@ BOOST_AUTO_TEST_CASE(non_factor_two_case)
// Inserting a prefix should not change anything
const std::vector<BisectionID> ids_3 = {
0b101000, 0b101000, 0b101001, 0b101001, 0b101010, 0b101010, 0b101011, 0b101011, 0b101100, 0b101100, 0b101101, 0b101101,
0b101000,
0b101000,
0b101001,
0b101001,
0b101010,
0b101010,
0b101011,
0b101011,
0b101100,
0b101100,
0b101101,
0b101101,
};
std::tie(partitions, num_cells) = bisectionToPartition(ids_3, {2, 4, 6, 12});
CHECK_EQUAL_RANGE(reference_l1, partitions[0]);