Commit b6171f6c authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

minor cleanup, adding ability to set optimizer for qfast decompose

parent 8f7b3a62
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
from xacc/ubuntu:18.04

run apt-get update && apt-get install -y ninja-build \
    && git clone https://github.com/hfinkel/llvm-project-csp llvm \
    && git clone https://github.com/ornl-qci/llvm-project-csp llvm \
    && cd llvm && mkdir build && cd build \
    && cmake -G Ninja ../llvm -DCMAKE_INSTALL_PREFIX=$HOME/.llvm -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS=clang \
    && cmake --build . --target install \
+1 −1
Original line number Diff line number Diff line
from qcor/qcor-base
from qcor/deploy-base
run git clone --recursive https://github.com/eclipse/xacc && cd xacc && mkdir build && cd build \
    && cmake .. \
    && make -j$(nproc) install 
+4 −2
Original line number Diff line number Diff line
@@ -10,7 +10,9 @@ __qpu__ void ccnot(qreg q) {
  }

  // To program at the unitary matrix level,
  // simply indicate you are using qcor::unitary namespace
  // invoke the decompose call, indicating which 
  // buffer to target, can optionally provide decomposition 
  // algorithm name and an optimizer. 
  decompose {
    // Create the unitary matrix
    UnitaryMatrix ccnot = UnitaryMatrix::Identity(8, 8);
@@ -19,7 +21,7 @@ __qpu__ void ccnot(qreg q) {
    ccnot(6, 7) = 1.0;
    ccnot(7, 6) = 1.0;
  }
  (q, QFAST);
  (q);

  // Add some measures
  for (int i = 0; i < q.size(); i++) {
+8 −2
Original line number Diff line number Diff line
@@ -119,9 +119,15 @@ std::string run_token_collector(clang::Preprocessor &PP,
        i++;
      }

      if (arguments.size() < 1) {
      if (arguments.size() == 0) {
          xacc::error("Invalid decompose arguments, must at least provide the qreg variable");
      }
      
      if (arguments.size() == 1) {
          arguments.push_back("QFAST");
      }

      
      std::map<int, std::function<void(const std::string arg)>> arg_to_action{
          {0,
           [&](const std::string arg) {
+11 −3
Original line number Diff line number Diff line
@@ -83,10 +83,18 @@ void UnitaryTokenCollector::collect(clang::Preprocessor &PP,
  }
  ss << "\n";

  // Add the qfast decomp and hook up to the qrt program.
  const auto optimizer_provided =
      ss.str().find("decompose_optimizer = ") != std::string::npos;
  if (optimizer_provided) {
    ss << "auto decomposed_program = "
          "__internal__::decompose_unitary(decompose_algo_name, "
       << var_name << ", decompose_buffer_name, decompose_optimizer);\n";
  } else {
    ss << "auto decomposed_program = "
          "__internal__::decompose_unitary(decompose_algo_name, "
       << var_name << ", decompose_buffer_name);\n";
  }
  // Add the qfast decomp and hook up to the qrt program.

  ss << "parent_kernel->addInstruction(decomposed_program);\n";
}
Loading