Commit d0c35ef5 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Removed qalloc and xacc_internal_compiler from XACC



Not exporting the header and compiling these files: to be relocated to qcor.

There are a few unit tests which uses these headers. Will either relocate them to qcor or rewrite this (e.g. ControlledGateTester which doesn't really need qubit types, XASMCompilerTester only has one test for qcor, etc.)

Tested by: compiling xacc
Signed-off-by: Nguyen, Thien Minh's avatarThien Nguyen <nguyentm@ornl.gov>
parent 7b59700a
......@@ -2,7 +2,6 @@
#include "xacc.hpp"
#include "xacc_service.hpp"
#include "CommonGates.hpp"
#include "qalloc.hpp"
using namespace xacc;
using namespace xacc::quantum;
......@@ -152,58 +151,58 @@ TEST(ControlledGateTester, checkMultipleControl)
}
}
TEST(ControlledGateTester, checkMultipleControlQregs)
{
// Reference circuit (index-based)
const std::string ref_circuit_str = []() {
auto gateRegistry = xacc::getService<xacc::IRProvider>("quantum");
auto x = std::make_shared<X>(0);
std::shared_ptr<xacc::CompositeInstruction> comp =
gateRegistry->createComposite("__COMPOSITE__X");
comp->addInstruction(x);
auto ccx = std::dynamic_pointer_cast<CompositeInstruction>(
xacc::getService<Instruction>("C-U"));
const std::vector<int> ctrl_idxs{1, 2};
ccx->expand({{"U", comp}, {"control-idx", ctrl_idxs}});
return ccx->toString();
}();
// TEST(ControlledGateTester, checkMultipleControlQregs)
// {
// // Reference circuit (index-based)
// const std::string ref_circuit_str = []() {
// auto gateRegistry = xacc::getService<xacc::IRProvider>("quantum");
// auto x = std::make_shared<X>(0);
// std::shared_ptr<xacc::CompositeInstruction> comp =
// gateRegistry->createComposite("__COMPOSITE__X");
// comp->addInstruction(x);
// auto ccx = std::dynamic_pointer_cast<CompositeInstruction>(
// xacc::getService<Instruction>("C-U"));
// const std::vector<int> ctrl_idxs{1, 2};
// ccx->expand({{"U", comp}, {"control-idx", ctrl_idxs}});
// return ccx->toString();
// }();
// Circuit with different buffer names.
auto gateRegistry = xacc::getService<xacc::IRProvider>("quantum");
auto x = std::make_shared<X>(0);
x->setBufferNames({"target"});
std::shared_ptr<xacc::CompositeInstruction> comp =
gateRegistry->createComposite("__COMPOSITE__X");
comp->addInstruction(x);
auto ccx = std::dynamic_pointer_cast<CompositeInstruction>(
xacc::getService<Instruction>("C-U"));
// // Circuit with different buffer names.
// auto gateRegistry = xacc::getService<xacc::IRProvider>("quantum");
// auto x = std::make_shared<X>(0);
// x->setBufferNames({"target"});
// std::shared_ptr<xacc::CompositeInstruction> comp =
// gateRegistry->createComposite("__COMPOSITE__X");
// comp->addInstruction(x);
// auto ccx = std::dynamic_pointer_cast<CompositeInstruction>(
// xacc::getService<Instruction>("C-U"));
auto ctrlReg1 = ::qalloc(1);
auto ctrl1 = ctrlReg1[0];
ctrl1.first = "control1";
auto ctrlReg2 = ::qalloc(1);
auto ctrl2 = ctrlReg2[0];
ctrl2.first = "control2";
const std::vector<std::pair<std::string, size_t>> ctrl_qubits{
{ctrl1.first, ctrl1.second}, {ctrl2.first, ctrl2.second}};
// auto ctrlReg1 = ::qalloc(1);
// auto ctrl1 = ctrlReg1[0];
// ctrl1.first = "control1";
// auto ctrlReg2 = ::qalloc(1);
// auto ctrl2 = ctrlReg2[0];
// ctrl2.first = "control2";
// const std::vector<std::pair<std::string, size_t>> ctrl_qubits{
// {ctrl1.first, ctrl1.second}, {ctrl2.first, ctrl2.second}};
ccx->expand({{"U", comp}, {"control-idx", ctrl_qubits}});
auto new_circ_str = ccx->toString();
const auto replaceAll = [](const std::string &t, const std::string &s,
std::string &str) {
std::string::size_type n = 0;
while ((n = str.find(s, n)) != std::string::npos) {
str.replace(n, s.size(), t);
n += t.size();
}
};
// ccx->expand({{"U", comp}, {"control-idx", ctrl_qubits}});
// auto new_circ_str = ccx->toString();
// const auto replaceAll = [](const std::string &t, const std::string &s,
// std::string &str) {
// std::string::size_type n = 0;
// while ((n = str.find(s, n)) != std::string::npos) {
// str.replace(n, s.size(), t);
// n += t.size();
// }
// };
replaceAll("q0", "target0", new_circ_str);
replaceAll("q1", "control10", new_circ_str);
replaceAll("q2", "control20", new_circ_str);
std::cout << "HOWDY:\n" << new_circ_str << "\n";
EXPECT_EQ(ref_circuit_str, new_circ_str);
}
// replaceAll("q0", "target0", new_circ_str);
// replaceAll("q1", "control10", new_circ_str);
// replaceAll("q2", "control20", new_circ_str);
// std::cout << "HOWDY:\n" << new_circ_str << "\n";
// EXPECT_EQ(ref_circuit_str, new_circ_str);
// }
TEST(ControlledGateTester, checkControlSwap)
{
......
......@@ -14,8 +14,8 @@ include_directories(${CMAKE_SOURCE_DIR}/quantum/plugins/rigetti)
#add_xacc_test(QVMAccelerator)
#target_link_libraries(QVMAcceleratorTester xacc-quantum-gate CppMicroServices)
add_xacc_test(QuilCompiler)
target_link_libraries(QuilCompilerTester xacc-quantum-gate CppMicroServices)
# add_xacc_test(QuilCompiler)
# target_link_libraries(QuilCompilerTester xacc-quantum-gate CppMicroServices)
add_xacc_test(QuilVisitor)
target_link_libraries(QuilVisitorTester xacc-quantum-gate)
......@@ -10,6 +10,6 @@
# Contributors:
# Alexander J. McCaskey - initial API and implementation
# *******************************************************************************/
include_directories(${CMAKE_SOURCE_DIR}/tools/compiler)
add_xacc_test(XASMCompiler)
target_link_libraries(XASMCompilerTester xacc CppMicroServices xacc-quantum-gate)
\ No newline at end of file
# include_directories(${CMAKE_SOURCE_DIR}/tools/compiler)
# add_xacc_test(XASMCompiler)
# target_link_libraries(XASMCompilerTester xacc CppMicroServices xacc-quantum-gate)
\ No newline at end of file
......@@ -28,8 +28,7 @@ file(GLOB
HEADERS
xacc.hpp
ir/*.hpp
compiler/*.hpp
compiler/qalloc
compiler/Compiler.hpp
accelerator/*.hpp
accelerator/remote/*.hpp
utils/*.hpp
......@@ -42,8 +41,6 @@ add_library(xacc SHARED
accelerator/AcceleratorBuffer.cpp
utils/Utils.cpp
utils/CLIParser.cpp
compiler/xacc_internal_compiler.cpp
compiler/qalloc.cpp
service/ServiceRegistry.cpp
service/xacc_service.cpp
accelerator/remote/RemoteAccelerator.cpp)
......
......@@ -18,13 +18,13 @@ add_xacc_test(Algorithm xacc)
add_xacc_test(Heterogeneous xacc)
target_compile_features(HeterogeneousTester PRIVATE cxx_std_14)
configure_file(InternalCompilerTester.in.cpp
${CMAKE_BINARY_DIR}/xacc/tests/InternalCompilerTester.cpp)
# configure_file(InternalCompilerTester.in.cpp
# ${CMAKE_BINARY_DIR}/xacc/tests/InternalCompilerTester.cpp)
add_executable(InternalCompilerTester ${CMAKE_BINARY_DIR}/xacc/tests/InternalCompilerTester.cpp)
target_include_directories(InternalCompilerTester PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(InternalCompilerTester PRIVATE xacc ${GTEST_LIBRARIES})
add_test(NAME xacc_InternalCompilerTester COMMAND InternalCompilerTester)
target_compile_features(InternalCompilerTester PRIVATE cxx_std_14)
# add_executable(InternalCompilerTester ${CMAKE_BINARY_DIR}/xacc/tests/InternalCompilerTester.cpp)
# target_include_directories(InternalCompilerTester PRIVATE ${GTEST_INCLUDE_DIRS})
# target_link_libraries(InternalCompilerTester PRIVATE xacc ${GTEST_LIBRARIES})
# add_test(NAME xacc_InternalCompilerTester COMMAND InternalCompilerTester)
# target_compile_features(InternalCompilerTester PRIVATE cxx_std_14)
#add_xacc_test(InternalCompiler xacc)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment