Commit 83136afb authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

update tests for compiling and executing capture vars in compute context

parent 1ab11d61
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@ add_qcor_compile_and_exe_test(qrt_qpe_example qpe/qpe_example_qrt.cpp)
add_qcor_compile_and_exe_test(qrt_kernel_include simple/multiple_kernels.cpp)
add_qcor_compile_and_exe_test(qrt_grover grover/grover.cpp)
add_qcor_compile_and_exe_test(qrt_adapt hybrid/adapt_h2.cpp)
#add_qcor_compile_and_exe_test(compute_action_uncompute0 compute_action_uncompute/compute_action_uncompute_h2_ucc1_example.cpp)
#add_qcor_compile_and_exe_test(compute_action_uncompute1 compute_action_uncompute/multiple_in_kernel.cpp)
#add_qcor_compile_and_exe_test(compute_action_uncompute2 compute_action_uncompute/cau_capture_vars.cpp)
add_qcor_compile_and_exe_test(compute_action_uncompute0 compute_action_uncompute/compute_action_uncompute_h2_ucc1_example.cpp)
add_qcor_compile_and_exe_test(compute_action_uncompute1 compute_action_uncompute/multiple_in_kernel.cpp)
add_qcor_compile_and_exe_test(compute_action_uncompute2 compute_action_uncompute/cau_capture_vars.cpp)

add_qcor_ftqc_compile_and_exe_test(qrt_ftqc_simple ftqc_qrt/simple-demo.cpp)
add_qcor_ftqc_compile_and_exe_test(qrt_ftqc_rus ftqc_qrt/repeat-until-success.cpp)
+3 −5
Original line number Diff line number Diff line
__qpu__ void test(qreg q, double x, int& j) {
__qpu__ void test(qreg q, double x) {
  std::vector<int> b{10, 20, 30};

  int j = 10;
  compute {
    int i = j;
    std::vector<int> bits = b;
@@ -16,7 +16,5 @@ __qpu__ void test(qreg q, double x, int& j) {

int main() {
  auto q = qalloc(2);
  int n = 10;
  test::print_kernel(q, 2.2, n);
  print(n);
  test::print_kernel(q, 2.2);
}
+18 −0
Original line number Diff line number Diff line
@@ -76,6 +76,24 @@ class TestKernelJIT(unittest.TestCase):
    self.assertEqual(comp3.getInstruction(middle_inst_idx).name(), 'CRZ')
    self.assertEqual(comp3.nInstructions(), comp0.nInstructions()) 

  def test_capture_vars(self):
    @qjit
    def test_compute_action11(q : qreg, x : float):
      i = 10
      with compute:
        # control of x gate
        j = i
        print(j)
        X.ctrl(q[0], q[1])
        for i in range(3):
            H(q[i+1])
      with action:
        Rz(q[3], x)
      
      q = qalloc(2)
      test_compute_action11(q, 2.2)
      

  def test_multi_control(self):
    @qjit
    def x_gate_standalone_m(q: qubit):