Commit 972c897e authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

adding awesome mixed language example, hooking up set_shots to quantum...


adding awesome mixed language example, hooking up set_shots to quantum runtime, works with new heterogeneous map

Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent ac1b56c9
Loading
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
#include <qalloc>

// Define a multi-register kernel
__qpu__ void bell_multi(qreg q, qreg r) {
  using qcor::xasm;
  H(q[0]);
  CX(q[0], q[1]);

  using qcor::openqasm;

  h r[0];
  cx r[0], r[1];

  using qcor::xasm;
  
  for (int i = 0; i < q.size(); i++) {
    Measure(q[i]);
    Measure(r[i]);
  }
}

int main() {

  // Create two qubit registers, each size 2
  auto q = qalloc(2);
  auto r = qalloc(2);

  // Run the quantum kernel
  bell_multi(q, r);

  // dump the results
  q.print();
  r.print();
}
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -77,8 +77,7 @@ public:
          bufferNames.push_back(ident->getName().str());
          function_prototype += "qreg " + ident->getName().str() + ", ";
        } else {
          function_prototype +=
              type + " " + ident->getName().str() + ", ";
          function_prototype += type + " " + ident->getName().str() + ", ";
        }
      }
    }
@@ -92,7 +91,8 @@ public:
    if (qrt) {

      qcor::run_token_collector_llvm_rt(PP, Toks, function_prototype,
                                        bufferNames, kernel_name, OS, qpu_name);
                                        bufferNames, kernel_name, OS, qpu_name,
                                        shots);

    } else {
      auto kernel_src_and_compiler =
+4 −1
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@ void initialize(const std::string qpu_name, const std::string kernel_name) {
  program = provider->createComposite(kernel_name);
}

void set_shots(int shots) {}
void set_shots(int shots) {
  xacc::internal_compiler::get_qpu()->updateConfiguration(
      {std::make_pair("shots", shots)});
}

void one_qubit_inst(const std::string &name, const qubit &qidx,
                    std::vector<double> parameters) {