From 2e4d666eec1a372d4b64c527d6c4945ad98d2b58 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Sep 2022 21:19:57 -0400 Subject: Update clang-format configuration --- .clang-format | 99 +---- benchmark/bench_bitvec.cpp | 461 ++++++++++---------- benchmark/bench_hilbert.cpp | 93 ++-- benchmark/bench_utils.hpp | 40 +- include/chilbert/BoundedBitVec.hpp | 112 +++-- include/chilbert/DynamicBitVec.hpp | 186 ++++---- include/chilbert/SmallBitVec.hpp | 606 +++++++++++++------------- include/chilbert/StaticBitVec.hpp | 100 +++-- include/chilbert/chilbert.hpp | 40 +- include/chilbert/chilbert.ipp | 584 +++++++++++++------------ include/chilbert/detail/BitVecIndex.hpp | 31 +- include/chilbert/detail/BitVecIterator.hpp | 79 ++-- include/chilbert/detail/BitVecMask.hpp | 58 ++- include/chilbert/detail/MultiBitVec.hpp | 672 ++++++++++++++--------------- include/chilbert/detail/gray_code_rank.hpp | 220 +++++----- include/chilbert/detail/operations.hpp | 92 ++-- include/chilbert/detail/traits.hpp | 9 +- include/chilbert/operators.hpp | 61 +-- src/chilbert_obj.cpp | 52 +-- src/chilbert_svg.cpp | 68 +-- test/test_bitvec.cpp | 498 ++++++++++----------- test/test_gray_code_rank.cpp | 206 ++++----- test/test_hilbert.cpp | 272 ++++++------ test/test_utils.hpp | 63 ++- 24 files changed, 2314 insertions(+), 2388 deletions(-) diff --git a/.clang-format b/.clang-format index a728264..8b29ee3 100644 --- a/.clang-format +++ b/.clang-format @@ -1,90 +1,25 @@ --- -Language: Cpp -# BasedOnStyle: Mozilla -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: true AlignEscapedNewlinesLeft: true -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: true -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: TopLevel -AlwaysBreakAfterReturnType: TopLevelDefinitions -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterClass: true - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: true - AfterUnion: true - BeforeCatch: false - BeforeElse: false - IndentBraces: false -BreakBeforeBinaryOperators: None +BasedOnStyle: Mozilla +BraceWrapping: + AfterNamespace: false + AfterClass: true + AfterEnum: false + AfterExternBlock: false + AfterFunction: true + AfterStruct: false + SplitEmptyFunction: false + SplitEmptyRecord: false BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 2 -ContinuationIndentWidth: 2 Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 +FixNamespaceComments: true IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: false -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: ForIndentation +IndentPPDirectives: AfterHash +KeepEmptyLinesAtTheStartOfBlocks: false +SpacesInContainerLiterals: false +StatementMacros: + - _Pragma + - __pragma ... - diff --git a/benchmark/bench_bitvec.cpp b/benchmark/bench_bitvec.cpp index 6580af9..5c885b1 100644 --- a/benchmark/bench_bitvec.cpp +++ b/benchmark/bench_bitvec.cpp @@ -29,324 +29,303 @@ #include #include -template -struct BenchAnd -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = make_random_bitvec(ctx); - - return run_bench([&](auto) { r &= v; }); - } +template +struct BenchAnd { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = make_random_bitvec(ctx); + + return run_bench([&](auto) { r &= v; }); + } }; -template -struct BenchOr -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = make_random_bitvec(ctx); +template +struct BenchOr { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = make_random_bitvec(ctx); - return run_bench([&](auto) { r |= v; }); - } + return run_bench([&](auto) { r |= v; }); + } }; -template -struct BenchXor -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = make_random_bitvec(ctx); +template +struct BenchXor { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = make_random_bitvec(ctx); - return run_bench([&](auto) { r ^= v; }); - } + return run_bench([&](auto) { r ^= v; }); + } }; -template -struct BenchSetOne -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](const auto i) { v.set(i % N); }); - } +template +struct BenchSetOne { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](const auto i) { v.set(i % N); }); + } }; -template -struct BenchSetAll -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](auto) { v.set(); }); - } +template +struct BenchSetAll { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](auto) { v.set(); }); + } }; -template -struct BenchResetOne -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](const auto i) { v.reset(i % N); }); - } +template +struct BenchResetOne { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](const auto i) { v.reset(i % N); }); + } }; -template -struct BenchResetAll -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](auto) { v.reset(); }); - } +template +struct BenchResetAll { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](auto) { v.reset(); }); + } }; -template -struct BenchFlipOne -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](const auto i) { v.flip(i % N); }); - } +template +struct BenchFlipOne { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](const auto i) { v.flip(i % N); }); + } }; -template -struct BenchFlipAll -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](auto) { v.flip(); }); - } +template +struct BenchFlipAll { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](auto) { v.flip(); }); + } }; -template -struct BenchNone -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - bool r = false; - (void)r; - - return run_bench([&](auto) { r = v.none(); }); - } +template +struct BenchNone { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + bool r = false; + (void)r; + + return run_bench([&](auto) { r = v.none(); }); + } }; -template -struct BenchCount -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - volatile size_t r = 0; - (void)r; - - return run_bench([&](auto) { r = v.count(); }); - } +template +struct BenchCount { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + volatile size_t r = 0; + (void)r; + + return run_bench([&](auto) { r = v.count(); }); + } }; -template -struct BenchLeftShift -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = v; - return run_bench([&](const auto i) { r <<= (i % N); }); - } +template +struct BenchLeftShift { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = v; + return run_bench([&](const auto i) { r <<= (i % N); }); + } }; -template -struct BenchRightShift -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = v; - return run_bench([&](const auto i) { r >>= (i % N); }); - } +template +struct BenchRightShift { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = v; + return run_bench([&](const auto i) { r >>= (i % N); }); + } }; -template -struct BenchLeftRotate -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - return run_bench([&](const auto i) { v.rotl(i % N); }); - } +template +struct BenchLeftRotate { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + return run_bench([&](const auto i) { v.rotl(i % N); }); + } }; -template -struct BenchRightRotate -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - volatile bool r = false; - (void)r; - - return run_bench([&](const auto i) { - v.rotr(i % N); - r = v.test(0); - }); - } +template +struct BenchRightRotate { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + volatile bool r = false; + (void)r; + + return run_bench([&](const auto i) { + v.rotr(i % N); + r = v.test(0); + }); + } }; -template -struct BenchFindFirst -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - volatile size_t r = 0; - (void)r; - - return run_bench([&](auto) { r = v.find_first(); }); - } +template +struct BenchFindFirst { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + volatile size_t r = 0; + (void)r; + + return run_bench([&](auto) { r = v.find_first(); }); + } }; -template -struct BenchGrayCode -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = v; +template +struct BenchGrayCode { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = v; - return run_bench([&](auto) { chilbert::detail::gray_code(r); }); - } + return run_bench([&](auto) { chilbert::detail::gray_code(r); }); + } }; -template -struct BenchGrayCodeInv -{ - Duration operator()(Context& ctx) - { - const T v = make_random_bitvec(ctx); - T r = v; +template +struct BenchGrayCodeInv { + Duration operator()(Context& ctx) + { + const T v = make_random_bitvec(ctx); + T r = v; - return run_bench([&](auto) { chilbert::detail::gray_code_inv(r); }); - } + return run_bench([&](auto) { chilbert::detail::gray_code_inv(r); }); + } }; -template -struct BenchComparison -{ - Duration operator()(Context& ctx) - { - std::vector vecs; - for (size_t i = 0; i < 32; ++i) { - vecs.emplace_back(make_random_bitvec(ctx)); - } - - volatile bool r = false; - - return run_bench([&](const auto i) { - r |= vecs[i % vecs.size()] < vecs[(i + 1) % vecs.size()]; - }); - } +template +struct BenchComparison { + Duration operator()(Context& ctx) + { + std::vector vecs; + for (size_t i = 0; i < 32; ++i) { + vecs.emplace_back(make_random_bitvec(ctx)); + } + + volatile bool r = false; + + return run_bench([&](const auto i) { + r |= vecs[i % vecs.size()] < vecs[(i + 1) % vecs.size()]; + }); + } }; -template -struct BenchIteration -{ - Duration operator()(Context& ctx) - { - T v = make_random_bitvec(ctx); - auto i = v.begin(); - volatile bool r = false; - return run_bench([&](const auto) { - r = (++i == v.end()); - if (r) { - i = v.begin(); - } - }); - } +template +struct BenchIteration { + Duration operator()(Context& ctx) + { + T v = make_random_bitvec(ctx); + auto i = v.begin(); + volatile bool r = false; + return run_bench([&](const auto) { + r = (++i == v.end()); + if (r) { + i = v.begin(); + } + }); + } }; /// Run benchmark for size N -template