Loading runtime/qrt/pass_manager.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include "InstructionIterator.hpp" #include "xacc.hpp" #include "xacc_service.hpp" #include "xacc_internal_compiler.hpp" #include <iomanip> #include <numeric> namespace { Loading Loading @@ -91,6 +92,23 @@ std::vector<PassStat> PassManager::optimize( return passData; } void PassManager::applyPlacement(std::shared_ptr<xacc::CompositeInstruction> program, const std::string &placementName) { if (!xacc::hasService<xacc::IRTransformation>(placementName) && !xacc::hasContributedService<xacc::IRTransformation>(placementName)) { // Graciously ignores services which cannot be located. return; } auto irt = xacc::getIRTransformation(placementName); if (irt->type() == xacc::IRTransformationType::Placement && xacc::internal_compiler::qpu && !xacc::internal_compiler::qpu->getConnectivity().empty()) { irt->apply(program, xacc::internal_compiler::qpu); } // DEBUG: std::cout << "HOWDY:\n" << program->toString() << "\n"; } std::unordered_map<std::string, int> PassStat::countGates( const std::shared_ptr<xacc::CompositeInstruction> &program) { std::unordered_map<std::string, int> gateCount; Loading runtime/qrt/pass_manager.hpp +5 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,11 @@ public: PassManager(int level); // Static helper to run an optimization pass static PassStat runPass(const std::string &passName, std::shared_ptr<xacc::CompositeInstruction> program); // Default placement strategy static constexpr const char *DEFAULT_PLACEMENT = "swap-shortest-path"; // Apply placement static void applyPlacement(std::shared_ptr<xacc::CompositeInstruction> program, const std::string &placementName = DEFAULT_PLACEMENT); // Optimizes the input program. // Returns the full statistics about all the passes that have been executed. std::vector<PassStat> Loading runtime/qrt/qrt.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ void execute_pass_manager() { std::cout << passData.toString(false); } } // Apply placement: // TODO: add option to change the placement strategy. qcor::internal::PassManager::applyPlacement(::quantum::program); } Loading Loading
runtime/qrt/pass_manager.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include "InstructionIterator.hpp" #include "xacc.hpp" #include "xacc_service.hpp" #include "xacc_internal_compiler.hpp" #include <iomanip> #include <numeric> namespace { Loading Loading @@ -91,6 +92,23 @@ std::vector<PassStat> PassManager::optimize( return passData; } void PassManager::applyPlacement(std::shared_ptr<xacc::CompositeInstruction> program, const std::string &placementName) { if (!xacc::hasService<xacc::IRTransformation>(placementName) && !xacc::hasContributedService<xacc::IRTransformation>(placementName)) { // Graciously ignores services which cannot be located. return; } auto irt = xacc::getIRTransformation(placementName); if (irt->type() == xacc::IRTransformationType::Placement && xacc::internal_compiler::qpu && !xacc::internal_compiler::qpu->getConnectivity().empty()) { irt->apply(program, xacc::internal_compiler::qpu); } // DEBUG: std::cout << "HOWDY:\n" << program->toString() << "\n"; } std::unordered_map<std::string, int> PassStat::countGates( const std::shared_ptr<xacc::CompositeInstruction> &program) { std::unordered_map<std::string, int> gateCount; Loading
runtime/qrt/pass_manager.hpp +5 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,11 @@ public: PassManager(int level); // Static helper to run an optimization pass static PassStat runPass(const std::string &passName, std::shared_ptr<xacc::CompositeInstruction> program); // Default placement strategy static constexpr const char *DEFAULT_PLACEMENT = "swap-shortest-path"; // Apply placement static void applyPlacement(std::shared_ptr<xacc::CompositeInstruction> program, const std::string &placementName = DEFAULT_PLACEMENT); // Optimizes the input program. // Returns the full statistics about all the passes that have been executed. std::vector<PassStat> Loading
runtime/qrt/qrt.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,9 @@ void execute_pass_manager() { std::cout << passData.toString(false); } } // Apply placement: // TODO: add option to change the placement strategy. qcor::internal::PassManager::applyPlacement(::quantum::program); } Loading