Skip to content

Bump the submodules group with 2 updates #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ repos:
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]
- id: cmake-lint
additional_dependencies: [pyyaml]

# Clang-format the C++ part of the code base automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ endmacro()
check_submodule_present(mqt-core)
check_submodule_present(taskflow)

option(BUILD_MQT_DDSIM_TESTS "Also build tests for the MQT DDSIM project" ON)
option(BUILD_MQT_DDSIM_BINDINGS "Build the MQT DDSIM Python bindings" OFF)
if(BUILD_MQT_DDSIM_BINDINGS)
# ensure that the BINDINGS option is set
Expand All @@ -43,9 +44,10 @@ if(BUILD_MQT_DDSIM_BINDINGS)
OPTIONAL_COMPONENTS Development.SABIModule)
endif()

include(cmake/ExternalDependencies.cmake)

add_subdirectory(src)

option(BUILD_MQT_DDSIM_TESTS "Also build tests for the MQT DDSIM project" ON)
if(BUILD_MQT_DDSIM_TESTS)
enable_testing()
include(GoogleTest)
Expand Down
3 changes: 1 addition & 2 deletions apps/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ int main(int argc, char** argv) { // NOLINT(bugprone-exception-escape)
}

if (vm.count("pcomplex") > 0) {
outputObj["complex_stats"]["cache_count"] = ddsim->dd->cn.cacheCount();
outputObj["complex_stats"]["real_count"] = ddsim->dd->cn.realCount();
outputObj["complex_stats"]["real_count"] = ddsim->dd->cn.realCount();
}

