Loading benchmarks/circuit_opt_benchmark.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,12 @@ int main() { auto q = qalloc(1); // Run the kernel testKernel(q); { class testKernel t(q); t.optimize_only = true; // kernel executed upon destruction, // will only build up circuit and run pass manager } std::cout << "NInsts: " << quantum::program->nInstructions() << "\n"; } #endif No newline at end of file examples/unitary/ccnot.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -15,11 +15,11 @@ __qpu__ void ccnot(qreg q) { // algorithm name and an optimizer. decompose { // Create the unitary matrix UnitaryMatrix ccnot = UnitaryMatrix::Identity(8, 8); ccnot(6, 6) = 0.0; ccnot(7, 7) = 0.0; ccnot(6, 7) = 1.0; ccnot(7, 6) = 1.0; UnitaryMatrix ccnot_mat = UnitaryMatrix::Identity(8, 8); ccnot_mat(6, 6) = 0.0; ccnot_mat(7, 7) = 0.0; ccnot_mat(6, 7) = 1.0; ccnot_mat(7, 6) = 1.0; } (q); Loading handlers/qcor_syntax_handler.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,12 @@ public: OS << ", " << program_parameters[i]; } OS << ");\n"; OS << "if (optimize_only) {\n"; OS << "xacc::internal_compiler::execute_pass_manager();\n"; OS << "return;\n"; OS << "}\n"; OS << "if (is_callable) {\n"; if (bufferNames.size() > 1) { OS << "xacc::AcceleratorBuffer * buffers[" << bufferNames.size() Loading runtime/kernel/quantum_kernel.hpp +6 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,11 @@ protected: bool disable_destructor = false; public: // Flag to indicate we only want to // run the pass manager and not execute bool optimize_only = false; // Default constructor, takes quantum kernel function arguments QuantumKernel(Args... args) : args_tuple(std::forward_as_tuple(args...)) {} Loading runtime/qrt/pass_manager.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ std::vector<PassStat> PassManager::optimize( stat.gateCountBefore = PassStat::countGates(program); xacc::ScopeTimer timer(passName, false); auto xaccOptTransform = xacc::getService<xacc::IRTransformation>(passName, false); xacc::getIRTransformation(passName); // Graciously ignores passes which cannot be located. if (xaccOptTransform) { xaccOptTransform->apply(program, nullptr); Loading Loading
benchmarks/circuit_opt_benchmark.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,12 @@ int main() { auto q = qalloc(1); // Run the kernel testKernel(q); { class testKernel t(q); t.optimize_only = true; // kernel executed upon destruction, // will only build up circuit and run pass manager } std::cout << "NInsts: " << quantum::program->nInstructions() << "\n"; } #endif No newline at end of file
examples/unitary/ccnot.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -15,11 +15,11 @@ __qpu__ void ccnot(qreg q) { // algorithm name and an optimizer. decompose { // Create the unitary matrix UnitaryMatrix ccnot = UnitaryMatrix::Identity(8, 8); ccnot(6, 6) = 0.0; ccnot(7, 7) = 0.0; ccnot(6, 7) = 1.0; ccnot(7, 6) = 1.0; UnitaryMatrix ccnot_mat = UnitaryMatrix::Identity(8, 8); ccnot_mat(6, 6) = 0.0; ccnot_mat(7, 7) = 0.0; ccnot_mat(6, 7) = 1.0; ccnot_mat(7, 6) = 1.0; } (q); Loading
handlers/qcor_syntax_handler.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,12 @@ public: OS << ", " << program_parameters[i]; } OS << ");\n"; OS << "if (optimize_only) {\n"; OS << "xacc::internal_compiler::execute_pass_manager();\n"; OS << "return;\n"; OS << "}\n"; OS << "if (is_callable) {\n"; if (bufferNames.size() > 1) { OS << "xacc::AcceleratorBuffer * buffers[" << bufferNames.size() Loading
runtime/kernel/quantum_kernel.hpp +6 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,11 @@ protected: bool disable_destructor = false; public: // Flag to indicate we only want to // run the pass manager and not execute bool optimize_only = false; // Default constructor, takes quantum kernel function arguments QuantumKernel(Args... args) : args_tuple(std::forward_as_tuple(args...)) {} Loading
runtime/qrt/pass_manager.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ std::vector<PassStat> PassManager::optimize( stat.gateCountBefore = PassStat::countGates(program); xacc::ScopeTimer timer(passName, false); auto xaccOptTransform = xacc::getService<xacc::IRTransformation>(passName, false); xacc::getIRTransformation(passName); // Graciously ignores passes which cannot be located. if (xaccOptTransform) { xaccOptTransform->apply(program, nullptr); Loading