2 Shows the performance difference in optimised versus non optimised NCU operations. 4 mpirun -n 8 python ./ncu_opt_tester.py <num ctrl lines> <operating mode: {0,1}> 6 mpirun -n 8 python ./ncu_opt_tester.py 11 0 # Should be realtively fast 7 mpirun -n 8 python ./ncu_opt_tester.py 11 1 # Should take a while 11 from PyQNLPSimulator
import PyQNLPSimulator
as p
13 from mpi4py
import MPI
16 rank = comm.Get_rank()
18 num_ctrl = int(sys.argv[1])
19 num_qubits = num_ctrl*2 - 1
23 sim = p(num_qubits,
False)
24 regD = range(num_ctrl)
25 regA = range(num_ctrl, target)
31 print(
"Applying gateX to {}".format(i))
34 res0 = sim.applyMeasurementToRegister([target],
True)
36 if sys.argv[2] ==
"1":
37 sim.applyGateNCU(sim.getGateX(), regD, target ,
"X")
39 sim.applyGateNCU(sim.getGateX(), regD, regA, target ,
"X")
41 res1 = sim.applyMeasurementToRegister([target],
True)
44 print(list(regD) + [target], list(regA),
"Before NCU={}".format(res0),
"After NCU={}".format(res1))