Loading handlers/token_collector/staq/staq_token_collector.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -53,7 +53,8 @@ static const std::map<std::string, std::string> gates{ {"z", "Z"}, {"h", "H"}, {"s", "S"}, {"sdg", "Sdg"}, {"t", "T"}, {"tdg", "Tdg"}, {"rx", "Rx"}, {"ry", "Ry"}, {"rz", "Rz"}, {"cz", "CZ"}, {"cy", "CY"}, {"swap", "Swap"}, {"ccx", "CCX"}, {"ch", "CH"}, {"crz", "CRZ"}, {"measure", "Measure"}}; {"ccx", "CCX"}, {"ch", "CH"}, {"crz", "CRZ"}, {"measure", "Measure"}, {"reset", "Reset"}}; void StaqTokenCollector::collect(clang::Preprocessor &PP, clang::CachedTokens &Toks, Loading handlers/token_collector/staq/tests/StaqTokenCollectorTester.in.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,31 @@ quantum::mz(c[3]); ss.str()); } TEST(StaqTokenCollectorTester, checkReset) { LexerHelper helper; auto [tokens, PP] = helper.Lex(R"#( creg c[1]; h q[0]; reset q[0]; reset q[1]; x q[0]; measure q[0] -> c[0];)#"); clang::CachedTokens cached; for (auto &t : tokens) { cached.push_back(t); } std::stringstream ss; auto xasm_tc = xacc::getService<qcor::TokenCollector>("staq"); xasm_tc->collect(*PP.get(), cached, {"q"}, ss); std::cout << "heres the test\n"; std::cout << ss.str() << "\n"; EXPECT_TRUE(ss.str().find("quantum::reset(q[0]);") != std::string::npos); EXPECT_TRUE(ss.str().find("quantum::reset(q[1]);") != std::string::npos); } int main(int argc, char **argv) { std::string xacc_config_install_dir = std::string(XACC_INSTALL_DIR); std::string qcor_root = std::string(QCOR_INSTALL_DIR); Loading handlers/token_collector/xasm/tests/XASMTokenCollectorTester.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,24 @@ beta_counter ++ ; ss.str()); } TEST(XASMTokenCollectorTester, checkReset) { LexerHelper helper; auto [tokens, PP] = helper.Lex("H(q[0]);\nReset(q[0]);\nRy(q[3], theta);"); clang::CachedTokens cached; for (auto &t : tokens) { cached.push_back(t); } std::stringstream ss; auto xasm_tc = xacc::getService<qcor::TokenCollector>("xasm"); xasm_tc->collect(*PP.get(), cached, {"q"}, ss); std::cout << "heres the test\n"; std::cout << ss.str() << "\n"; EXPECT_TRUE(ss.str().find("quantum::reset(q[0]);") != std::string::npos); } int main(int argc, char **argv) { std::string xacc_config_install_dir = std::string(XACC_INSTALL_DIR); std::string qcor_root = std::string(QCOR_INSTALL_DIR); Loading runtime/qrt/impls/ftqc/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ else() endif() if (QCOR_BUILD_TESTS) #add_subdirectory(tests) add_subdirectory(tests) endif() install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins) runtime/qrt/impls/ftqc/ftqc_qrt.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,10 @@ public: applyGate("U", {qidx.second}, {theta, phi, lambda}); } virtual void reset(const qubit &qidx) override { applyGate("Reset", {qidx.second}); } // Measure-Z virtual bool mz(const qubit &qidx) override { applyGate("Measure", {qidx.second}); Loading Loading
handlers/token_collector/staq/staq_token_collector.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -53,7 +53,8 @@ static const std::map<std::string, std::string> gates{ {"z", "Z"}, {"h", "H"}, {"s", "S"}, {"sdg", "Sdg"}, {"t", "T"}, {"tdg", "Tdg"}, {"rx", "Rx"}, {"ry", "Ry"}, {"rz", "Rz"}, {"cz", "CZ"}, {"cy", "CY"}, {"swap", "Swap"}, {"ccx", "CCX"}, {"ch", "CH"}, {"crz", "CRZ"}, {"measure", "Measure"}}; {"ccx", "CCX"}, {"ch", "CH"}, {"crz", "CRZ"}, {"measure", "Measure"}, {"reset", "Reset"}}; void StaqTokenCollector::collect(clang::Preprocessor &PP, clang::CachedTokens &Toks, Loading
handlers/token_collector/staq/tests/StaqTokenCollectorTester.in.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,31 @@ quantum::mz(c[3]); ss.str()); } TEST(StaqTokenCollectorTester, checkReset) { LexerHelper helper; auto [tokens, PP] = helper.Lex(R"#( creg c[1]; h q[0]; reset q[0]; reset q[1]; x q[0]; measure q[0] -> c[0];)#"); clang::CachedTokens cached; for (auto &t : tokens) { cached.push_back(t); } std::stringstream ss; auto xasm_tc = xacc::getService<qcor::TokenCollector>("staq"); xasm_tc->collect(*PP.get(), cached, {"q"}, ss); std::cout << "heres the test\n"; std::cout << ss.str() << "\n"; EXPECT_TRUE(ss.str().find("quantum::reset(q[0]);") != std::string::npos); EXPECT_TRUE(ss.str().find("quantum::reset(q[1]);") != std::string::npos); } int main(int argc, char **argv) { std::string xacc_config_install_dir = std::string(XACC_INSTALL_DIR); std::string qcor_root = std::string(QCOR_INSTALL_DIR); Loading
handlers/token_collector/xasm/tests/XASMTokenCollectorTester.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,24 @@ beta_counter ++ ; ss.str()); } TEST(XASMTokenCollectorTester, checkReset) { LexerHelper helper; auto [tokens, PP] = helper.Lex("H(q[0]);\nReset(q[0]);\nRy(q[3], theta);"); clang::CachedTokens cached; for (auto &t : tokens) { cached.push_back(t); } std::stringstream ss; auto xasm_tc = xacc::getService<qcor::TokenCollector>("xasm"); xasm_tc->collect(*PP.get(), cached, {"q"}, ss); std::cout << "heres the test\n"; std::cout << ss.str() << "\n"; EXPECT_TRUE(ss.str().find("quantum::reset(q[0]);") != std::string::npos); } int main(int argc, char **argv) { std::string xacc_config_install_dir = std::string(XACC_INSTALL_DIR); std::string qcor_root = std::string(QCOR_INSTALL_DIR); Loading
runtime/qrt/impls/ftqc/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ else() endif() if (QCOR_BUILD_TESTS) #add_subdirectory(tests) add_subdirectory(tests) endif() install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins)
runtime/qrt/impls/ftqc/ftqc_qrt.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,10 @@ public: applyGate("U", {qidx.second}, {theta, phi, lambda}); } virtual void reset(const qubit &qidx) override { applyGate("Reset", {qidx.second}); } // Measure-Z virtual bool mz(const qubit &qidx) override { applyGate("Measure", {qidx.second}); Loading