Commit 39576a52 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

minor cleanup, setup circuit benchmark to run without accelerator execution.

parent b6171f6c
Loading
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,12 @@ int main() {
  auto q = qalloc(1);

  // Run the kernel
  testKernel(q);
  {
    class testKernel t(q);
    t.optimize_only = true;
    // kernel executed upon destruction, 
    // will only build up circuit and run pass manager
  }
  std::cout << "NInsts: " << quantum::program->nInstructions() << "\n";
}
#endif
 No newline at end of file
+5 −5
Original line number Diff line number Diff line
@@ -15,11 +15,11 @@ __qpu__ void ccnot(qreg q) {
  // algorithm name and an optimizer. 
  decompose {
    // Create the unitary matrix
    UnitaryMatrix ccnot = UnitaryMatrix::Identity(8, 8);
    ccnot(6, 6) = 0.0;
    ccnot(7, 7) = 0.0;
    ccnot(6, 7) = 1.0;
    ccnot(7, 6) = 1.0;
    UnitaryMatrix ccnot_mat = UnitaryMatrix::Identity(8, 8);
    ccnot_mat(6, 6) = 0.0;
    ccnot_mat(7, 7) = 0.0;
    ccnot_mat(6, 7) = 1.0;
    ccnot_mat(7, 6) = 1.0;
  }
  (q);

+6 −0
Original line number Diff line number Diff line
@@ -206,6 +206,12 @@ public:
      OS << ", " << program_parameters[i];
    }
    OS << ");\n";

    OS << "if (optimize_only) {\n";
    OS << "xacc::internal_compiler::execute_pass_manager();\n";
    OS << "return;\n";
    OS << "}\n";

    OS << "if (is_callable) {\n";
    if (bufferNames.size() > 1) {
      OS << "xacc::AcceleratorBuffer * buffers[" << bufferNames.size()
+6 −1
Original line number Diff line number Diff line
@@ -47,6 +47,11 @@ protected:
  bool disable_destructor = false;
  
public:

  // Flag to indicate we only want to 
  // run the pass manager and not execute
  bool optimize_only = false;

  // Default constructor, takes quantum kernel function arguments
  QuantumKernel(Args... args) : args_tuple(std::forward_as_tuple(args...)) {}

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ std::vector<PassStat> PassManager::optimize(
    stat.gateCountBefore = PassStat::countGates(program);
    xacc::ScopeTimer timer(passName, false);
    auto xaccOptTransform =
        xacc::getService<xacc::IRTransformation>(passName, false);
        xacc::getIRTransformation(passName);
    // Graciously ignores passes which cannot be located.
    if (xaccOptTransform) {
      xaccOptTransform->apply(program, nullptr);
Loading