if (vm.count("dump_complex") > 0) {
Expand Down
30 changes: 30 additions & 0 deletions cmake/ExternalDependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Declare all external dependencies and make sure that they are available.

include(FetchContent)
set(FETCH_PACKAGES "")

if(BUILD_MQT_DDSIM_TESTS)
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
set(GTEST_VERSION
1.14.0
CACHE STRING "Google Test version")
set(GTEST_URL
https://github.com/google/googletest/archive/refs/tags/v${GTEST_VERSION}.tar.gz
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
FetchContent_Declare(googletest URL ${GTEST_URL} FIND_PACKAGE_ARGS
${GTEST_VERSION} NAMES GTest)
list(APPEND FETCH_PACKAGES googletest)
else()
find_package(googletest ${GTEST_VERSION} QUIET NAMES GTest)
if(NOT googletest_FOUND)
FetchContent_Declare(googletest URL ${GTEST_URL})
list(APPEND FETCH_PACKAGES googletest)
endif()
endif()
endif()

# Make all declared dependencies available.
FetchContent_MakeAvailable(${FETCH_PACKAGES})
2 changes: 1 addition & 1 deletion extern/mqt-core
2 changes: 1 addition & 1 deletion extern/taskflow
Submodule taskflow updated 74 files
+12 −11 .github/workflows/ubuntu.yml
+6 −6 docs/ParallelFind.html
+5 −5 docs/ParallelIterations.html
+3 −3 docs/ParallelReduction.html
+6 −6 docs/ParallelScan.html
+4 −4 docs/ParallelTransforms.html
+23 −2 docs/PartitioningAlgorithm.html
+2 −1 docs/annotated.html
+51 −6 docs/classtf_1_1DynamicPartitioner.html
+191 −131 docs/classtf_1_1FlowBuilder.html
+51 −6 docs/classtf_1_1GuidedPartitioner.html
+64 −29 docs/classtf_1_1PartitionerBase.html
+70 −16 docs/classtf_1_1RandomPartitioner.html
+59 −11 docs/classtf_1_1StaticPartitioner.html
+1 −1 docs/contributors.html
+1 −1 docs/matrix_multiplication.html
+43 −6 docs/namespacetf.html
+10 −1 docs/partitioner_8hpp.html
+1 −1 docs/release-2-0-0.html
+1 −1 docs/release-2-6-0.html
+1 −1 docs/release-3-3-0.html
+1 −1 docs/release-3-5-0.html
+1 −1 docs/release-3-6-0.html
+18 −1 docs/release-3-7-0.html
+1 −1 docs/searchdata-v2.js
+102 −0 docs/structtf_1_1DefaultClosureWrapper.html
+12 −12 docs/xml/ParallelFind.xml
+5 −5 docs/xml/ParallelIterations.xml
+3 −3 docs/xml/ParallelReduction.xml
+6 −6 docs/xml/ParallelScan.xml
+4 −4 docs/xml/ParallelTransforms.xml
+39 −6 docs/xml/PartitioningAlgorithm.xml
+119 −29 docs/xml/classtf_1_1DynamicPartitioner.xml
+30 −30 docs/xml/classtf_1_1Executor.xml
+297 −131 docs/xml/classtf_1_1FlowBuilder.xml
+119 −29 docs/xml/classtf_1_1GuidedPartitioner.xml
+179 −49 docs/xml/classtf_1_1PartitionerBase.xml
+172 −55 docs/xml/classtf_1_1RandomPartitioner.xml
+12 −12 docs/xml/classtf_1_1Runtime.xml
+131 −41 docs/xml/classtf_1_1StaticPartitioner.xml
+27 −27 docs/xml/classtf_1_1Subflow.xml
+17 −17 docs/xml/classtf_1_1Taskflow.xml
+2 −0 docs/xml/contributors.xml
+67 −46 docs/xml/index.xml
+2 −2 docs/xml/indexpage.xml
+2 −2 docs/xml/matrix_multiplication.xml
+37 −7 docs/xml/namespacetf.xml
+2 −0 docs/xml/partitioner_8hpp.xml
+1 −1 docs/xml/release-2-0-0.xml
+4 −4 docs/xml/release-2-6-0.xml
+5 −5 docs/xml/release-3-3-0.xml
+2 −2 docs/xml/release-3-5-0.xml
+16 −16 docs/xml/release-3-6-0.xml
+28 −1 docs/xml/release-3-7-0.xml
+15 −0 docs/xml/structtf_1_1DefaultClosureWrapper.xml
+56 −0 docs/xml/structtf_1_1IsPartitioner.xml
+47 −4 doxygen/algorithms/partitioner.dox
+2 −0 doxygen/contributing/contributors.dox
+30 −0 doxygen/releases/release-3.7.0.dox
+220 −204 taskflow/algorithm/find.hpp
+59 −47 taskflow/algorithm/for_each.hpp
+8 −0 taskflow/algorithm/launch.hpp
+332 −66 taskflow/algorithm/partitioner.hpp
+224 −198 taskflow/algorithm/reduce.hpp
+170 −124 taskflow/algorithm/scan.hpp
+64 −56 taskflow/algorithm/transform.hpp
+0 −15 taskflow/core/executor.hpp
+71 −50 taskflow/core/flow_builder.hpp
+11 −5 taskflow/core/notifier.hpp
+16 −0 taskflow/utility/macros.hpp
+342 −96 unittests/test_find.cpp
+225 −96 unittests/test_for_each.cpp
+483 −304 unittests/test_reduce.cpp
+159 −88 unittests/test_transform.cpp
2 changes: 1 addition & 1 deletion include/ShorFastSimulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ShorFastSimulator: public Simulator<Config> {

void applyGate(dd::GateMatrix matrix, dd::Qubit target);

std::vector<std::map<dd::vNode*, dd::vEdge>> nodesOnLevel;
std::vector<std::map<dd::vNode*, dd::vCachedEdge>> nodesOnLevel;

dd::mEdge addConst(std::uint64_t a);

Expand Down
6 changes: 3 additions & 3 deletions src/CircuitSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dd::fp CircuitSimulator<Config>::expectationValue(const qc::QuantumComputation&
singleShot(true);

// construct the DD for the observable
const auto observableDD = dd::buildFunctionality(&observable, Simulator<Config>::dd);
const auto observableDD = dd::buildFunctionality(&observable, *Simulator<Config>::dd);

// calculate the expectation value
return Simulator<Config>::dd->expectationValue(observableDD, Simulator<Config>::rootEdge);
Expand Down Expand Up @@ -136,7 +136,7 @@ std::map<std::size_t, bool> CircuitSimulator<Config>::singleShot(const bool igno
// apply an X operation whenever the measured result is one
if (bit == '1') {
const auto x = qc::StandardOperation(qc->getNqubits(), qubit, qc::X);
auto tmp = Simulator<Config>::dd->multiply(dd::getDD(&x, Simulator<Config>::dd), Simulator<Config>::rootEdge);
auto tmp = Simulator<Config>::dd->multiply(dd::getDD(&x, *Simulator<Config>::dd), Simulator<Config>::rootEdge);
Simulator<Config>::dd->incRef(tmp);
Simulator<Config>::dd->decRef(Simulator<Config>::rootEdge);
Simulator<Config>::rootEdge = tmp;
Expand Down Expand Up @@ -176,7 +176,7 @@ std::map<std::size_t, bool> CircuitSimulator<Config>::singleShot(const bool igno
<< " #controls=" << op->getControls().size()
<< " statesize=" << dd->size(rootEdge) << "\n";//*/

auto ddOp = dd::getDD(op.get(), Simulator<Config>::dd);
auto ddOp = dd::getDD(op.get(), *Simulator<Config>::dd);
auto tmp = Simulator<Config>::dd->multiply(ddOp, Simulator<Config>::rootEdge);
Simulator<Config>::dd->incRef(tmp);
Simulator<Config>::dd->decRef(Simulator<Config>::rootEdge);
Expand Down
3 changes: 2 additions & 1 deletion src/DeterministicNoiseSimulator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DeterministicNoiseSimulator.hpp"

#include "dd/Export.hpp"
#include "dd/Operations.hpp"

using CN = dd::ComplexNumbers;

Expand Down Expand Up @@ -35,7 +36,7 @@ dd::SparsePVecStrKeys DeterministicNoiseSimulator<Config>::deterministicSimulate
if (op->isClassicControlledOperation()) {
throw std::runtime_error("Classical controlled operations are not supported.");
}
auto operation = dd::getDD(op.get(), Simulator<Config>::dd);
auto operation = dd::getDD(op.get(), *Simulator<Config>::dd);

// Applying the operation to the density matrix
Simulator<Config>::dd->applyOperationToDensity(rootEdge, operation, useDensityMatrixType);
Expand Down
6 changes: 3 additions & 3 deletions src/GroverSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ std::map<std::string, std::size_t> GroverSimulator<Config>::simulate(std::size_t
qcSetup.h(i);
}

const dd::Edge setupOp{dd::buildFunctionality(&qcSetup, Simulator<Config>::dd)};
const dd::Edge setupOp{dd::buildFunctionality(&qcSetup, *Simulator<Config>::dd)};

// Build the oracle
qc::QuantumComputation qcOracle(nQubits + nAnciallae);
Expand All @@ -24,7 +24,7 @@ std::map<std::string, std::size_t> GroverSimulator<Config>::simulate(std::size_t
}
qcOracle.mcz(controls, nQubits);

const dd::Edge oracleOp{dd::buildFunctionality(&qcOracle, Simulator<Config>::dd)};
const dd::Edge oracleOp{dd::buildFunctionality(&qcOracle, *Simulator<Config>::dd)};

// Build the diffusion stage.
qc::QuantumComputation qcDiffusion(nQubits + nAnciallae);
Expand Down Expand Up @@ -53,7 +53,7 @@ std::map<std::string, std::size_t> GroverSimulator<Config>::simulate(std::size_t
qcDiffusion.h(i);
}

const dd::Edge diffusionOp{dd::buildFunctionality(&qcDiffusion, Simulator<Config>::dd)};
const dd::Edge diffusionOp{dd::buildFunctionality(&qcDiffusion, *Simulator<Config>::dd)};

const dd::Edge fullIteration{Simulator<Config>::dd->multiply(oracleOp, diffusionOp)};
Simulator<Config>::dd->incRef(fullIteration);
Expand Down
2 changes: 1 addition & 1 deletion src/HybridSchrodingerFeynmanSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool HybridSchrodingerFeynmanSimulator<Config>::Slice::apply(std::unique_ptr<dd:
const auto& param = op->getParameter();
qc::StandardOperation newOp(nqubits, opControls, opTargets, op->getType(), param, start);
sliceDD->decRef(edge);
edge = sliceDD->multiply(dd::getDD(&newOp, sliceDD), edge, static_cast<dd::Qubit>(start));
edge = sliceDD->multiply(dd::getDD(&newOp, *sliceDD), edge, static_cast<dd::Qubit>(start));
sliceDD->incRef(edge);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/PathSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void PathSimulator<Config>::constructTaskGraph() {
results.emplace(leftID, zeroState);
} else {
const auto& op = CircuitSimulator<Config>::qc->at(leftID - 1);
qc::MatrixDD opDD = dd::getDD(op.get(), Simulator<Config>::dd);
qc::MatrixDD opDD = dd::getDD(op.get(), *Simulator<Config>::dd);
Simulator<Config>::dd->incRef(opDD);
results.emplace(leftID, opDD);
}
Expand All @@ -390,7 +390,7 @@ void PathSimulator<Config>::constructTaskGraph() {
throw std::runtime_error("Initial state must not appear on right side of the simulation path member.");
}
const auto& op = CircuitSimulator<Config>::qc->at(rightID - 1);
qc::MatrixDD opDD = dd::getDD(op.get(), Simulator<Config>::dd);
qc::MatrixDD opDD = dd::getDD(op.get(), *Simulator<Config>::dd);
Simulator<Config>::dd->incRef(opDD);
results.emplace(rightID, opDD);
}
Expand Down
100 changes: 37 additions & 63 deletions src/ShorFastSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ void ShorFastSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit targe
*/
template<class Config>
void ShorFastSimulator<Config>::uAEmulate2(const std::uint64_t a) {
[[maybe_unused]] const std::size_t cacheCountBefore = Simulator<Config>::dd->cn.cacheCount();
dagEdges.clear();

dd::vEdge f = dd::vEdge::one();
Expand All @@ -349,77 +348,56 @@ void ShorFastSimulator<Config>::uAEmulate2(const std::uint64_t a) {

// clear nodesOnLevel. TODO: make it a local variable?
for (auto& m: nodesOnLevel) {
m = std::map<dd::vNode*, dd::vEdge>();
m = {};
}

// initialize nodesOnLevel
uAEmulate2Rec(Simulator<Config>::rootEdge.p->e[0]);

// special treatment for the nodes on first level
for (const auto& entry: nodesOnLevel.at(0)) {
dd::vEdge left = f;
if (entry.first->e[0].w.exactlyZero()) {
left = dd::vEdge::zero();
} else {
left.w = Simulator<Config>::dd->cn.mulCached(left.w, entry.first->e[0].w);
}

dd::vEdge right = Simulator<Config>::dd->multiply(addConstMod(ts[static_cast<std::size_t>(entry.first->v)]), f);

if (entry.first->e[1].w.exactlyZero()) {
right = dd::vEdge::zero();
} else {
right.w = Simulator<Config>::dd->cn.mulCached(right.w, entry.first->e[1].w);
auto left = dd::vCachedEdge::zero();
if (!entry.first->e[0].w.exactlyZero()) {
left = {f.p, f.w * entry.first->e[0].w};
}

const dd::vEdge result = Simulator<Config>::dd->add(left, right);

if (!left.w.exactlyZero()) {
Simulator<Config>::dd->cn.returnToCache(left.w);
auto right = dd::vCachedEdge::zero();
if (!entry.first->e[1].w.exactlyZero()) {
auto tmp = Simulator<Config>::dd->multiply(addConstMod(ts[static_cast<std::size_t>(entry.first->v)]), f);
right = {tmp.p, tmp.w * entry.first->e[1].w};
}
if (!right.w.exactlyZero()) {
Simulator<Config>::dd->cn.returnToCache(right.w);
}

Simulator<Config>::dd->incRef(result);

nodesOnLevel[0][entry.first] = result;
nodesOnLevel[0][entry.first] = Simulator<Config>::dd->add2(left, right, 0);
}

// treat the nodes on the remaining levels
for (std::size_t i = 1; i < nQubits - 1; i++) {
std::vector<dd::vEdge> saveEdges;
for (auto it = nodesOnLevel.at(i).begin(); it != nodesOnLevel.at(i).end(); it++) {
dd::vEdge left = dd::vEdge::zero();
auto left = dd::vCachedEdge::zero();
if (!it->first->e.at(0).w.exactlyZero()) {
left = nodesOnLevel.at(i - 1)[it->first->e.at(0).p];
left.w = Simulator<Config>::dd->cn.mulCached(left.w, it->first->e.at(0).w);
left.w = left.w * it->first->e.at(0).w;
}

dd::vEdge right = dd::vEdge::zero();
auto right = dd::vCachedEdge::zero();
if (!it->first->e.at(1).w.exactlyZero()) {
right = Simulator<Config>::dd->multiply(addConstMod(ts.at(static_cast<std::size_t>(it->first->v))), nodesOnLevel.at(i - 1)[it->first->e.at(1).p]);
right.w = Simulator<Config>::dd->cn.mulCached(right.w, it->first->e.at(1).w);
auto node0 = addConstMod(ts.at(static_cast<std::size_t>(it->first->v)));
auto& node1 = nodesOnLevel.at(i - 1)[it->first->e.at(1).p];
auto node2 = dd::vEdge{node1.p, Simulator<Config>::dd->cn.lookup(node1.w)};
auto res = Simulator<Config>::dd->multiply(node0, node2);
right = {res.p, res.w * it->first->e.at(1).w};
}

const dd::vEdge result = Simulator<Config>::dd->add(left, right);

if (!left.w.exactlyZero()) {
Simulator<Config>::dd->cn.returnToCache(left.w);
dd::Qubit level = 0;
if (left.p != nullptr) {
level = left.p->v;
}
if (!right.w.exactlyZero()) {
Simulator<Config>::dd->cn.returnToCache(right.w);
if (right.p != nullptr && right.p->v > level) {
level = right.p->v;
}

Simulator<Config>::dd->incRef(result);
nodesOnLevel.at(i)[it->first] = result;
saveEdges.push_back(result);
}
for (auto& it: nodesOnLevel.at(i - 1)) {
Simulator<Config>::dd->decRef(it.second);
nodesOnLevel.at(i)[it->first] = Simulator<Config>::dd->add2(left, right, level);
}
Simulator<Config>::dd->garbageCollect();
saveEdges.push_back(Simulator<Config>::rootEdge);
nodesOnLevel.at(i - 1).clear();
}

Expand All @@ -428,33 +406,29 @@ void ShorFastSimulator<Config>::uAEmulate2(const std::uint64_t a) {
throw std::runtime_error("error occurred");
}

dd::vEdge result = nodesOnLevel.at(nQubits - 2)[Simulator<Config>::rootEdge.p->e[0].p];

Simulator<Config>::dd->decRef(result);
auto result = nodesOnLevel.at(nQubits - 2)[Simulator<Config>::rootEdge.p->e[0].p];
result.w = result.w * Simulator<Config>::rootEdge.p->e[0].w;
auto tmp = dd::vCachedEdge{Simulator<Config>::rootEdge.p->e[0].p, Simulator<Config>::rootEdge.p->e[0].w};
result = Simulator<Config>::dd->makeDDNode(Simulator<Config>::rootEdge.p->v, std::array{tmp, result});

result.w = Simulator<Config>::dd->cn.mulCached(result.w, Simulator<Config>::rootEdge.p->e[0].w);
auto tmp = result.w;

result = Simulator<Config>::dd->makeDDNode(Simulator<Config>::rootEdge.p->v, std::array<dd::vEdge, dd::RADIX>{Simulator<Config>::rootEdge.p->e[0], result});
Simulator<Config>::dd->cn.returnToCache(tmp);

result.w = Simulator<Config>::dd->cn.mulCached(result.w, Simulator<Config>::rootEdge.w);
tmp = result.w;
result.w = Simulator<Config>::dd->cn.lookup(result.w);
Simulator<Config>::dd->cn.returnToCache(tmp);
result.w = result.w * Simulator<Config>::rootEdge.w;
auto res = dd::vEdge{result.p, Simulator<Config>::dd->cn.lookup(result.w)};
Simulator<Config>::dd->incRef(res);
Simulator<Config>::dd->decRef(Simulator<Config>::rootEdge);
Simulator<Config>::dd->incRef(result);
Simulator<Config>::rootEdge = result;
Simulator<Config>::rootEdge = res;
Simulator<Config>::dd->garbageCollect();
assert(Simulator<Config>::dd->cn.cacheCount() == cacheCountBefore);
}

template<class Config>
void ShorFastSimulator<Config>::uAEmulate2Rec(dd::vEdge e) {
if (e.isTerminal() || nodesOnLevel.at(static_cast<std::size_t>(e.p->v)).find(e.p) != nodesOnLevel.at(static_cast<std::size_t>(e.p->v)).end()) {
if (e.isTerminal()) {
return;
}
auto& nodes = nodesOnLevel.at(static_cast<std::size_t>(e.p->v));
if (nodes.find(e.p) != nodes.end()) {
return;
}
nodesOnLevel.at(static_cast<std::size_t>(e.p->v))[e.p] = dd::vEdge::zero();
nodes[e.p] = dd::vCachedEdge::zero();
uAEmulate2Rec(e.p->e[0]);
uAEmulate2Rec(e.p->e[1]);
}
Expand Down
Loading