Skip to content

Commit

Permalink
🚨 clang-tidy
Browse files Browse the repository at this point in the history
Signed-off-by: burgholzer <burgholzer@me.com>
  • Loading branch information
burgholzer committed Jun 21, 2024
1 parent e5d7a58 commit c465f2a
Show file tree
Hide file tree
Showing 32 changed files with 210 additions and 68 deletions.
4 changes: 4 additions & 0 deletions include/EquivalenceCheckingManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "ThreadSafeQueue.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "checker/dd/DDSimulationChecker.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "checker/dd/applicationscheme/GateCostApplicationScheme.hpp"
#include "checker/dd/simulation/StateGenerator.hpp"
#include "checker/dd/simulation/StateType.hpp"
#include "dd/ComplexNumbers.hpp"
#include "dd/DDDefinitions.hpp"

Expand Down
5 changes: 3 additions & 2 deletions include/EquivalenceCriterion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

#pragma once

#include <exception>
#include <cstdint>
#include <iostream>
#include <string>

namespace ec {
enum class EquivalenceCriterion {
enum class EquivalenceCriterion : std::uint8_t {
NotEquivalent = 0,
Equivalent = 1,
NoInformation = 2,
Expand Down
5 changes: 5 additions & 0 deletions include/checker/dd/DDAlternatingChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@

#pragma once

#include "Configuration.hpp"
#include "DDEquivalenceChecker.hpp"
#include "DDPackageConfigs.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "applicationscheme/LookaheadApplicationScheme.hpp"
#include "dd/Package_fwd.hpp"

#include <nlohmann/json_fwd.hpp>
#include <utility>

namespace ec {
class DDAlternatingChecker final
Expand Down
2 changes: 1 addition & 1 deletion include/checker/dd/DDSimulationChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DDSimulationChecker final
return taskManager2.getInternalState().getVector();
}

void json(nlohmann::json& j) const noexcept override;
void json(nlohmann::basic_json<>& j) const noexcept override;

private:
// the initial state used for simulation. defaults to the all-zero state
Expand Down
8 changes: 5 additions & 3 deletions include/checker/dd/applicationscheme/ApplicationScheme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@

#pragma once

#include "QuantumComputation.hpp"
#include "checker/dd/TaskManager.hpp"

#include <cstddef>
#include <cstdint>
#include <iostream>
#include <stdexcept>
#include <string>
#include <utility>

namespace ec {
// A list of application schemes that implement the below interface
enum class ApplicationSchemeType {
enum class ApplicationSchemeType : std::uint8_t {
Sequential = 0,
OneToOne = 1,
Lookahead = 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
#pragma once

#include "ApplicationScheme.hpp"
#include "checker/dd/TaskManager.hpp"
#include "dd/Package.hpp"
#include "dd/Package_fwd.hpp"

#include <cassert>
#include <cstddef>
#include <utility>

namespace ec {
template <class Config>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#pragma once

#include "ApplicationScheme.hpp"
#include "checker/dd/TaskManager.hpp"

#include <cstddef>
#include <utility>

namespace ec {
template <class DDType, class Config>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#pragma once

#include "ApplicationScheme.hpp"
#include "checker/dd/TaskManager.hpp"

#include <cstddef>
#include <utility>

namespace ec {
template <class DDType, class Config>
Expand All @@ -23,7 +27,7 @@ class SequentialApplicationScheme final
}

private:
const std::size_t gates1;
const std::size_t gates2;
std::size_t gates1;
std::size_t gates2;
};
} // namespace ec
20 changes: 15 additions & 5 deletions include/checker/dd/simulation/StateGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@

#include "StateType.hpp"
#include "algorithms/RandomCliffordCircuit.hpp"
#include "checker/dd/TaskManager.hpp"
#include "dd/DDDefinitions.hpp"
#include "dd/DDpackageConfig.hpp"
#include "dd/Package.hpp"
#include "dd/Simulation.hpp"

#include <functional>
#include "dd/Package_fwd.hpp"
#include "dd/Simulation.hpp" // IWYU pragma: keep

#include <array>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <random>
#include <tuple>
#include <unordered_set>
#include <vector>

namespace ec {
class StateGenerator {
Expand Down Expand Up @@ -168,7 +178,7 @@ class StateGenerator {
std::size_t seed = 0U;
std::mt19937_64 mt;

std::unordered_set<std::size_t> generatedComputationalBasisStates{};
std::unordered_set<std::size_t> generatedComputationalBasisStates;
constexpr static std::size_t ONE_QUBIT_BASE_ELEMENTS = 6U;
// this generator produces random bases from the set { |0>, |1>, |+>, |->,
// |L>, |R> }
Expand Down
4 changes: 3 additions & 1 deletion include/checker/dd/simulation/StateType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

#pragma once

#include <cstdint>
#include <iostream>
#include <string>

namespace ec {
enum class StateType {
enum class StateType : std::uint8_t {
ComputationalBasis = 0,
Random1QBasis = 1,
Stabilizer = 2
Expand Down
11 changes: 7 additions & 4 deletions include/checker/zx/ZXChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
#pragma once

#include "Configuration.hpp"
#include "Definitions.hpp"
#include "EquivalenceCriterion.hpp"
#include "Permutation.hpp"
#include "QuantumComputation.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "nlohmann/json.hpp"
#include "zx/Simplify.hpp"
#include "zx/Rules.hpp"
#include "zx/ZXDefinitions.hpp"
#include "zx/ZXDiagram.hpp"

#include <cstddef>
#include <nlohmann/json.hpp>

namespace ec {
class ZXEquivalenceChecker : public EquivalenceChecker {
public:
Expand All @@ -23,7 +26,7 @@ class ZXEquivalenceChecker : public EquivalenceChecker {

EquivalenceCriterion run() override;

void json(nlohmann::json& j) const noexcept override {
void json(nlohmann::basic_json<>& j) const noexcept override {
EquivalenceChecker::json(j);
j["checker"] = "zx";
}
Expand Down
7 changes: 5 additions & 2 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include "Configuration.hpp"

#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "checker/dd/simulation/StateType.hpp"

#include <nlohmann/json.hpp>

namespace ec {
Expand Down Expand Up @@ -47,8 +50,8 @@ bool Configuration::onlySimulationCheckerConfigured() const noexcept {
!execution.runAlternatingChecker && !execution.runZXChecker;
}

nlohmann::json Configuration::json() const {
nlohmann::json config{};
nlohmann::basic_json<> Configuration::json() const {
nlohmann::basic_json<> config{};
auto& exe = config["execution"];
exe["tolerance"] = execution.numericalTolerance;
exe["parallel"] = execution.parallel;
Expand Down
9 changes: 6 additions & 3 deletions src/EquivalenceCheckingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "EquivalenceCriterion.hpp"
#include "Permutation.hpp"
#include "QuantumComputation.hpp"
#include "ThreadSafeQueue.hpp"
#include "checker/dd/DDAlternatingChecker.hpp"
#include "checker/dd/DDConstructionChecker.hpp"
#include "checker/dd/DDSimulationChecker.hpp"
Expand All @@ -21,11 +22,13 @@
#include <cassert>
#include <chrono>
#include <cstddef>
#include <future>
#include <iostream>
#include <memory>
#include <mutex>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
#include <stdexcept>
#include <thread>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -336,7 +339,7 @@ void EquivalenceCheckingManager::run() {
}

for (const auto& checker : checkers) {
nlohmann::json j{};
nlohmann::basic_json j{};
checker->json(j);
results.checkerResults.emplace_back(j);
}
Expand Down Expand Up @@ -881,7 +884,7 @@ void EquivalenceCheckingManager::checkSymbolic() {
std::clog << "Checking symbolic circuits requires transformation "
"to ZX-diagram but one of the circuits contains "
"operations not supported by this checker! Exiting!"
<< std::endl;
<< '\n';
checkers.clear();
results.equivalence = EquivalenceCriterion::NoInformation;
return;
Expand Down
6 changes: 5 additions & 1 deletion src/checker/EquivalenceChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

#include "checker/EquivalenceChecker.hpp"

#include "EquivalenceCriterion.hpp"

#include <nlohmann/json.hpp>

// this function is mainly placed here in order to have an out-of-line
// virtual method definition which avoids emitting the classe's vtable in
// every translation unit.
void ec::EquivalenceChecker::json(nlohmann::json& j) const noexcept {
void ec::EquivalenceChecker::json(nlohmann::basic_json<>& j) const noexcept {
j["equivalence"] = toString(equivalence);
j["runtime"] = getRuntime();
}
2 changes: 1 addition & 1 deletion src/checker/dd/DDAlternatingChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool DDAlternatingChecker::canHandle(const qc::QuantumComputation& qc1,
return true;
}

void DDAlternatingChecker::json(nlohmann::json& j) const noexcept {
void DDAlternatingChecker::json(nlohmann::basic_json<>& j) const noexcept {
DDEquivalenceChecker::json(j);
j["checker"] = "decision_diagram_alternating";
}
Expand Down
2 changes: 1 addition & 1 deletion src/checker/dd/DDConstructionChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// this function is mainly placed here in order to have an out-of-line
// virtual method definition which avoids emitting the classes' vtable in
// every translation unit.
void ec::DDConstructionChecker::json(nlohmann::json& j) const noexcept {
void ec::DDConstructionChecker::json(nlohmann::basic_json<>& j) const noexcept {
DDEquivalenceChecker::json(j);
j["checker"] = "decision_diagram_construction";
}
2 changes: 1 addition & 1 deletion src/checker/dd/DDEquivalenceChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void DDEquivalenceChecker<DDType, Config>::initializeApplicationScheme(

template <class DDType, class Config>
void DDEquivalenceChecker<DDType, Config>::json(
nlohmann::json& j) const noexcept {
nlohmann::basic_json<>& j) const noexcept {
EquivalenceChecker::json(j);
j["max_nodes"] = maxActiveNodes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/checker/dd/DDSimulationChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void DDSimulationChecker::setRandomInitialState(StateGenerator& generator) {
generator.generateRandomState(*dd, nqubits, nancillary, stateType);
}

void DDSimulationChecker::json(nlohmann::json& j) const noexcept {
void DDSimulationChecker::json(nlohmann::basic_json<>& j) const noexcept {
DDEquivalenceChecker::json(j);
j["checker"] = "decision_diagram_simulation";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include "checker/dd/applicationscheme/GateCostApplicationScheme.hpp"

#include "operations/OpType.hpp"

#include <cstddef>

namespace ec {
[[nodiscard]] std::size_t
legacyCostFunction(const GateCostLookupTableKeyType& key) noexcept {
Expand Down
6 changes: 6 additions & 0 deletions src/checker/dd/simulation/StateGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

#include "checker/dd/simulation/StateGenerator.hpp"

#include <algorithm>
#include <array>
#include <cstddef>
#include <functional>
#include <random>

namespace ec {

void StateGenerator::seedGenerator(const std::size_t s) {
Expand Down
8 changes: 6 additions & 2 deletions src/checker/zx/ZXChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@

#include "checker/zx/ZXChecker.hpp"

#include "Configuration.hpp"
#include "Definitions.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "zx/FunctionalityConstruction.hpp"
#include "zx/Simplify.hpp"
#include "zx/Rules.hpp"
#include "zx/ZXDefinitions.hpp"
#include "zx/ZXDiagram.hpp"

#include <cassert>
#include <chrono>
#include <cstddef>
#include <optional>
#include <unordered_map>
#include <utility>
#include <vector>

namespace ec {
Expand Down
9 changes: 7 additions & 2 deletions test/legacy/test_compilationflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
// See README.md or go to https://github.com/cda-tum/qcec for more information.
//

#include "Configuration.hpp"
#include "EquivalenceCheckingManager.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "checker/dd/applicationscheme/GateCostApplicationScheme.hpp"

#include "gtest/gtest.h"
#include <functional>
#include <algorithm>
#include <gtest/gtest.h>
#include <iostream>
#include <string>

class CompilationFlowTest : public testing::TestWithParam<std::string> {
Expand Down
Loading

0 comments on commit c465f2a

Please sign in to comment.