diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 58ecaac8ef..f805df9dda 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -6,6 +6,9 @@ ### Improvements +* Update clang-tools version in Github workflows. +[(#351)](https://github.com/PennyLaneAI/pennylane-lightning/pull/351) + ### Documentation ### Bug fixes @@ -14,6 +17,8 @@ This release contains contributions from (in alphabetical order): +Chae-Yeun Park + --- # Release 0.26.0 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index c465f68b07..fe00cccdc1 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -45,7 +45,7 @@ jobs: python-version: 3.7 - name: Install dependencies - run: sudo apt update && sudo apt -y install clang-tidy-13 cmake g++-10 libomp-13-dev + run: sudo apt update && sudo apt -y install clang-tidy-14 cmake g++-10 libomp-14-dev env: DEBIAN_FRONTEND: noninteractive @@ -54,7 +54,7 @@ jobs: - name: Run clang-tidy compilation run: | - cmake -BBuild -DENABLE_CLANG_TIDY=ON -DCLANG_TIDY_BINARY=clang-tidy-13 -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DCMAKE_CXX_COMPILER="$(which g++-10)" . + cmake -BBuild -DENABLE_CLANG_TIDY=ON -DCLANG_TIDY_BINARY=clang-tidy-14 -DBUILD_TESTS=ON -DENABLE_WARNINGS=ON -DCMAKE_CXX_COMPILER="$(which g++-10)" . cmake --build ./Build --parallel 2 format-cpp: @@ -68,10 +68,10 @@ jobs: access_token: ${{ github.token }} - name: Install dependencies - run: sudo apt update && sudo apt -y install clang-format-13 python3 + run: sudo apt update && sudo apt -y install clang-format-14 python3 - name: Checkout code uses: actions/checkout@v2 - name: Run formatter - run: ./bin/format --check --cfversion 13 ./pennylane_lightning/src + run: ./bin/format --check --cfversion 14 ./pennylane_lightning/src diff --git a/bin/format b/bin/format index ad3d389fea..7b116f9185 100755 --- a/bin/format +++ b/bin/format @@ -18,7 +18,7 @@ CLANG_FMT_STYLE_CFG = { IGNORE_PATTERNS = ["external"] -DEFAULT_CLANG_FORMAT_VERSION=12 +DEFAULT_CLANG_FORMAT_VERSION=14 BASE_ARGS = f"-style={json.dumps(CLANG_FMT_STYLE_CFG)}" diff --git a/pennylane_lightning/_version.py b/pennylane_lightning/_version.py index 194def522a..641f1b2c78 100644 --- a/pennylane_lightning/_version.py +++ b/pennylane_lightning/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.27.0-dev" +__version__ = "0.27.0-dev1" diff --git a/pennylane_lightning/src/.clang-tidy b/pennylane_lightning/src/.clang-tidy index 85e6247011..8e91895e1d 100644 --- a/pennylane_lightning/src/.clang-tidy +++ b/pennylane_lightning/src/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,clang-diagnostic-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type,-modernize-loop-convert,clang-analyzer-cplusplus*,openmp-*,performance-*,portability-*,readability-*,hicpp-*,-hicpp-avoid-c-arrays,-hicpp-no-array-decay,bugprone-suspicious-*,llvm-namespace-comment,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions' +Checks: '-*,clang-diagnostic-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type,-modernize-loop-convert,clang-analyzer-cplusplus*,openmp-*,performance-*,portability-*,readability-*,hicpp-*,-hicpp-avoid-c-arrays,-hicpp-no-array-decay,bugprone-suspicious-*,llvm-namespace-comment,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions,-readability-identifier-length' WarningsAsErrors: '*' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: false diff --git a/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsLM.hpp b/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsLM.hpp index 34d4daa259..3184e5e7ba 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsLM.hpp +++ b/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsLM.hpp @@ -214,38 +214,24 @@ class GateImplementationsLM : public PauliGenerator { const std::complex v10 = arr[i10]; const std::complex v11 = arr[i11]; - // NOLINTNEXTLINE(readability-magic-numbers) + // NOLINTBEGIN(readability-magic-numbers) arr[i00] = std::conj(matrix[0b0000]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b0100]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1000]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1100]) * v11; - // NOLINTNEXTLINE(readability-magic-numbers) arr[i01] = std::conj(matrix[0b0001]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b0101]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1001]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1101]) * v11; - // NOLINTNEXTLINE(readability-magic-numbers) arr[i10] = std::conj(matrix[0b0010]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b0110]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1010]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1110]) * v11; - // NOLINTNEXTLINE(readability-magic-numbers) arr[i11] = std::conj(matrix[0b0011]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b0111]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1011]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) std::conj(matrix[0b1111]) * v11; + // NOLINTEND(readability-magic-numbers) } } else { for (size_t k = 0; k < Util::exp2(num_qubits - 2); k++) { @@ -261,22 +247,16 @@ class GateImplementationsLM : public PauliGenerator { const std::complex v10 = arr[i10]; const std::complex v11 = arr[i11]; - // NOLINTNEXTLINE(readability-magic-numbers) + // NOLINTBEGIN(readability-magic-numbers) arr[i00] = matrix[0b0000] * v00 + matrix[0b0001] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b0010] * v10 + matrix[0b0011] * v11; - // NOLINTNEXTLINE(readability-magic-numbers) arr[i01] = matrix[0b0100] * v00 + matrix[0b0101] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b0110] * v10 + matrix[0b0111] * v11; - // NOLINTNEXTLINE(readability-magic-numbers) arr[i10] = matrix[0b1000] * v00 + matrix[0b1001] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b1010] * v10 + matrix[0b1011] * v11; - // NOLINTNEXTLINE(readability-magic-numbers) arr[i11] = matrix[0b1100] * v00 + matrix[0b1101] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b1110] * v10 + matrix[0b1111] * v11; + // NOLINTEND(readability-magic-numbers) } } } diff --git a/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.cpp b/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.cpp index 142b2f0852..6124cb439d 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.cpp +++ b/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.cpp @@ -60,42 +60,26 @@ void GateImplementationsPI::applyDoubleExcitationMinus( for (const size_t &externalIndex : externalIndices) { std::complex *shiftedState = arr + externalIndex; - // NOLINTNEXTLINE(readability-magic-numbers) const std::complex v3 = shiftedState[indices[i0]]; - // NOLINTNEXTLINE(readability-magic-numbers) const std::complex v12 = shiftedState[indices[i1]]; - // NOLINTNEXTLINE(readability-magic-numbers) + // NOLINTBEGIN(readability-magic-numbers) shiftedState[indices[0]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[1]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[2]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[i0]] = c * v3 - s * v12; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[4]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[5]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[6]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[7]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[8]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[9]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[10]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[11]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[i1]] = s * v3 + c * v12; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[13]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[14]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[15]] *= e; + // NOLINTEND(readability-magic-numbers) } } @@ -118,42 +102,26 @@ void GateImplementationsPI::applyDoubleExcitationPlus( for (const size_t &externalIndex : externalIndices) { std::complex *shiftedState = arr + externalIndex; - // NOLINTNEXTLINE(readability-magic-numbers) const std::complex v3 = shiftedState[indices[i0]]; - // NOLINTNEXTLINE(readability-magic-numbers) const std::complex v12 = shiftedState[indices[i1]]; - // NOLINTNEXTLINE(readability-magic-numbers) + // NOLINTBEGIN(readability-magic-numbers) shiftedState[indices[0]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[1]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[2]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[i0]] = c * v3 - s * v12; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[4]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[5]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[6]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[7]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[8]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[9]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[10]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[11]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[i1]] = s * v3 + c * v12; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[13]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[14]] *= e; - // NOLINTNEXTLINE(readability-magic-numbers) shiftedState[indices[15]] *= e; + // NOLINTEND(readability-magic-numbers) } } diff --git a/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.hpp b/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.hpp index 3d6eabbd0f..ee3d5082d2 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.hpp +++ b/pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.hpp @@ -182,42 +182,24 @@ class GateImplementationsPI : public PauliGenerator { const std::complex v10 = shiftedState[indices[2]]; const std::complex v11 = shiftedState[indices[3]]; - // NOLINTNEXTLINE(readability-magic-numbers) - shiftedState[indices[0]] = - std::conj(matrix[0b0000]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b0100]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1000]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1100]) * v11; - // NOLINTNEXTLINE(readability-magic-numbers) - shiftedState[indices[1]] = - std::conj(matrix[0b0001]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b0101]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1001]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1101]) * v11; - // NOLINTNEXTLINE(readability-magic-numbers) - shiftedState[indices[2]] = - std::conj(matrix[0b0010]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b0110]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1010]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1110]) * v11; - // NOLINTNEXTLINE(readability-magic-numbers) - shiftedState[indices[3]] = - std::conj(matrix[0b0011]) * v00 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b0111]) * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1011]) * v10 + - // NOLINTNEXTLINE(readability-magic-numbers) - std::conj(matrix[0b1111]) * v11; + // NOLINTBEGIN(readability-magic-numbers) + shiftedState[indices[0]] = std::conj(matrix[0b0000]) * v00 + + std::conj(matrix[0b0100]) * v01 + + std::conj(matrix[0b1000]) * v10 + + std::conj(matrix[0b1100]) * v11; + shiftedState[indices[1]] = std::conj(matrix[0b0001]) * v00 + + std::conj(matrix[0b0101]) * v01 + + std::conj(matrix[0b1001]) * v10 + + std::conj(matrix[0b1101]) * v11; + shiftedState[indices[2]] = std::conj(matrix[0b0010]) * v00 + + std::conj(matrix[0b0110]) * v01 + + std::conj(matrix[0b1010]) * v10 + + std::conj(matrix[0b1110]) * v11; + shiftedState[indices[3]] = std::conj(matrix[0b0011]) * v00 + + std::conj(matrix[0b0111]) * v01 + + std::conj(matrix[0b1011]) * v10 + + std::conj(matrix[0b1111]) * v11; + // NOLINTEND(readability-magic-numbers) } } else { for (const size_t &externalIndex : externalIndices) { @@ -228,26 +210,20 @@ class GateImplementationsPI : public PauliGenerator { const std::complex v10 = shiftedState[indices[2]]; const std::complex v11 = shiftedState[indices[3]]; + // NOLINTBEGIN(readability-magic-numbers) shiftedState[indices[0]] = - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b0000] * v00 + matrix[0b0001] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b0010] * v10 + matrix[0b0011] * v11; shiftedState[indices[1]] = - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b0100] * v00 + matrix[0b0101] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b0110] * v10 + matrix[0b0111] * v11; shiftedState[indices[2]] = - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b1000] * v00 + matrix[0b1001] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b1010] * v10 + matrix[0b1011] * v11; shiftedState[indices[3]] = - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b1100] * v00 + matrix[0b1101] * v01 + - // NOLINTNEXTLINE(readability-magic-numbers) matrix[0b1110] * v10 + matrix[0b1111] * v11; + // NOLINTEND(readability-magic-numbers) } } } diff --git a/pennylane_lightning/src/gates/cpu_kernels/avx_common/AVXUtil.hpp b/pennylane_lightning/src/gates/cpu_kernels/avx_common/AVXUtil.hpp index 19d23261fc..07cabe0912 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/avx_common/AVXUtil.hpp +++ b/pennylane_lightning/src/gates/cpu_kernels/avx_common/AVXUtil.hpp @@ -269,10 +269,12 @@ constexpr auto internal_wires_v = InternalWires::value; #ifdef PL_USE_AVX2 constexpr __m256i setr256i(int32_t e0, int32_t e1, int32_t e2, int32_t e3, int32_t e4, int32_t e5, int32_t e6, int32_t e7) { - return __m256i{(static_cast(e1) << 32) | e0, // NOLINT(hicpp-signed-bitwise) - (static_cast(e3) << 32) | e2, // NOLINT(hicpp-signed-bitwise) - (static_cast(e5) << 32) | e4, // NOLINT(hicpp-signed-bitwise) - (static_cast(e7) << 32) | e6}; // NOLINT(hicpp-signed-bitwise) + // NOLINTBEGIN(hicpp-signed-bitwise) + return __m256i{(static_cast(e1) << 32) | e0, + (static_cast(e3) << 32) | e2, + (static_cast(e5) << 32) | e4, + (static_cast(e7) << 32) | e6}; + // NOLINTEND(hicpp-signed-bitwise) } #endif #ifdef PL_USE_AVX512F @@ -281,14 +283,16 @@ constexpr __m512i setr512i(int32_t e0, int32_t e1, int32_t e2, int32_t e3, int32_t e4, int32_t e5, int32_t e6, int32_t e7, int32_t e8, int32_t e9, int32_t e10, int32_t e11, int32_t e12, int32_t e13, int32_t e14, int32_t e15) { - return __m512i{(static_cast(e1) << 32) | e0, // NOLINT(hicpp-signed-bitwise) - (static_cast(e3) << 32) | e2, // NOLINT(hicpp-signed-bitwise) - (static_cast(e5) << 32) | e4, // NOLINT(hicpp-signed-bitwise) - (static_cast(e7) << 32) | e6, // NOLINT(hicpp-signed-bitwise) - (static_cast(e9) << 32) | e8, // NOLINT(hicpp-signed-bitwise) - (static_cast(e11) << 32) | e10, // NOLINT(hicpp-signed-bitwise) - (static_cast(e13) << 32) | e12, // NOLINT(hicpp-signed-bitwise) - (static_cast(e15) << 32) | e14}; // NOLINT(hicpp-signed-bitwise) + // NOLINTBEGIN(hicpp-signed-bitwise) + return __m512i{(static_cast(e1) << 32) | e0, + (static_cast(e3) << 32) | e2, + (static_cast(e5) << 32) | e4, + (static_cast(e7) << 32) | e6, + (static_cast(e9) << 32) | e8, + (static_cast(e11) << 32) | e10, + (static_cast(e13) << 32) | e12, + (static_cast(e15) << 32) | e14}; + // NOLINTEND(hicpp-signed-bitwise) } constexpr __m512i setr512i(int64_t e0, int64_t e1, int64_t e2, int64_t e3, int64_t e4, int64_t e5, int64_t e6, int64_t e7) { diff --git a/pennylane_lightning/src/gates/cpu_kernels/avx_common/Permutation.hpp b/pennylane_lightning/src/gates/cpu_kernels/avx_common/Permutation.hpp index a43cacfbb9..01148c4c05 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/avx_common/Permutation.hpp +++ b/pennylane_lightning/src/gates/cpu_kernels/avx_common/Permutation.hpp @@ -163,36 +163,38 @@ getPermutation4x(const std::array &permutation) { } //@endcond -// clang-format off #ifdef PL_USE_AVX2 -constexpr __m256i getPermutation8x256i(const std::array& permutation) { - return setr256i(permutation[0], permutation[1], // NOLINT(readability-magic-numbers) - permutation[2], permutation[3], // NOLINT(readability-magic-numbers) - permutation[4], permutation[5], // NOLINT(readability-magic-numbers) - permutation[6], permutation[7]);// NOLINT(readability-magic-numbers) +constexpr __m256i +getPermutation8x256i(const std::array &permutation) { + // NOLINTBEGIN(readability-magic-numbers) + return setr256i(permutation[0], permutation[1], permutation[2], + permutation[3], permutation[4], permutation[5], + permutation[6], permutation[7]); + // NOLINTEND(readability-magic-numbers) } #endif #ifdef PL_USE_AVX512F // LCOV_EXCL_START -constexpr __m512i getPermutation8x512i(const std::array& permutation) { - return setr512i(permutation[0], permutation[1], // NOLINT(readability-magic-numbers) - permutation[2], permutation[3], // NOLINT(readability-magic-numbers) - permutation[4], permutation[5], // NOLINT(readability-magic-numbers) - permutation[6], permutation[7]);// NOLINT(readability-magic-numbers) +constexpr __m512i +getPermutation8x512i(const std::array &permutation) { + // NOLINTBEGIN(readability-magic-numbers) + return setr512i(permutation[0], permutation[1], permutation[2], + permutation[3], permutation[4], permutation[5], + permutation[6], permutation[7]); + // NOLINTEND(readability-magic-numbers) } -constexpr __m512i getPermutation16x512i(const std::array& permutation) { - return setr512i( permutation[0], permutation[1], // NOLINT(readability-magic-numbers) - permutation[2], permutation[3], // NOLINT(readability-magic-numbers) - permutation[4], permutation[5], // NOLINT(readability-magic-numbers) - permutation[6], permutation[7], // NOLINT(readability-magic-numbers) - permutation[8], permutation[9], // NOLINT(readability-magic-numbers) - permutation[10], permutation[11], // NOLINT(readability-magic-numbers) - permutation[12], permutation[13], // NOLINT(readability-magic-numbers) - permutation[14], permutation[15]); // NOLINT(readability-magic-numbers) +constexpr __m512i +getPermutation16x512i(const std::array &permutation) { + // NOLINTBEGIN(readability-magic-numbers) + return setr512i( + permutation[0], permutation[1], permutation[2], permutation[3], + permutation[4], permutation[5], permutation[6], permutation[7], + permutation[8], permutation[9], permutation[10], permutation[11], + permutation[12], permutation[13], permutation[14], permutation[15]); + // NOLINTEND(readability-magic-numbers) } // LCOV_EXCL_STOP #endif -// clang-format on template constexpr auto compilePermutation( diff --git a/pennylane_lightning/src/gates/cpu_kernels/avx_common/SingleQubitGateHelper.hpp b/pennylane_lightning/src/gates/cpu_kernels/avx_common/SingleQubitGateHelper.hpp index 7df352652f..27b49176b6 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/avx_common/SingleQubitGateHelper.hpp +++ b/pennylane_lightning/src/gates/cpu_kernels/avx_common/SingleQubitGateHelper.hpp @@ -71,37 +71,35 @@ concept SingleQubitGate = SingleQubitGateWithoutParam || SingleQubitGateWithParam; namespace Internal { - template - constexpr auto InternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) - ->decltype(auto) { - return std::array{&AVXImpl::template applyInternal...}; - } - - template - constexpr auto InternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) - ->decltype(auto) { - return std::array{ - &AVXImpl::template applyInternal...}; - } +template +constexpr auto +InternalFunctions_Iter([[maybe_unused]] std::index_sequence dummy) + -> decltype(auto) { + return std::array{&AVXImpl::template applyInternal...}; +} + +template +constexpr auto +InternalFunctions_Iter([[maybe_unused]] std::index_sequence dummy) + -> decltype(auto) { + return std::array{&AVXImpl::template applyInternal...}; +} - template - constexpr auto InternalFunctions()->decltype(auto) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return InternalFunctions_Iter( - std::make_index_sequence()); - } +template +constexpr auto InternalFunctions() -> decltype(auto) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return InternalFunctions_Iter( + std::make_index_sequence()); +} - template - constexpr auto InternalFunctions()->decltype(auto) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return InternalFunctions_Iter( - std::make_index_sequence()); - } +template +constexpr auto InternalFunctions() -> decltype(auto) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return InternalFunctions_Iter( + std::make_index_sequence()); +} } // namespace Internal /// @endcond diff --git a/pennylane_lightning/src/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp b/pennylane_lightning/src/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp index c0aceac874..e769b79759 100644 --- a/pennylane_lightning/src/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp +++ b/pennylane_lightning/src/gates/cpu_kernels/avx_common/TwoQubitGateHelper.hpp @@ -106,116 +106,114 @@ concept TwoQubitGateWithoutParam = SymmetricTwoQubitGateWithoutParam || AsymmetricTwoQubitGateWithoutParam; namespace Internal { - template - constexpr auto ExternalInternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) - ->decltype(auto) { - return Util::tuple_to_array( - std::tuple{&AVXImpl::template applyExternalInternal...}); - } - - template - constexpr auto ExternalInternalFunctions()->decltype(auto) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return ExternalInternalFunctions_Iter( - std::make_index_sequence()); - } - // Symmetric two qubit gate without param begin - template - constexpr auto InternalInternalFunctions_IterTargets( - [[maybe_unused]] std::index_sequence dummy) { - return std::array{&AVXImpl::template applyInternalInternal< - std::min(control, target), std::max(control, target)>...}; - } - - template - constexpr auto InternalInternalFunctions_IterTargets( - [[maybe_unused]] std::index_sequence dummy) { - return std::array{ - &AVXImpl::template applyInternalInternal...}; - } - - template - constexpr auto InternalInternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return Util::tuple_to_array( - std::tuple{InternalInternalFunctions_IterTargets( - std::make_index_sequence())...}); - } - - template - constexpr auto InternalInternalFunctions()->decltype(auto) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return InternalInternalFunctions_Iter( - std::make_index_sequence()); - } - - template - constexpr auto InternalExternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) - ->decltype(auto) { - return std::array{ - &AVXImpl::template applyInternalExternal...}; - } - - template - constexpr auto InternalExternalFunctions()->decltype(auto) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return InternalExternalFunctions_Iter( - std::make_index_sequence()); - } - // Symmetric two qubit gate without param end - // Symmetric two qubit gate with param begin - template - constexpr auto InternalInternalFunctions_IterTargets( - [[maybe_unused]] std::index_sequence dummy) { - return std::array{&AVXImpl::template applyInternalInternal< - std::min(control, target), std::max(control, target), ParamT>...}; - } - - template - constexpr auto InternalInternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return Util::tuple_to_array(std::tuple{ - InternalInternalFunctions_IterTargets( - std::make_index_sequence())...}); - } - - template - constexpr auto InternalInternalFunctions() { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return InternalInternalFunctions_Iter( - std::make_index_sequence()); - } - - template - constexpr auto InternalExternalFunctions_Iter( - [[maybe_unused]] std::index_sequence dummy) { - return std::array{ - &AVXImpl::template applyInternalExternal...}; - } - - template - constexpr auto InternalExternalFunctions() { - constexpr size_t internal_wires = - Util::log2PerfectPower(AVXImpl::packed_size_ / 2); - return InternalExternalFunctions_Iter( - std::make_index_sequence()); - } - // Symmetric two qubit gate with param end +template +constexpr auto ExternalInternalFunctions_Iter( + [[maybe_unused]] std::index_sequence dummy) -> decltype(auto) { + return Util::tuple_to_array( + std::tuple{&AVXImpl::template applyExternalInternal...}); +} + +template +constexpr auto ExternalInternalFunctions() -> decltype(auto) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return ExternalInternalFunctions_Iter( + std::make_index_sequence()); +} +// Symmetric two qubit gate without param begin +template +constexpr auto InternalInternalFunctions_IterTargets( + [[maybe_unused]] std::index_sequence dummy) { + return std::array{ + &AVXImpl::template applyInternalInternal...}; +} + +template +constexpr auto InternalInternalFunctions_IterTargets( + [[maybe_unused]] std::index_sequence dummy) { + return std::array{ + &AVXImpl::template applyInternalInternal...}; +} + +template +constexpr auto InternalInternalFunctions_Iter( + [[maybe_unused]] std::index_sequence dummy) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return Util::tuple_to_array( + std::tuple{InternalInternalFunctions_IterTargets( + std::make_index_sequence())...}); +} + +template +constexpr auto InternalInternalFunctions() -> decltype(auto) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return InternalInternalFunctions_Iter( + std::make_index_sequence()); +} + +template +constexpr auto InternalExternalFunctions_Iter( + [[maybe_unused]] std::index_sequence dummy) -> decltype(auto) { + return std::array{&AVXImpl::template applyInternalExternal...}; +} + +template +constexpr auto InternalExternalFunctions() -> decltype(auto) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return InternalExternalFunctions_Iter( + std::make_index_sequence()); +} +// Symmetric two qubit gate without param end +// Symmetric two qubit gate with param begin +template +constexpr auto InternalInternalFunctions_IterTargets( + [[maybe_unused]] std::index_sequence dummy) { + return std::array{&AVXImpl::template applyInternalInternal< + std::min(control, target), std::max(control, target), ParamT>...}; +} + +template +constexpr auto InternalInternalFunctions_Iter( + [[maybe_unused]] std::index_sequence dummy) { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return Util::tuple_to_array(std::tuple{ + InternalInternalFunctions_IterTargets( + std::make_index_sequence())...}); +} + +template +constexpr auto InternalInternalFunctions() { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return InternalInternalFunctions_Iter( + std::make_index_sequence()); +} + +template +constexpr auto InternalExternalFunctions_Iter( + [[maybe_unused]] std::index_sequence dummy) { + return std::array{ + &AVXImpl::template applyInternalExternal...}; +} + +template +constexpr auto InternalExternalFunctions() { + constexpr size_t internal_wires = + Util::log2PerfectPower(AVXImpl::packed_size_ / 2); + return InternalExternalFunctions_Iter( + std::make_index_sequence()); +} +// Symmetric two qubit gate with param end } // namespace Internal /// @endcond diff --git a/pennylane_lightning/src/simulator/Measures.hpp b/pennylane_lightning/src/simulator/Measures.hpp index d053e4359a..be7f86fe36 100644 --- a/pennylane_lightning/src/simulator/Measures.hpp +++ b/pennylane_lightning/src/simulator/Measures.hpp @@ -377,7 +377,7 @@ class Measures { idx = bucket_partner[idx]; } // If cached, retrieve sample from cache - if (cache.count(idx) != 0) { + if (cache.contains(idx)) { size_t cache_id = cache[idx]; auto it_temp = samples.begin() + cache_id * num_qubits; std::copy(it_temp, it_temp + num_qubits, diff --git a/pennylane_lightning/src/tests/.clang-tidy b/pennylane_lightning/src/tests/.clang-tidy index 75afabace1..747793823a 100644 --- a/pennylane_lightning/src/tests/.clang-tidy +++ b/pennylane_lightning/src/tests/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-llvmlibc-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-cplusplus*,openmp-*,performance-*,portability-*,readability-*,-modernize-avoid-c-arrays,-readability-magic-numbers,hicpp-*,-hicpp-no-array-decay,-hicpp-avoid-c-arrays,bugprone-suspicious-*,llvm-namespace-comment,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions' +Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-llvmlibc-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-cplusplus*,openmp-*,performance-*,portability-*,readability-*,-modernize-avoid-c-arrays,-readability-magic-numbers,hicpp-*,-hicpp-no-array-decay,-hicpp-avoid-c-arrays,bugprone-suspicious-*,llvm-namespace-comment,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions,-readability-identifier-length' WarningsAsErrors: '*' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: false