Skip to content

Commit

Permalink
Update clang-tools version (#351)
Browse files Browse the repository at this point in the history
* Update clang-version and code accordingly

* Auto update version

* Use NOLINTBEGIN

* Update changelog

* Update version

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
chaeyeunpark and github-actions[bot] authored Sep 20, 2022
1 parent 316459f commit 4c6c154
Show file tree
Hide file tree
Showing 14 changed files with 216 additions and 285 deletions.
5 changes: 5 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

### Improvements

* Update clang-tools version in Github workflows.
[(#351)](https://github.com/PennyLaneAI/pennylane-lightning/pull/351)

### Documentation

### Bug fixes
Expand All @@ -14,6 +17,8 @@

This release contains contributions from (in alphabetical order):

Chae-Yeun Park

---

# Release 0.26.0
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion bin/format
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.27.0-dev"
__version__ = "0.27.0-dev1"
2 changes: 1 addition & 1 deletion pennylane_lightning/src/.clang-tidy
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,38 +214,24 @@ class GateImplementationsLM : public PauliGenerator<GateImplementationsLM> {
const std::complex<PrecisionT> v10 = arr[i10];
const std::complex<PrecisionT> 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++) {
Expand All @@ -261,22 +247,16 @@ class GateImplementationsLM : public PauliGenerator<GateImplementationsLM> {
const std::complex<PrecisionT> v10 = arr[i10];
const std::complex<PrecisionT> 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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,26 @@ void GateImplementationsPI::applyDoubleExcitationMinus(

for (const size_t &externalIndex : externalIndices) {
std::complex<PrecisionT> *shiftedState = arr + externalIndex;
// NOLINTNEXTLINE(readability-magic-numbers)
const std::complex<PrecisionT> v3 = shiftedState[indices[i0]];
// NOLINTNEXTLINE(readability-magic-numbers)
const std::complex<PrecisionT> 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)
}
}

Expand All @@ -118,42 +102,26 @@ void GateImplementationsPI::applyDoubleExcitationPlus(

for (const size_t &externalIndex : externalIndices) {
std::complex<PrecisionT> *shiftedState = arr + externalIndex;
// NOLINTNEXTLINE(readability-magic-numbers)
const std::complex<PrecisionT> v3 = shiftedState[indices[i0]];
// NOLINTNEXTLINE(readability-magic-numbers)
const std::complex<PrecisionT> 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)
}
}

Expand Down
64 changes: 20 additions & 44 deletions pennylane_lightning/src/gates/cpu_kernels/GateImplementationsPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,42 +182,24 @@ class GateImplementationsPI : public PauliGenerator<GateImplementationsPI> {
const std::complex<PrecisionT> v10 = shiftedState[indices[2]];
const std::complex<PrecisionT> 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) {
Expand All @@ -228,26 +210,20 @@ class GateImplementationsPI : public PauliGenerator<GateImplementationsPI> {
const std::complex<PrecisionT> v10 = shiftedState[indices[2]];
const std::complex<PrecisionT> 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)
}
}
}
Expand Down
28 changes: 16 additions & 12 deletions pennylane_lightning/src/gates/cpu_kernels/avx_common/AVXUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,12 @@ constexpr auto internal_wires_v = InternalWires<packed_size>::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<int64_t>(e1) << 32) | e0, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e3) << 32) | e2, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e5) << 32) | e4, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e7) << 32) | e6}; // NOLINT(hicpp-signed-bitwise)
// NOLINTBEGIN(hicpp-signed-bitwise)
return __m256i{(static_cast<int64_t>(e1) << 32) | e0,
(static_cast<int64_t>(e3) << 32) | e2,
(static_cast<int64_t>(e5) << 32) | e4,
(static_cast<int64_t>(e7) << 32) | e6};
// NOLINTEND(hicpp-signed-bitwise)
}
#endif
#ifdef PL_USE_AVX512F
Expand All @@ -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<int64_t>(e1) << 32) | e0, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e3) << 32) | e2, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e5) << 32) | e4, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e7) << 32) | e6, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e9) << 32) | e8, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e11) << 32) | e10, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e13) << 32) | e12, // NOLINT(hicpp-signed-bitwise)
(static_cast<int64_t>(e15) << 32) | e14}; // NOLINT(hicpp-signed-bitwise)
// NOLINTBEGIN(hicpp-signed-bitwise)
return __m512i{(static_cast<int64_t>(e1) << 32) | e0,
(static_cast<int64_t>(e3) << 32) | e2,
(static_cast<int64_t>(e5) << 32) | e4,
(static_cast<int64_t>(e7) << 32) | e6,
(static_cast<int64_t>(e9) << 32) | e8,
(static_cast<int64_t>(e11) << 32) | e10,
(static_cast<int64_t>(e13) << 32) | e12,
(static_cast<int64_t>(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) {
Expand Down
Loading

0 comments on commit 4c6c154

Please sign in to comment.