From 77434dec79a818740351f48872d95733759bff45 Mon Sep 17 00:00:00 2001 From: hopery Date: Wed, 23 Mar 2022 20:52:21 +0200 Subject: [PATCH 1/8] Add rOEE algorithm for mapping --- .gitignore | 4 + examples/cpp-standalone-example/example.cc | 1207 ++++++++++++++++- .../test_multi_core_4x4_full.json | 279 ++++ src/ql/com/topology.cc | 14 +- src/ql/pass/map/qubits/map/detail/future.cc | 12 +- src/ql/pass/map/qubits/map/detail/future.h | 6 + src/ql/pass/map/qubits/map/detail/mapper.cc | 283 +++- src/ql/pass/map/qubits/map/detail/mapper.h | 17 + 8 files changed, 1782 insertions(+), 40 deletions(-) create mode 100644 examples/cpp-standalone-example/test_multi_core_4x4_full.json diff --git a/.gitignore b/.gitignore index 11756b408..640c508dd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ openql.egg-info lab env .eggs/ +examples/cpp-standalone-example/testb_build # Temp files *.dot @@ -38,3 +39,6 @@ docs/_templates /.idea /cmake-build-* +qiskit-vscode-log.test_output +qiskit-vscode-log.out +.vscode/settings.json diff --git a/examples/cpp-standalone-example/example.cc b/examples/cpp-standalone-example/example.cc index b8113e195..ed7c2599d 100644 --- a/examples/cpp-standalone-example/example.cc +++ b/examples/cpp-standalone-example/example.cc @@ -1,29 +1,1202 @@ -#include #include -int main(int argc, char **argv) { - // create platform - auto platf = ql::Platform("seven_qubits_chip", "cc_light"); - - // create program - auto prog = ql::Program("aProgram", platf, 2); +void test_mc(std::string v, std::string param1, std::string param2, std::string param3, std::string param4) { + int n = 32; + // std::string prog_name = "test_" + v + "_maplookahead=" + param1 + "_maprecNN2q=" + param2 + "_mapselectmaxlevel=" + param3 + "_mapselectmaxwidth=" + param4; + std::string prog_name = "test_" + v; + // std::string kernel_name = "test_" + v + "_maplookahead=" + param1 + "_maprecNN2q=" + param2 + "_mapselectmaxlevel=" + param3 + "_mapselectmaxwidth=" + param4; + std::string kernel_name = "test_" + v; + std::vector sweep_points = { 1 }; - // create kernel - auto k = ql::Kernel("aKernel", platf, 2); + auto starmon = ql::Platform("mc4x4full", "test_multi_core_4x4_full.json"); + //ql::set_platform(starmon); + auto prog = ql::Program(prog_name, starmon, n, 0); + auto k = ql::Kernel(kernel_name, starmon, n, 0); + prog.set_sweep_points(sweep_points); - k.gate("prepz", 0); - k.gate("prepz", 1); + int i, j; + k.gate("x", 16); + k.gate("x", 0); + k.gate("ym90", 0); + k.gate("x", 1); + k.gate("ym90", 1); + k.gate("x", 2); + k.gate("ym90", 2); + k.gate("x", 3); + k.gate("ym90", 3); + k.gate("x", 4); + k.gate("ym90", 4); + k.gate("x", 5); + k.gate("ym90", 5); + k.gate("x", 6); + k.gate("ym90", 6); + k.gate("x", 7); + k.gate("ym90", 7); + k.gate("x", 8); + k.gate("ym90", 8); + k.gate("x", 9); + k.gate("ym90", 9); + k.gate("x", 10); + k.gate("ym90", 10); + k.gate("x", 11); + k.gate("ym90", 11); + k.gate("x", 12); + k.gate("ym90", 12); + k.gate("x", 13); + k.gate("ym90", 13); + k.gate("x", 14); + k.gate("ym90", 14); + k.gate("x", 15); + k.gate("ym90", 15); + k.gate("x", 16); + k.gate("ym90", 16); + k.gate("x", 0); + k.gate("x", 1); + k.gate("x", 2); + k.gate("x", 3); + k.gate("x", 4); + k.gate("x", 5); + k.gate("x", 6); + k.gate("x", 7); + k.gate("x", 8); + k.gate("x", 9); + k.gate("x", 10); + k.gate("x", 11); + k.gate("x", 12); + k.gate("x", 13); + k.gate("x", 14); + k.gate("x", 15); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 1); + k.gate("t", 17); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 0, 1); + k.gate("tdag", 1); + k.gate("t", 0); + k.gate("cnot", 0, 1); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 17); + k.gate("t", 18); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 2, 17); + k.gate("tdag", 17); + k.gate("t", 2); + k.gate("cnot", 2, 17); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 18); + k.gate("t", 19); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 3, 18); + k.gate("tdag", 18); + k.gate("t", 3); + k.gate("cnot", 3, 18); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 19); + k.gate("t", 20); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 4, 19); + k.gate("tdag", 19); + k.gate("t", 4); + k.gate("cnot", 4, 19); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 20); + k.gate("t", 21); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 5, 20); + k.gate("tdag", 20); + k.gate("t", 5); + k.gate("cnot", 5, 20); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 21); + k.gate("t", 22); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 6, 21); + k.gate("tdag", 21); + k.gate("t", 6); + k.gate("cnot", 6, 21); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 22); + k.gate("t", 23); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 7, 22); + k.gate("tdag", 22); + k.gate("t", 7); + k.gate("cnot", 7, 22); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 23); + k.gate("t", 24); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 8, 23); + k.gate("tdag", 23); + k.gate("t", 8); + k.gate("cnot", 8, 23); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 24); + k.gate("t", 25); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 9, 24); + k.gate("tdag", 24); + k.gate("t", 9); + k.gate("cnot", 9, 24); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 25); + k.gate("t", 26); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 10, 25); + k.gate("tdag", 25); + k.gate("t", 10); + k.gate("cnot", 10, 25); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 26); + k.gate("t", 27); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 11, 26); + k.gate("tdag", 26); + k.gate("t", 11); + k.gate("cnot", 11, 26); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 27); + k.gate("t", 28); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 12, 27); + k.gate("tdag", 27); + k.gate("t", 12); + k.gate("cnot", 12, 27); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 28); + k.gate("t", 29); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 13, 28); + k.gate("tdag", 28); + k.gate("t", 13); + k.gate("cnot", 13, 28); + k.gate("x", 30); + k.gate("ym90", 30); + k.gate("cnot", 29, 30); + k.gate("tdag", 30); + k.gate("cnot", 14, 30); + k.gate("t", 30); + k.gate("cnot", 29, 30); + k.gate("tdag", 30); + k.gate("cnot", 14, 30); + k.gate("t", 29); + k.gate("t", 30); + k.gate("x", 30); + k.gate("ym90", 30); + k.gate("cnot", 14, 29); + k.gate("tdag", 29); + k.gate("t", 14); + k.gate("cnot", 14, 29); + k.gate("x", 16); + k.gate("ym90", 16); + k.gate("cnot", 15, 16); + k.gate("tdag", 16); + k.gate("cnot", 30, 16); + k.gate("t", 16); + k.gate("cnot", 15, 16); + k.gate("tdag", 16); + k.gate("cnot", 30, 16); + k.gate("t", 15); + k.gate("t", 16); + k.gate("x", 16); + k.gate("ym90", 16); + k.gate("cnot", 30, 15); + k.gate("tdag", 15); + k.gate("t", 30); + k.gate("cnot", 30, 15); + k.gate("x", 30); + k.gate("ym90", 30); + k.gate("cnot", 29, 30); + k.gate("tdag", 30); + k.gate("cnot", 14, 30); + k.gate("t", 30); + k.gate("cnot", 29, 30); + k.gate("tdag", 30); + k.gate("cnot", 14, 30); + k.gate("t", 29); + k.gate("t", 30); + k.gate("x", 30); + k.gate("ym90", 30); + k.gate("cnot", 14, 29); + k.gate("tdag", 29); + k.gate("t", 14); + k.gate("cnot", 14, 29); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 28); + k.gate("t", 29); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 13, 28); + k.gate("tdag", 28); + k.gate("t", 13); + k.gate("cnot", 13, 28); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 27); + k.gate("t", 28); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 12, 27); + k.gate("tdag", 27); + k.gate("t", 12); + k.gate("cnot", 12, 27); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 26); + k.gate("t", 27); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 11, 26); + k.gate("tdag", 26); + k.gate("t", 11); + k.gate("cnot", 11, 26); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 25); + k.gate("t", 26); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 10, 25); + k.gate("tdag", 25); + k.gate("t", 10); + k.gate("cnot", 10, 25); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 24); + k.gate("t", 25); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 9, 24); + k.gate("tdag", 24); + k.gate("t", 9); + k.gate("cnot", 9, 24); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 23); + k.gate("t", 24); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 8, 23); + k.gate("tdag", 23); + k.gate("t", 8); + k.gate("cnot", 8, 23); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 22); + k.gate("t", 23); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 7, 22); + k.gate("tdag", 22); + k.gate("t", 7); + k.gate("cnot", 7, 22); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 21); + k.gate("t", 22); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 6, 21); + k.gate("tdag", 21); + k.gate("t", 6); + k.gate("cnot", 6, 21); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 20); + k.gate("t", 21); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 5, 20); + k.gate("tdag", 20); + k.gate("t", 5); + k.gate("cnot", 5, 20); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 19); + k.gate("t", 20); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 4, 19); + k.gate("tdag", 19); + k.gate("t", 4); + k.gate("cnot", 4, 19); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 18); + k.gate("t", 19); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 3, 18); + k.gate("tdag", 18); + k.gate("t", 3); + k.gate("cnot", 3, 18); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 17); + k.gate("t", 18); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 2, 17); + k.gate("tdag", 17); + k.gate("t", 2); + k.gate("cnot", 2, 17); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 1); + k.gate("t", 17); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 0, 1); + k.gate("tdag", 1); + k.gate("t", 0); + k.gate("cnot", 0, 1); + k.gate("x", 0); + k.gate("x", 1); + k.gate("x", 2); + k.gate("x", 3); + k.gate("x", 4); + k.gate("x", 5); + k.gate("x", 6); + k.gate("x", 7); + k.gate("x", 8); + k.gate("x", 9); + k.gate("x", 10); + k.gate("x", 11); + k.gate("x", 12); + k.gate("x", 13); + k.gate("x", 14); + k.gate("x", 15); k.gate("x", 0); - k.gate("y", 1); - k.measure(0); - k.measure(1); + k.gate("ym90", 0); + k.gate("x", 1); + k.gate("ym90", 1); + k.gate("x", 2); + k.gate("ym90", 2); + k.gate("x", 3); + k.gate("ym90", 3); + k.gate("x", 4); + k.gate("ym90", 4); + k.gate("x", 5); + k.gate("ym90", 5); + k.gate("x", 6); + k.gate("ym90", 6); + k.gate("x", 7); + k.gate("ym90", 7); + k.gate("x", 8); + k.gate("ym90", 8); + k.gate("x", 9); + k.gate("ym90", 9); + k.gate("x", 10); + k.gate("ym90", 10); + k.gate("x", 11); + k.gate("ym90", 11); + k.gate("x", 12); + k.gate("ym90", 12); + k.gate("x", 13); + k.gate("ym90", 13); + k.gate("x", 14); + k.gate("ym90", 14); + k.gate("x", 15); + k.gate("ym90", 15); + k.gate("x", 0); + k.gate("x", 1); + k.gate("x", 2); + k.gate("x", 3); + k.gate("x", 4); + k.gate("x", 5); + k.gate("x", 6); + k.gate("x", 7); + k.gate("x", 8); + k.gate("x", 9); + k.gate("x", 10); + k.gate("x", 11); + k.gate("x", 12); + k.gate("x", 13); + k.gate("x", 14); + k.gate("x", 15); + k.gate("x", 15); + k.gate("ym90", 15); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 1); + k.gate("t", 17); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 0, 1); + k.gate("tdag", 1); + k.gate("t", 0); + k.gate("cnot", 0, 1); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 17); + k.gate("t", 18); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 2, 17); + k.gate("tdag", 17); + k.gate("t", 2); + k.gate("cnot", 2, 17); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 18); + k.gate("t", 19); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 3, 18); + k.gate("tdag", 18); + k.gate("t", 3); + k.gate("cnot", 3, 18); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 19); + k.gate("t", 20); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 4, 19); + k.gate("tdag", 19); + k.gate("t", 4); + k.gate("cnot", 4, 19); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 20); + k.gate("t", 21); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 5, 20); + k.gate("tdag", 20); + k.gate("t", 5); + k.gate("cnot", 5, 20); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 21); + k.gate("t", 22); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 6, 21); + k.gate("tdag", 21); + k.gate("t", 6); + k.gate("cnot", 6, 21); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 22); + k.gate("t", 23); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 7, 22); + k.gate("tdag", 22); + k.gate("t", 7); + k.gate("cnot", 7, 22); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 23); + k.gate("t", 24); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 8, 23); + k.gate("tdag", 23); + k.gate("t", 8); + k.gate("cnot", 8, 23); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 24); + k.gate("t", 25); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 9, 24); + k.gate("tdag", 24); + k.gate("t", 9); + k.gate("cnot", 9, 24); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 25); + k.gate("t", 26); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 10, 25); + k.gate("tdag", 25); + k.gate("t", 10); + k.gate("cnot", 10, 25); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 26); + k.gate("t", 27); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 11, 26); + k.gate("tdag", 26); + k.gate("t", 11); + k.gate("cnot", 11, 26); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 27); + k.gate("t", 28); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 12, 27); + k.gate("tdag", 27); + k.gate("t", 12); + k.gate("cnot", 12, 27); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 28); + k.gate("t", 29); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 13, 28); + k.gate("tdag", 28); + k.gate("t", 13); + k.gate("cnot", 13, 28); + k.gate("x", 15); + k.gate("ym90", 15); + k.gate("cnot", 14, 15); + k.gate("tdag", 15); + k.gate("cnot", 29, 15); + k.gate("t", 15); + k.gate("cnot", 14, 15); + k.gate("tdag", 15); + k.gate("cnot", 29, 15); + k.gate("t", 14); + k.gate("t", 15); + k.gate("x", 15); + k.gate("ym90", 15); + k.gate("cnot", 29, 14); + k.gate("tdag", 14); + k.gate("t", 29); + k.gate("cnot", 29, 14); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 29); + k.gate("cnot", 28, 29); + k.gate("tdag", 29); + k.gate("cnot", 13, 29); + k.gate("t", 28); + k.gate("t", 29); + k.gate("x", 29); + k.gate("ym90", 29); + k.gate("cnot", 13, 28); + k.gate("tdag", 28); + k.gate("t", 13); + k.gate("cnot", 13, 28); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 28); + k.gate("cnot", 27, 28); + k.gate("tdag", 28); + k.gate("cnot", 12, 28); + k.gate("t", 27); + k.gate("t", 28); + k.gate("x", 28); + k.gate("ym90", 28); + k.gate("cnot", 12, 27); + k.gate("tdag", 27); + k.gate("t", 12); + k.gate("cnot", 12, 27); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 27); + k.gate("cnot", 26, 27); + k.gate("tdag", 27); + k.gate("cnot", 11, 27); + k.gate("t", 26); + k.gate("t", 27); + k.gate("x", 27); + k.gate("ym90", 27); + k.gate("cnot", 11, 26); + k.gate("tdag", 26); + k.gate("t", 11); + k.gate("cnot", 11, 26); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 26); + k.gate("cnot", 25, 26); + k.gate("tdag", 26); + k.gate("cnot", 10, 26); + k.gate("t", 25); + k.gate("t", 26); + k.gate("x", 26); + k.gate("ym90", 26); + k.gate("cnot", 10, 25); + k.gate("tdag", 25); + k.gate("t", 10); + k.gate("cnot", 10, 25); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 25); + k.gate("cnot", 24, 25); + k.gate("tdag", 25); + k.gate("cnot", 9, 25); + k.gate("t", 24); + k.gate("t", 25); + k.gate("x", 25); + k.gate("ym90", 25); + k.gate("cnot", 9, 24); + k.gate("tdag", 24); + k.gate("t", 9); + k.gate("cnot", 9, 24); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 24); + k.gate("cnot", 23, 24); + k.gate("tdag", 24); + k.gate("cnot", 8, 24); + k.gate("t", 23); + k.gate("t", 24); + k.gate("x", 24); + k.gate("ym90", 24); + k.gate("cnot", 8, 23); + k.gate("tdag", 23); + k.gate("t", 8); + k.gate("cnot", 8, 23); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 23); + k.gate("cnot", 22, 23); + k.gate("tdag", 23); + k.gate("cnot", 7, 23); + k.gate("t", 22); + k.gate("t", 23); + k.gate("x", 23); + k.gate("ym90", 23); + k.gate("cnot", 7, 22); + k.gate("tdag", 22); + k.gate("t", 7); + k.gate("cnot", 7, 22); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 22); + k.gate("cnot", 21, 22); + k.gate("tdag", 22); + k.gate("cnot", 6, 22); + k.gate("t", 21); + k.gate("t", 22); + k.gate("x", 22); + k.gate("ym90", 22); + k.gate("cnot", 6, 21); + k.gate("tdag", 21); + k.gate("t", 6); + k.gate("cnot", 6, 21); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 21); + k.gate("cnot", 20, 21); + k.gate("tdag", 21); + k.gate("cnot", 5, 21); + k.gate("t", 20); + k.gate("t", 21); + k.gate("x", 21); + k.gate("ym90", 21); + k.gate("cnot", 5, 20); + k.gate("tdag", 20); + k.gate("t", 5); + k.gate("cnot", 5, 20); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 20); + k.gate("cnot", 19, 20); + k.gate("tdag", 20); + k.gate("cnot", 4, 20); + k.gate("t", 19); + k.gate("t", 20); + k.gate("x", 20); + k.gate("ym90", 20); + k.gate("cnot", 4, 19); + k.gate("tdag", 19); + k.gate("t", 4); + k.gate("cnot", 4, 19); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 19); + k.gate("cnot", 18, 19); + k.gate("tdag", 19); + k.gate("cnot", 3, 19); + k.gate("t", 18); + k.gate("t", 19); + k.gate("x", 19); + k.gate("ym90", 19); + k.gate("cnot", 3, 18); + k.gate("tdag", 18); + k.gate("t", 3); + k.gate("cnot", 3, 18); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 18); + k.gate("cnot", 17, 18); + k.gate("tdag", 18); + k.gate("cnot", 2, 18); + k.gate("t", 17); + k.gate("t", 18); + k.gate("x", 18); + k.gate("ym90", 18); + k.gate("cnot", 2, 17); + k.gate("tdag", 17); + k.gate("t", 2); + k.gate("cnot", 2, 17); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 17); + k.gate("cnot", 1, 17); + k.gate("tdag", 17); + k.gate("cnot", 0, 17); + k.gate("t", 1); + k.gate("t", 17); + k.gate("x", 17); + k.gate("ym90", 17); + k.gate("cnot", 0, 1); + k.gate("tdag", 1); + k.gate("t", 0); + k.gate("cnot", 0, 1); + k.gate("x", 15); + k.gate("ym90", 15); + k.gate("x", 0); + k.gate("x", 1); + k.gate("x", 2); + k.gate("x", 3); + k.gate("x", 4); + k.gate("x", 5); + k.gate("x", 6); + k.gate("x", 7); + k.gate("x", 8); + k.gate("x", 9); + k.gate("x", 10); + k.gate("x", 11); + k.gate("x", 12); + k.gate("x", 13); + k.gate("x", 14); + k.gate("x", 15); + k.gate("x", 0); + k.gate("ym90", 0); + k.gate("x", 1); + k.gate("ym90", 1); + k.gate("x", 2); + k.gate("ym90", 2); + k.gate("x", 3); + k.gate("ym90", 3); + k.gate("x", 4); + k.gate("ym90", 4); + k.gate("x", 5); + k.gate("ym90", 5); + k.gate("x", 6); + k.gate("ym90", 6); + k.gate("x", 7); + k.gate("ym90", 7); + k.gate("x", 8); + k.gate("ym90", 8); + k.gate("x", 9); + k.gate("ym90", 9); + k.gate("x", 10); + k.gate("ym90", 10); + k.gate("x", 11); + k.gate("ym90", 11); + k.gate("x", 12); + k.gate("ym90", 12); + k.gate("x", 13); + k.gate("ym90", 13); + k.gate("x", 14); + k.gate("ym90", 14); + k.gate("x", 15); + k.gate("ym90", 15); - // add kernel to program + //for (i=0; i<4; i++) { + // k.gate("x", 4*i);;; + // k.gate("x", 4*i+1);;; + //} + //for (i=0; i<4; i++) { + // k.gate("cnot", 4*i, 4*i+1);;; + //} +// // for (i=0; i<4; i++) { + // for (j=0; j<4; j++) { + // if (i!=j) k.gate("cnot", 4*i, 4*j);;; + // } + // } + // k.gate("x", 4);;; prog.add_kernel(k); - // compile the program + // ql::set_option("maplookahead", param1); + // ql::set_option("maprecNN2q", param2); + // ql::set_option("mapselectmaxlevel", param3); + // ql::set_option("mapselectmaxwidth", param4); + prog.compile(); +} + + + +int main(int argc, char **argv) { + ql::utils::logger::set_log_level("LOG_DEBUG"); + // ql::utils::logger::set_log_level("LOG_NOTHING"); + ql::set_option("unique_output", "no"); + + ql::set_option("write_qasm_files", "yes"); + ql::set_option("write_report_files", "yes"); + // ql::set_option("print_dot_graphs", "yes"); + ql::set_option("use_default_gates", "no"); + ql::set_option("generate_code", "no"); + + ql::set_option("clifford_prescheduler", "no"); + ql::set_option("clifford_postscheduler", "no"); + + // ql::set_option("clifford_premapper", "yes"); + ql::set_option("mapper", "minextend"); + ql::set_option("mapinitone2one", "yes"); + ql::set_option("mapassumezeroinitstate", "yes"); +//parameter1 ql::set_option("maplookahead", "noroutingfirst"); + ql::set_option("mapselectswaps", "all"); + ql::set_option("initialplace", "no"); + ql::set_option("initialplace2qhorizon", "0"); + ql::set_option("mappathselect", "all"); + ql::set_option("mapusemoves", "yes"); + ql::set_option("mapreverseswap", "yes"); +//parameter3 ql::set_option("mapselectmaxlevel", "0"); +//parameter2 ql::set_option("maprecNN2q", "no"); +//parameter4 ql::set_option("mapselectmaxwidth", "min"); + ql::set_option("maptiebreak", "first"); + + ql::set_option("clifford_postmapper", "no"); + ql::set_option("scheduler_post179", "yes"); + ql::set_option("scheduler", "ALAP"); + ql::set_option("scheduler_commute", "yes"); + ql::set_option("prescheduler", "yes"); + + test_mc("mc", "noroutingfirst", "no", "0", "min"); - std::cout << "Seems good to me!" << std::endl; return 0; } diff --git a/examples/cpp-standalone-example/test_multi_core_4x4_full.json b/examples/cpp-standalone-example/test_multi_core_4x4_full.json new file mode 100644 index 000000000..809df0ef6 --- /dev/null +++ b/examples/cpp-standalone-example/test_multi_core_4x4_full.json @@ -0,0 +1,279 @@ +{ + "eqasm_compiler" : "cc_light_compiler", + + "hardware_settings": { + "qubit_number": 16, + "cycle_time" : 20, + "mw_mw_buffer": 0, + "mw_flux_buffer": 0, + "mw_readout_buffer": 0, + "flux_mw_buffer": 0, + "flux_flux_buffer": 0, + "flux_readout_buffer": 0, + "readout_mw_buffer": 0, + "readout_flux_buffer": 0, + "readout_readout_buffer": 0 + }, + + "qubit_attributes": + { + "relaxation_times": + { + "0" : [3000, 1500], + "1" : [3000, 1500], + "2" : [3000, 1500], + "3" : [3000, 1500], + "4" : [3000, 1500] + } + }, + + "topology" : + { + "number_of_cores": 4, + "connectivity": "full", + "form": "irregular", + "comm_qubits_per_core": 4 + }, + + "resources": + { + "qubits": + { + "description": "Each qubit can be used by only one gate at a time. There are 'count' qubits.", + "count": 16 + }, + "channels": + { + "description": "Each inter-core gate uses one channel in each core. There are 'count' such channels per core.", + "count": 4 + } + }, + + "instructions": { + "prepx": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "prepx" + }, + "prepz": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "prepz" + }, + "measx": { + "duration": 340, + "latency": 0, + "type": "readout", + "cc_light_instr": "measx" + }, + "measz": { + "duration": 300, + "latency": 0, + "type": "readout", + "cc_light_instr": "measz" + }, + "measure": { + "duration": 300, + "latency": 0, + "type": "readout", + "cc_light_instr": "measz" + }, + "i": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "i" + }, + "x": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "x" + }, + "y": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "y" + }, + "z": { + "duration": 40, + "latency": 0, + "type": "mw", + "cc_light_instr": "z" + }, + "rx": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "rx" + }, + "ry": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "ry" + }, + "rz": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "rz" + }, + "h": { + "duration": 40, + "latency": 0, + "type": "mw", + "cc_light_instr": "h" + }, + "s": { + "duration": 60, + "latency": 0, + "type": "mw", + "cc_light_instr": "s" + }, + "sdag": { + "duration": 60, + "latency": 0, + "type": "mw", + "cc_light_instr": "sdag" + }, + "x90": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "x90" + }, + "xm90": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "xm90" + }, + "y90": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "y90" + }, + "ym90": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "ym90" + }, + "t": { + "duration": 60, + "latency": 0, + "type": "mw", + "cc_light_instr": "t" + }, + "tdag": { + "duration": 60, + "latency": 0, + "type": "mw", + "cc_light_instr": "tdag" + }, + "x45": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "x45" + }, + "xm45": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "xm45" + }, + "y45": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "y45" + }, + "ym45": { + "duration": 20, + "latency": 0, + "type": "mw", + "cc_light_instr": "ym45" + }, + "cz": { + "duration": 60, + "latency": 0, + "type": "flux", + "cc_light_instr": "cz" + }, + "cnot": { + "duration": 100, + "latency": 0, + "type": "flux", + "cc_light_instr": "cnot" + }, + "swap": { + "duration": 260, + "latency": 0, + "type": "flux", + "cc_light_instr": "swap" + }, + "move": { + "duration": 180, + "latency": 0, + "type": "flux", + "cc_light_instr": "move" + }, + "teleportswap": { + "duration": 1000, + "latency": 0, + "type": "extern", + "cc_light_instr": "teleportswap" + }, + "teleportmove": { + "duration": 600, + "latency": 0, + "type": "extern", + "cc_light_instr": "teleportmove" + }, + "preswap": { + "duration": 100, + "latency": 0, + "type": "mw", + "cc_light_instr": "preswap" + }, + "premove": { + "duration": 100, + "latency": 0, + "type": "mw", + "cc_light_instr": "premove" + }, + "postswap": { + "duration": 100, + "latency": 0, + "type": "mw", + "cc_light_instr": "postswap" + }, + "postmove": { + "duration": 100, + "latency": 0, + "type": "mw", + "cc_light_instr": "postmove" + } + }, + + "gate_decomposition": { + "tswap_real %0,%1": ["preswap %0","teleportswap %0,%1","postswap %1"], + "tmove_real %0,%1": ["premove %0","teleportmove %0,%1","postmove %1"], + "rx180 %0" : ["x %0"], + "ry180 %0" : ["y %0"], + "rx90 %0" : ["x90 %0"], + "ry90 %0" : ["y90 %0"], + "mrx90 %0" : ["xm90 %0"], + "mry90 %0" : ["ym90 %0"], + "rx45 %0" : ["x45 %0"], + "ry45 %0" : ["y45 %0"], + "mrx45 %0" : ["xm45 %0"], + "mry45 %0" : ["ym45 %0"] + } +} diff --git a/src/ql/com/topology.cc b/src/ql/com/topology.cc index f9b8ffb94..69d9ec212 100644 --- a/src/ql/com/topology.cc +++ b/src/ql/com/topology.cc @@ -621,6 +621,14 @@ Topology::Neighbors Topology::get_neighbors(Qubit qubit) const { } } +/** + * Get the conectivity + */ +GridConnectivity Topology::get_connectivity(){ + return connectivity; +} + + /** * Returns whether the given qubit is a communication qubit of a core. */ @@ -706,10 +714,10 @@ utils::UInt Topology::get_min_hops(Qubit source, Qubit target) const { utils::UInt d = get_distance(source, target); utils::UInt cd = get_core_distance(source, target); QL_ASSERT(cd <= d); - if (cd == d) { - return d+2; - } else { + if (connectivity == GridConnectivity::FULL || cd != d){ return d; + } else { + return d+2; } } diff --git a/src/ql/pass/map/qubits/map/detail/future.cc b/src/ql/pass/map/qubits/map/detail/future.cc index 26379aa51..040e85330 100644 --- a/src/ql/pass/map/qubits/map/detail/future.cc +++ b/src/ql/pass/map/qubits/map/detail/future.cc @@ -3,7 +3,7 @@ */ #include "future.h" - +#include #include "ql/utils/filesystem.h" namespace ql { @@ -46,6 +46,7 @@ void Future::set_kernel(const ir::compat::KernelRef &kernel, const utils::Ptrgates) { scheduled.set(gp) = false; // none were scheduled + remaining_gates.push_back(gp); } scheduled.set(scheduler->instruction[scheduler->s]) = false; // also the dummy nodes not scheduled.set(scheduler->instruction[scheduler->t]) = false; @@ -137,6 +138,15 @@ void Future::completed_gate(const ir::compat::GateRef &gate) { input_gatepp = std::next(input_gatepp); } else { scheduler->take_available(scheduler->node.at(gate), avlist, scheduled, rmgr::Direction::FORWARD); + + std::list::iterator it = remaining_gates.begin(); + for(auto &i : remaining_gates){ + if(i==gate){ + remaining_gates.erase(it); + break; + } + it++; + } } } diff --git a/src/ql/pass/map/qubits/map/detail/future.h b/src/ql/pass/map/qubits/map/detail/future.h index 3d84ac3fc..c1fbf82bd 100644 --- a/src/ql/pass/map/qubits/map/detail/future.h +++ b/src/ql/pass/map/qubits/map/detail/future.h @@ -15,6 +15,7 @@ #include "options.h" #include "past.h" #include "alter.h" +#include namespace ql { namespace pass { @@ -111,6 +112,11 @@ class Future { */ utils::UInt approx_gates_remaining; + /** + * List of total number of gates remaining. + */ + utils::List remaining_gates; + /** * Program-wide initialization function. */ diff --git a/src/ql/pass/map/qubits/map/detail/mapper.cc b/src/ql/pass/map/qubits/map/detail/mapper.cc index 45ba0e962..216701819 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.cc +++ b/src/ql/pass/map/qubits/map/detail/mapper.cc @@ -8,6 +8,11 @@ #include "ql/utils/filesystem.h" #include "ql/pass/ana/statistics/annotations.h" #include "ql/pass/map/qubits/place_mip/detail/algorithm.h" +#include +#include + +// #define MULTI_LINE_LOG_DEBUG to enable multi-line dumping +#undef MULTI_LINE_LOG_DEBUG // #define MULTI_LINE_LOG_DEBUG to enable multi-line dumping #undef MULTI_LINE_LOG_DEBUG @@ -557,8 +562,9 @@ Bool Mapper::map_mappable_gates( // Find minimum number of hops between real counterparts. UInt d = platform->topology->get_min_hops(src, tgt); + UInt partitions = platform->topology->get_num_cores(); - if (d == 1) { + if (d == 1 && (partitions == 1 || src/partitions == tgt/partitions)) { // Just one hop, so gate is already nearest-neighbor and can // be mapped. @@ -824,6 +830,241 @@ void Mapper::select_alter( } +void Mapper::chong( + List &gates, + List &remaining_gates, + Future &future, + Past &past, + Past &base_past + ){ + + UInt partitions = platform->topology->get_num_cores(); + UInt n_qubits = platform->topology->get_num_qubits(); + + std::vector part(n_qubits); + + std::vector C; + com::map::QubitMapping v2r; + + for (auto &gate : gates){ + + std::vector q1; + std::vector q2; + + auto &q = gate->operands; + + past.map_qubit(q[0]); + past.map_qubit(q[1]); + + bool val; + float inf = pow(2,16); + + // --------- Partition and weight matrix ----------- + + List remaining_gates_aux(remaining_gates); + std::list::iterator it = remaining_gates_aux.begin(); + float w_matrix[n_qubits][n_qubits] = {}; + float w_aux[n_qubits][n_qubits] = {}; + + // Create weight matrix + if(remaining_gates_aux.size() == 1){ + if(remaining_gates_aux.front() == gate) + remaining_gates_aux.pop_front(); + } else { + for(auto &i : remaining_gates_aux){ + if(i==gate){ + remaining_gates_aux.erase(it); + break; + } + it++; + } + } + + w_matrix[q[0]][q[1]] = 1*inf; + w_matrix[q[1]][q[0]] = 1*inf; + w_aux[q[0]][q[1]] = 1*pow(2,-1); + w_aux[q[1]][q[0]] = 1*pow(2,-1); + + for (int i = 0; i < n_qubits; i++){ + for (int j = 0; j < n_qubits; j++) + w_matrix[i][j] += w_aux[i][j]; + } + w_aux[q[0]][q[1]] = 0; + w_aux[q[1]][q[0]] = 0; + + Int n = 2; + for(const auto &gate :remaining_gates_aux){ + auto &p = gate->operands; + if(p.size() > 1){ + past.map_qubit(p[0]); + past.map_qubit(p[1]); + w_aux[p[0]][p[1]] = 1*pow(2,-n); + w_aux[p[1]][p[0]] = 1*pow(2,-n); + for (int i = 0; i < n_qubits; i++){ + for (int j = 0; j < n_qubits; j++) + w_matrix[i][j] += w_aux[i][j]; + } + w_aux[p[0]][p[1]] = 0; + w_aux[p[1]][p[0]] = 0; + n++; + } + } + // v2r[i]/partitions + past.export_mapping(v2r); + for(int i = 0; i < n_qubits; i++) + part[i] = platform->topology->get_core_index(v2r[i]); + + // --------- End partition and weight matrix ----------- + + // --------------------- ROEE -------------------------- + // If they are equal qubits are already in same partition + if (part[q[0]] != part[q[1]]){ + float g_max = 1; + // Step 7 + val = 1; + while(g_max > 0 && val == 1){ + + if(part[q[0]] == part[q[1]]){ + val = 0; + break; + } + // Step 1 + utils::UInt index = 0; + C.clear(); + + for(int i = 0; i < n_qubits; ++i) + C.push_back(i); + // Calculating W_(i,l) + float W[n_qubits][partitions] = {}; + for(int i = 0; i < n_qubits; i++){ + for(int j = 0; j < partitions; j++){ + for(int p = 0; p < n_qubits; p++){ + + // p is the qubit index in that core + if(part[p] == j){ + W[i][j] += w_matrix[i][p]; + } + } + } + } + + // Calculating D(i,l) = W(i,l)-W[i,col(i)] + float D[n_qubits][partitions] = {}; + for(int i = 0; i < n_qubits; i++){ + for(int j = 0; j < partitions; j++) + D[i][j] = W[i][j] - W[i][part[i]]; + } + + std::vector g(C.size(), -INFINITY); + std::vector a(C.size(), 0); + std::vector b(C.size(), 0); + + // Step 4 + while(C.size() > 1){ + // Step 2 + + // Find max g(i,l) + float aux= -1; + int a_aux = 0; + int b_aux = 0; + + for(auto &i : C){ + for(auto &j : C){ + if( i != j ){ + aux = D[i][part[j]] + D[j][part[i]] - 2*w_matrix[i][j]; + if(aux > g[index]){ + g[index] = aux; + a_aux = i; + b_aux = j; + } + } + } + } + + // Delete a, b from C + C.erase(std::remove(C.begin(),C.end(),a_aux),C.end()); + C.erase(std::remove(C.begin(),C.end(),b_aux),C.end()); + + // Step 3 + for(auto &i : C){ + for (int l = 0; l < partitions; l++){ + if(l == part[a_aux]){ + if(part[i] != part[a_aux] && part[i] != part[b_aux]) + D[i][l] = D[i][l] + w_matrix[i][b_aux] - w_matrix[i][a_aux]; + if(part[i] == part[b_aux]) + D[i][l] = D[i][l] + 2*w_matrix[i][b_aux] - 2*w_matrix[i][a_aux]; + } else if (l == part[b_aux]) { + if(part[i] != part[a_aux] && part[i] != part[b_aux]) + D[i][l] = D[i][l] + w_matrix[i][a_aux] - w_matrix[i][b_aux]; + if(part[i] == part[a_aux]) + D[i][l] = D[i][l] + 2*w_matrix[i][a_aux] - 2*w_matrix[i][b_aux]; + } else { + if(part[i] == part[a_aux]){ + D[i][l] = D[i][l] + w_matrix[i][a_aux] - w_matrix[i][b_aux]; + } else if(part[i] == part[b_aux]){ + D[i][l] = D[i][l] + w_matrix[i][b_aux] - w_matrix[i][a_aux]; + } + } + } + } + a[index] = a_aux; + b[index] = b_aux; + + index++; + } + // Step 5 + // Calculate g_max + float g_aux = 0; + float g_max_idx = -1; + + for(int i = 0; i < g.size(); i++ ){ + if(g[i]==-INFINITY) + break; + if(g_aux+g[i] > g_aux){ + g_max_idx = i; + g_max = g_aux+g[i]; + } + g_aux += g[i]; + } + + // Step 6 + // Exchange firstg m pairs + int tmp = 0; + + for(int i = 0; i < g_max_idx+1 && val == 1; i++ ){ + tmp = part[a[i]]; + part[a[i]] = part[b[i]]; + part[b[i]] = tmp; + + q1.push_back(a[i]); + q2.push_back(b[i]); + + if(part[q[0]] == part[q[1]]){ + val = 0; + } + + } + } + + // --------------------- End ROEE -------------------------- + + // --------------------- Mapping qubits ------------------- + if(val == 1){ + fprintf(stderr, "Valid partition not found\n"); + exit(EXIT_FAILURE); + } + + for(int i=0; i < q1.size(); i++){ + if (q1[i] != q2[i]) + past.add_swap(past.map_qubit(q1[i]), past.map_qubit(q2[i])); + } + } + + map_routed_gate(gate, past); + future.completed_gate(gate); + } +} + /** * Given the states of past and future, map all mappable gates and find the * non-mappable ones. For those, evaluate what to do next and do it. During @@ -847,24 +1088,28 @@ void Mapper::map_gates(Future &future, Past &past, Past &base_past) { // Handle all the gates one by one. map_mappable_gates returns false when no // gates remain. while (map_mappable_gates(future, past, gates, also_nn_two_qubit_gates)) { - - // All gates in the gates list are two-qubit quantum gates that cannot - // be mapped yet. Select which one(s) to (partially) route, according to - // one of the known strategies. The only requirement on the code below - // is that at least something is done that decreases the problem. - - // Generate all alternative routes. - List alters; - gen_alters(gates, alters, past); - - // Select the best one based on the configured strategy. - Alter alter; - select_alter(alters, alter, future, past, base_past, 0); - - // Commit to selected alternative. This adds all or just one swap - // (depending on configuration) to THIS past, and schedules them/it in. - commit_alter(alter, future, past); - + if(platform->topology->get_num_cores() > 1 && + platform->topology->get_connectivity() == GridConnectivity::FULL){ + chong(gates, future.remaining_gates,future,past,base_past); + + } else { + // All gates in the gates list are two-qubit quantum gates that cannot + // be mapped yet. Select which one(s) to (partially) route, according to + // one of the known strategies. The only requirement on the code below + // is that at least something is done that decreases the problem. + + // Generate all alternative routes. + List alters; + gen_alters(gates, alters, past); + + // Select the best one based on the configured strategy. + Alter alter; + select_alter(alters, alter, future, past, base_past, 0); + + // Commit to selected alternative. This adds all or just one swap + // (depending on configuration) to THIS past, and schedules them/it in. + commit_alter(alter, future, past); + } // Print progress every once in a while if we're taking long. Real progress = 1.0; if (future.approx_gates_total) { diff --git a/src/ql/pass/map/qubits/map/detail/mapper.h b/src/ql/pass/map/qubits/map/detail/mapper.h index ab84df62a..76bb472f1 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.h +++ b/src/ql/pass/map/qubits/map/detail/mapper.h @@ -507,6 +507,23 @@ class Mapper { */ void map_kernel(const ir::compat::KernelRef &k); + void chong( + utils::List &gates, + utils::List &remaining_gates, + Future &future, + Past &past, + Past &base_past); + + void chong_mapper( + utils::UInt q1, + utils::UInt q2, + utils::UInt n_qubits, + Future &future, + Past &past, + Past &base_past, + const ir::compat::GateRef &gate + ); + public: /** From 356d0dde4508e6319b3dfdd46a0ff11ff03a00f7 Mon Sep 17 00:00:00 2001 From: hopery Date: Thu, 24 Mar 2022 15:04:01 +0200 Subject: [PATCH 2/8] Add missing change. --- include/ql/com/topology.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/ql/com/topology.h b/include/ql/com/topology.h index d3d351ba0..dca6d0b94 100644 --- a/include/ql/com/topology.h +++ b/include/ql/com/topology.h @@ -195,6 +195,11 @@ class Topology { public: + /** + * Get the conectivity + */ + GridConnectivity get_connectivity(); + /** * Constructs the grid for the given number of qubits from the given JSON * object. Refer to dump_docs() for details. From 7169756fb61e2e2f9bd465de825f7f3bcb5aa419 Mon Sep 17 00:00:00 2001 From: hopery Date: Thu, 24 Mar 2022 15:09:15 +0200 Subject: [PATCH 3/8] Delete duplicate line. --- src/ql/pass/map/qubits/map/detail/mapper.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ql/pass/map/qubits/map/detail/mapper.cc b/src/ql/pass/map/qubits/map/detail/mapper.cc index 216701819..5c9a69fcb 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.cc +++ b/src/ql/pass/map/qubits/map/detail/mapper.cc @@ -14,9 +14,6 @@ // #define MULTI_LINE_LOG_DEBUG to enable multi-line dumping #undef MULTI_LINE_LOG_DEBUG -// #define MULTI_LINE_LOG_DEBUG to enable multi-line dumping -#undef MULTI_LINE_LOG_DEBUG - namespace ql { namespace pass { namespace map { From f6cf78b7add50827166fd79c29dc7a8ea6fd624f Mon Sep 17 00:00:00 2001 From: hopery Date: Tue, 29 Mar 2022 15:06:34 +0300 Subject: [PATCH 4/8] Conver example.cc into example.py --- examples/cpp-standalone-example/example.cc | 1202 ----------------- examples/cpp-standalone-example/example.py | 1168 ++++++++++++++++ .../test_multi_core_4x4_full.json | 2 +- 3 files changed, 1169 insertions(+), 1203 deletions(-) delete mode 100644 examples/cpp-standalone-example/example.cc create mode 100644 examples/cpp-standalone-example/example.py diff --git a/examples/cpp-standalone-example/example.cc b/examples/cpp-standalone-example/example.cc deleted file mode 100644 index ed7c2599d..000000000 --- a/examples/cpp-standalone-example/example.cc +++ /dev/null @@ -1,1202 +0,0 @@ -#include - -void test_mc(std::string v, std::string param1, std::string param2, std::string param3, std::string param4) { - int n = 32; - // std::string prog_name = "test_" + v + "_maplookahead=" + param1 + "_maprecNN2q=" + param2 + "_mapselectmaxlevel=" + param3 + "_mapselectmaxwidth=" + param4; - std::string prog_name = "test_" + v; - // std::string kernel_name = "test_" + v + "_maplookahead=" + param1 + "_maprecNN2q=" + param2 + "_mapselectmaxlevel=" + param3 + "_mapselectmaxwidth=" + param4; - std::string kernel_name = "test_" + v; - std::vector sweep_points = { 1 }; - - auto starmon = ql::Platform("mc4x4full", "test_multi_core_4x4_full.json"); - //ql::set_platform(starmon); - auto prog = ql::Program(prog_name, starmon, n, 0); - auto k = ql::Kernel(kernel_name, starmon, n, 0); - prog.set_sweep_points(sweep_points); - - int i, j; - k.gate("x", 16); - k.gate("x", 0); - k.gate("ym90", 0); - k.gate("x", 1); - k.gate("ym90", 1); - k.gate("x", 2); - k.gate("ym90", 2); - k.gate("x", 3); - k.gate("ym90", 3); - k.gate("x", 4); - k.gate("ym90", 4); - k.gate("x", 5); - k.gate("ym90", 5); - k.gate("x", 6); - k.gate("ym90", 6); - k.gate("x", 7); - k.gate("ym90", 7); - k.gate("x", 8); - k.gate("ym90", 8); - k.gate("x", 9); - k.gate("ym90", 9); - k.gate("x", 10); - k.gate("ym90", 10); - k.gate("x", 11); - k.gate("ym90", 11); - k.gate("x", 12); - k.gate("ym90", 12); - k.gate("x", 13); - k.gate("ym90", 13); - k.gate("x", 14); - k.gate("ym90", 14); - k.gate("x", 15); - k.gate("ym90", 15); - k.gate("x", 16); - k.gate("ym90", 16); - k.gate("x", 0); - k.gate("x", 1); - k.gate("x", 2); - k.gate("x", 3); - k.gate("x", 4); - k.gate("x", 5); - k.gate("x", 6); - k.gate("x", 7); - k.gate("x", 8); - k.gate("x", 9); - k.gate("x", 10); - k.gate("x", 11); - k.gate("x", 12); - k.gate("x", 13); - k.gate("x", 14); - k.gate("x", 15); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 1); - k.gate("t", 17); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 0, 1); - k.gate("tdag", 1); - k.gate("t", 0); - k.gate("cnot", 0, 1); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 17); - k.gate("t", 18); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 2, 17); - k.gate("tdag", 17); - k.gate("t", 2); - k.gate("cnot", 2, 17); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 18); - k.gate("t", 19); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 3, 18); - k.gate("tdag", 18); - k.gate("t", 3); - k.gate("cnot", 3, 18); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 19); - k.gate("t", 20); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 4, 19); - k.gate("tdag", 19); - k.gate("t", 4); - k.gate("cnot", 4, 19); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 20); - k.gate("t", 21); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 5, 20); - k.gate("tdag", 20); - k.gate("t", 5); - k.gate("cnot", 5, 20); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 21); - k.gate("t", 22); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 6, 21); - k.gate("tdag", 21); - k.gate("t", 6); - k.gate("cnot", 6, 21); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 22); - k.gate("t", 23); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 7, 22); - k.gate("tdag", 22); - k.gate("t", 7); - k.gate("cnot", 7, 22); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 23); - k.gate("t", 24); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 8, 23); - k.gate("tdag", 23); - k.gate("t", 8); - k.gate("cnot", 8, 23); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 24); - k.gate("t", 25); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 9, 24); - k.gate("tdag", 24); - k.gate("t", 9); - k.gate("cnot", 9, 24); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 25); - k.gate("t", 26); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 10, 25); - k.gate("tdag", 25); - k.gate("t", 10); - k.gate("cnot", 10, 25); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 26); - k.gate("t", 27); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 11, 26); - k.gate("tdag", 26); - k.gate("t", 11); - k.gate("cnot", 11, 26); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 27); - k.gate("t", 28); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 12, 27); - k.gate("tdag", 27); - k.gate("t", 12); - k.gate("cnot", 12, 27); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 28); - k.gate("t", 29); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 13, 28); - k.gate("tdag", 28); - k.gate("t", 13); - k.gate("cnot", 13, 28); - k.gate("x", 30); - k.gate("ym90", 30); - k.gate("cnot", 29, 30); - k.gate("tdag", 30); - k.gate("cnot", 14, 30); - k.gate("t", 30); - k.gate("cnot", 29, 30); - k.gate("tdag", 30); - k.gate("cnot", 14, 30); - k.gate("t", 29); - k.gate("t", 30); - k.gate("x", 30); - k.gate("ym90", 30); - k.gate("cnot", 14, 29); - k.gate("tdag", 29); - k.gate("t", 14); - k.gate("cnot", 14, 29); - k.gate("x", 16); - k.gate("ym90", 16); - k.gate("cnot", 15, 16); - k.gate("tdag", 16); - k.gate("cnot", 30, 16); - k.gate("t", 16); - k.gate("cnot", 15, 16); - k.gate("tdag", 16); - k.gate("cnot", 30, 16); - k.gate("t", 15); - k.gate("t", 16); - k.gate("x", 16); - k.gate("ym90", 16); - k.gate("cnot", 30, 15); - k.gate("tdag", 15); - k.gate("t", 30); - k.gate("cnot", 30, 15); - k.gate("x", 30); - k.gate("ym90", 30); - k.gate("cnot", 29, 30); - k.gate("tdag", 30); - k.gate("cnot", 14, 30); - k.gate("t", 30); - k.gate("cnot", 29, 30); - k.gate("tdag", 30); - k.gate("cnot", 14, 30); - k.gate("t", 29); - k.gate("t", 30); - k.gate("x", 30); - k.gate("ym90", 30); - k.gate("cnot", 14, 29); - k.gate("tdag", 29); - k.gate("t", 14); - k.gate("cnot", 14, 29); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 28); - k.gate("t", 29); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 13, 28); - k.gate("tdag", 28); - k.gate("t", 13); - k.gate("cnot", 13, 28); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 27); - k.gate("t", 28); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 12, 27); - k.gate("tdag", 27); - k.gate("t", 12); - k.gate("cnot", 12, 27); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 26); - k.gate("t", 27); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 11, 26); - k.gate("tdag", 26); - k.gate("t", 11); - k.gate("cnot", 11, 26); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 25); - k.gate("t", 26); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 10, 25); - k.gate("tdag", 25); - k.gate("t", 10); - k.gate("cnot", 10, 25); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 24); - k.gate("t", 25); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 9, 24); - k.gate("tdag", 24); - k.gate("t", 9); - k.gate("cnot", 9, 24); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 23); - k.gate("t", 24); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 8, 23); - k.gate("tdag", 23); - k.gate("t", 8); - k.gate("cnot", 8, 23); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 22); - k.gate("t", 23); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 7, 22); - k.gate("tdag", 22); - k.gate("t", 7); - k.gate("cnot", 7, 22); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 21); - k.gate("t", 22); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 6, 21); - k.gate("tdag", 21); - k.gate("t", 6); - k.gate("cnot", 6, 21); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 20); - k.gate("t", 21); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 5, 20); - k.gate("tdag", 20); - k.gate("t", 5); - k.gate("cnot", 5, 20); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 19); - k.gate("t", 20); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 4, 19); - k.gate("tdag", 19); - k.gate("t", 4); - k.gate("cnot", 4, 19); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 18); - k.gate("t", 19); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 3, 18); - k.gate("tdag", 18); - k.gate("t", 3); - k.gate("cnot", 3, 18); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 17); - k.gate("t", 18); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 2, 17); - k.gate("tdag", 17); - k.gate("t", 2); - k.gate("cnot", 2, 17); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 1); - k.gate("t", 17); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 0, 1); - k.gate("tdag", 1); - k.gate("t", 0); - k.gate("cnot", 0, 1); - k.gate("x", 0); - k.gate("x", 1); - k.gate("x", 2); - k.gate("x", 3); - k.gate("x", 4); - k.gate("x", 5); - k.gate("x", 6); - k.gate("x", 7); - k.gate("x", 8); - k.gate("x", 9); - k.gate("x", 10); - k.gate("x", 11); - k.gate("x", 12); - k.gate("x", 13); - k.gate("x", 14); - k.gate("x", 15); - k.gate("x", 0); - k.gate("ym90", 0); - k.gate("x", 1); - k.gate("ym90", 1); - k.gate("x", 2); - k.gate("ym90", 2); - k.gate("x", 3); - k.gate("ym90", 3); - k.gate("x", 4); - k.gate("ym90", 4); - k.gate("x", 5); - k.gate("ym90", 5); - k.gate("x", 6); - k.gate("ym90", 6); - k.gate("x", 7); - k.gate("ym90", 7); - k.gate("x", 8); - k.gate("ym90", 8); - k.gate("x", 9); - k.gate("ym90", 9); - k.gate("x", 10); - k.gate("ym90", 10); - k.gate("x", 11); - k.gate("ym90", 11); - k.gate("x", 12); - k.gate("ym90", 12); - k.gate("x", 13); - k.gate("ym90", 13); - k.gate("x", 14); - k.gate("ym90", 14); - k.gate("x", 15); - k.gate("ym90", 15); - k.gate("x", 0); - k.gate("x", 1); - k.gate("x", 2); - k.gate("x", 3); - k.gate("x", 4); - k.gate("x", 5); - k.gate("x", 6); - k.gate("x", 7); - k.gate("x", 8); - k.gate("x", 9); - k.gate("x", 10); - k.gate("x", 11); - k.gate("x", 12); - k.gate("x", 13); - k.gate("x", 14); - k.gate("x", 15); - k.gate("x", 15); - k.gate("ym90", 15); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 1); - k.gate("t", 17); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 0, 1); - k.gate("tdag", 1); - k.gate("t", 0); - k.gate("cnot", 0, 1); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 17); - k.gate("t", 18); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 2, 17); - k.gate("tdag", 17); - k.gate("t", 2); - k.gate("cnot", 2, 17); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 18); - k.gate("t", 19); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 3, 18); - k.gate("tdag", 18); - k.gate("t", 3); - k.gate("cnot", 3, 18); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 19); - k.gate("t", 20); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 4, 19); - k.gate("tdag", 19); - k.gate("t", 4); - k.gate("cnot", 4, 19); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 20); - k.gate("t", 21); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 5, 20); - k.gate("tdag", 20); - k.gate("t", 5); - k.gate("cnot", 5, 20); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 21); - k.gate("t", 22); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 6, 21); - k.gate("tdag", 21); - k.gate("t", 6); - k.gate("cnot", 6, 21); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 22); - k.gate("t", 23); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 7, 22); - k.gate("tdag", 22); - k.gate("t", 7); - k.gate("cnot", 7, 22); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 23); - k.gate("t", 24); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 8, 23); - k.gate("tdag", 23); - k.gate("t", 8); - k.gate("cnot", 8, 23); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 24); - k.gate("t", 25); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 9, 24); - k.gate("tdag", 24); - k.gate("t", 9); - k.gate("cnot", 9, 24); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 25); - k.gate("t", 26); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 10, 25); - k.gate("tdag", 25); - k.gate("t", 10); - k.gate("cnot", 10, 25); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 26); - k.gate("t", 27); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 11, 26); - k.gate("tdag", 26); - k.gate("t", 11); - k.gate("cnot", 11, 26); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 27); - k.gate("t", 28); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 12, 27); - k.gate("tdag", 27); - k.gate("t", 12); - k.gate("cnot", 12, 27); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 28); - k.gate("t", 29); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 13, 28); - k.gate("tdag", 28); - k.gate("t", 13); - k.gate("cnot", 13, 28); - k.gate("x", 15); - k.gate("ym90", 15); - k.gate("cnot", 14, 15); - k.gate("tdag", 15); - k.gate("cnot", 29, 15); - k.gate("t", 15); - k.gate("cnot", 14, 15); - k.gate("tdag", 15); - k.gate("cnot", 29, 15); - k.gate("t", 14); - k.gate("t", 15); - k.gate("x", 15); - k.gate("ym90", 15); - k.gate("cnot", 29, 14); - k.gate("tdag", 14); - k.gate("t", 29); - k.gate("cnot", 29, 14); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 29); - k.gate("cnot", 28, 29); - k.gate("tdag", 29); - k.gate("cnot", 13, 29); - k.gate("t", 28); - k.gate("t", 29); - k.gate("x", 29); - k.gate("ym90", 29); - k.gate("cnot", 13, 28); - k.gate("tdag", 28); - k.gate("t", 13); - k.gate("cnot", 13, 28); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 28); - k.gate("cnot", 27, 28); - k.gate("tdag", 28); - k.gate("cnot", 12, 28); - k.gate("t", 27); - k.gate("t", 28); - k.gate("x", 28); - k.gate("ym90", 28); - k.gate("cnot", 12, 27); - k.gate("tdag", 27); - k.gate("t", 12); - k.gate("cnot", 12, 27); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 27); - k.gate("cnot", 26, 27); - k.gate("tdag", 27); - k.gate("cnot", 11, 27); - k.gate("t", 26); - k.gate("t", 27); - k.gate("x", 27); - k.gate("ym90", 27); - k.gate("cnot", 11, 26); - k.gate("tdag", 26); - k.gate("t", 11); - k.gate("cnot", 11, 26); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 26); - k.gate("cnot", 25, 26); - k.gate("tdag", 26); - k.gate("cnot", 10, 26); - k.gate("t", 25); - k.gate("t", 26); - k.gate("x", 26); - k.gate("ym90", 26); - k.gate("cnot", 10, 25); - k.gate("tdag", 25); - k.gate("t", 10); - k.gate("cnot", 10, 25); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 25); - k.gate("cnot", 24, 25); - k.gate("tdag", 25); - k.gate("cnot", 9, 25); - k.gate("t", 24); - k.gate("t", 25); - k.gate("x", 25); - k.gate("ym90", 25); - k.gate("cnot", 9, 24); - k.gate("tdag", 24); - k.gate("t", 9); - k.gate("cnot", 9, 24); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 24); - k.gate("cnot", 23, 24); - k.gate("tdag", 24); - k.gate("cnot", 8, 24); - k.gate("t", 23); - k.gate("t", 24); - k.gate("x", 24); - k.gate("ym90", 24); - k.gate("cnot", 8, 23); - k.gate("tdag", 23); - k.gate("t", 8); - k.gate("cnot", 8, 23); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 23); - k.gate("cnot", 22, 23); - k.gate("tdag", 23); - k.gate("cnot", 7, 23); - k.gate("t", 22); - k.gate("t", 23); - k.gate("x", 23); - k.gate("ym90", 23); - k.gate("cnot", 7, 22); - k.gate("tdag", 22); - k.gate("t", 7); - k.gate("cnot", 7, 22); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 22); - k.gate("cnot", 21, 22); - k.gate("tdag", 22); - k.gate("cnot", 6, 22); - k.gate("t", 21); - k.gate("t", 22); - k.gate("x", 22); - k.gate("ym90", 22); - k.gate("cnot", 6, 21); - k.gate("tdag", 21); - k.gate("t", 6); - k.gate("cnot", 6, 21); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 21); - k.gate("cnot", 20, 21); - k.gate("tdag", 21); - k.gate("cnot", 5, 21); - k.gate("t", 20); - k.gate("t", 21); - k.gate("x", 21); - k.gate("ym90", 21); - k.gate("cnot", 5, 20); - k.gate("tdag", 20); - k.gate("t", 5); - k.gate("cnot", 5, 20); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 20); - k.gate("cnot", 19, 20); - k.gate("tdag", 20); - k.gate("cnot", 4, 20); - k.gate("t", 19); - k.gate("t", 20); - k.gate("x", 20); - k.gate("ym90", 20); - k.gate("cnot", 4, 19); - k.gate("tdag", 19); - k.gate("t", 4); - k.gate("cnot", 4, 19); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 19); - k.gate("cnot", 18, 19); - k.gate("tdag", 19); - k.gate("cnot", 3, 19); - k.gate("t", 18); - k.gate("t", 19); - k.gate("x", 19); - k.gate("ym90", 19); - k.gate("cnot", 3, 18); - k.gate("tdag", 18); - k.gate("t", 3); - k.gate("cnot", 3, 18); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 18); - k.gate("cnot", 17, 18); - k.gate("tdag", 18); - k.gate("cnot", 2, 18); - k.gate("t", 17); - k.gate("t", 18); - k.gate("x", 18); - k.gate("ym90", 18); - k.gate("cnot", 2, 17); - k.gate("tdag", 17); - k.gate("t", 2); - k.gate("cnot", 2, 17); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 17); - k.gate("cnot", 1, 17); - k.gate("tdag", 17); - k.gate("cnot", 0, 17); - k.gate("t", 1); - k.gate("t", 17); - k.gate("x", 17); - k.gate("ym90", 17); - k.gate("cnot", 0, 1); - k.gate("tdag", 1); - k.gate("t", 0); - k.gate("cnot", 0, 1); - k.gate("x", 15); - k.gate("ym90", 15); - k.gate("x", 0); - k.gate("x", 1); - k.gate("x", 2); - k.gate("x", 3); - k.gate("x", 4); - k.gate("x", 5); - k.gate("x", 6); - k.gate("x", 7); - k.gate("x", 8); - k.gate("x", 9); - k.gate("x", 10); - k.gate("x", 11); - k.gate("x", 12); - k.gate("x", 13); - k.gate("x", 14); - k.gate("x", 15); - k.gate("x", 0); - k.gate("ym90", 0); - k.gate("x", 1); - k.gate("ym90", 1); - k.gate("x", 2); - k.gate("ym90", 2); - k.gate("x", 3); - k.gate("ym90", 3); - k.gate("x", 4); - k.gate("ym90", 4); - k.gate("x", 5); - k.gate("ym90", 5); - k.gate("x", 6); - k.gate("ym90", 6); - k.gate("x", 7); - k.gate("ym90", 7); - k.gate("x", 8); - k.gate("ym90", 8); - k.gate("x", 9); - k.gate("ym90", 9); - k.gate("x", 10); - k.gate("ym90", 10); - k.gate("x", 11); - k.gate("ym90", 11); - k.gate("x", 12); - k.gate("ym90", 12); - k.gate("x", 13); - k.gate("ym90", 13); - k.gate("x", 14); - k.gate("ym90", 14); - k.gate("x", 15); - k.gate("ym90", 15); - - //for (i=0; i<4; i++) { - // k.gate("x", 4*i);;; - // k.gate("x", 4*i+1);;; - //} - //for (i=0; i<4; i++) { - // k.gate("cnot", 4*i, 4*i+1);;; - //} -// // for (i=0; i<4; i++) { - // for (j=0; j<4; j++) { - // if (i!=j) k.gate("cnot", 4*i, 4*j);;; - // } - // } - // k.gate("x", 4);;; - prog.add_kernel(k); - - // ql::set_option("maplookahead", param1); - // ql::set_option("maprecNN2q", param2); - // ql::set_option("mapselectmaxlevel", param3); - // ql::set_option("mapselectmaxwidth", param4); - - prog.compile(); -} - - - -int main(int argc, char **argv) { - ql::utils::logger::set_log_level("LOG_DEBUG"); - // ql::utils::logger::set_log_level("LOG_NOTHING"); - ql::set_option("unique_output", "no"); - - ql::set_option("write_qasm_files", "yes"); - ql::set_option("write_report_files", "yes"); - // ql::set_option("print_dot_graphs", "yes"); - ql::set_option("use_default_gates", "no"); - ql::set_option("generate_code", "no"); - - ql::set_option("clifford_prescheduler", "no"); - ql::set_option("clifford_postscheduler", "no"); - - // ql::set_option("clifford_premapper", "yes"); - ql::set_option("mapper", "minextend"); - ql::set_option("mapinitone2one", "yes"); - ql::set_option("mapassumezeroinitstate", "yes"); -//parameter1 ql::set_option("maplookahead", "noroutingfirst"); - ql::set_option("mapselectswaps", "all"); - ql::set_option("initialplace", "no"); - ql::set_option("initialplace2qhorizon", "0"); - ql::set_option("mappathselect", "all"); - ql::set_option("mapusemoves", "yes"); - ql::set_option("mapreverseswap", "yes"); -//parameter3 ql::set_option("mapselectmaxlevel", "0"); -//parameter2 ql::set_option("maprecNN2q", "no"); -//parameter4 ql::set_option("mapselectmaxwidth", "min"); - ql::set_option("maptiebreak", "first"); - - ql::set_option("clifford_postmapper", "no"); - ql::set_option("scheduler_post179", "yes"); - ql::set_option("scheduler", "ALAP"); - ql::set_option("scheduler_commute", "yes"); - ql::set_option("prescheduler", "yes"); - - test_mc("mc", "noroutingfirst", "no", "0", "min"); - - return 0; -} diff --git a/examples/cpp-standalone-example/example.py b/examples/cpp-standalone-example/example.py new file mode 100644 index 000000000..b98b99a93 --- /dev/null +++ b/examples/cpp-standalone-example/example.py @@ -0,0 +1,1168 @@ + +from openql import openql as ql +import os +import argparse + +def circuit(new_scheduler='yes', scheduler='ASAP', uniform_sched= 'no', sched_commute = 'yes', mapper='no', moves='no', maptiebreak='random', initial_placement='no', output_dir_name='compiler_output', measurement=True, log_level='LOG_NOTHING'): + output_dir = output_dir_name + ql.initialize() + ql.set_option('output_dir', output_dir) + + ql.set_option('log_level', log_level) + ql.set_option('use_default_gates', 'no') + + ql.set_option('mapper', mapper) + + ql.set_option('write_qasm_files', 'yes') + ql.set_option('write_report_files', 'yes') + + platform = ql.Platform('mctests', 'test_multi_core_4x4_full.json') + num_circuits = 1 + num_qubits = 32 + p = ql.Program('grover_q32_1', platform, num_qubits) + k = ql.Kernel('grover_q32_1', platform, num_qubits) + k.gate('x', (16,)) + k.gate('x', (0,)) + k.gate('ym90', (0,)) + k.gate('x', (1,)) + k.gate('ym90', (1,)) + k.gate('x', (2,)) + k.gate('ym90', (2,)) + k.gate('x', (3,)) + k.gate('ym90', (3,)) + k.gate('x', (4,)) + k.gate('ym90', (4,)) + k.gate('x', (5,)) + k.gate('ym90', (5,)) + k.gate('x', (6,)) + k.gate('ym90', (6,)) + k.gate('x', (7,)) + k.gate('ym90', (7,)) + k.gate('x', (8,)) + k.gate('ym90', (8,)) + k.gate('x', (9,)) + k.gate('ym90', (9,)) + k.gate('x', (10,)) + k.gate('ym90', (10,)) + k.gate('x', (11,)) + k.gate('ym90', (11,)) + k.gate('x', (12,)) + k.gate('ym90', (12,)) + k.gate('x', (13,)) + k.gate('ym90', (13,)) + k.gate('x', (14,)) + k.gate('ym90', (14,)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + k.gate('x', (16,)) + k.gate('ym90', (16,)) + k.gate('x', (0,)) + k.gate('x', (1,)) + k.gate('x', (2,)) + k.gate('x', (3,)) + k.gate('x', (4,)) + k.gate('x', (5,)) + k.gate('x', (6,)) + k.gate('x', (7,)) + k.gate('x', (8,)) + k.gate('x', (9,)) + k.gate('x', (10,)) + k.gate('x', (11,)) + k.gate('x', (12,)) + k.gate('x', (13,)) + k.gate('x', (14,)) + k.gate('x', (15,)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (1,)) + k.gate('t', (17,)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (0, 1)) + k.gate('tdag', (1,)) + k.gate('t', (0,)) + k.gate('cnot', (0, 1)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (17,)) + k.gate('t', (18,)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (2, 17)) + k.gate('tdag', (17,)) + k.gate('t', (2,)) + k.gate('cnot', (2, 17)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (18,)) + k.gate('t', (19,)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (3, 18)) + k.gate('tdag', (18,)) + k.gate('t', (3,)) + k.gate('cnot', (3, 18)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (19,)) + k.gate('t', (20,)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (4, 19)) + k.gate('tdag', (19,)) + k.gate('t', (4,)) + k.gate('cnot', (4, 19)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (20,)) + k.gate('t', (21,)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (5, 20)) + k.gate('tdag', (20,)) + k.gate('t', (5,)) + k.gate('cnot', (5, 20)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (21,)) + k.gate('t', (22,)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (6, 21)) + k.gate('tdag', (21,)) + k.gate('t', (6,)) + k.gate('cnot', (6, 21)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (22,)) + k.gate('t', (23,)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (7, 22)) + k.gate('tdag', (22,)) + k.gate('t', (7,)) + k.gate('cnot', (7, 22)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (23,)) + k.gate('t', (24,)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (8, 23)) + k.gate('tdag', (23,)) + k.gate('t', (8,)) + k.gate('cnot', (8, 23)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (24,)) + k.gate('t', (25,)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (9, 24)) + k.gate('tdag', (24,)) + k.gate('t', (9,)) + k.gate('cnot', (9, 24)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (25,)) + k.gate('t', (26,)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (10, 25)) + k.gate('tdag', (25,)) + k.gate('t', (10,)) + k.gate('cnot', (10, 25)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (26,)) + k.gate('t', (27,)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (11, 26)) + k.gate('tdag', (26,)) + k.gate('t', (11,)) + k.gate('cnot', (11, 26)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (27,)) + k.gate('t', (28,)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (12, 27)) + k.gate('tdag', (27,)) + k.gate('t', (12,)) + k.gate('cnot', (12, 27)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (28,)) + k.gate('t', (29,)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (13, 28)) + k.gate('tdag', (28,)) + k.gate('t', (13,)) + k.gate('cnot', (13, 28)) + k.gate('x', (30,)) + k.gate('ym90', (30,)) + k.gate('cnot', (29, 30)) + k.gate('tdag', (30,)) + k.gate('cnot', (14, 30)) + k.gate('t', (30,)) + k.gate('cnot', (29, 30)) + k.gate('tdag', (30,)) + k.gate('cnot', (14, 30)) + k.gate('t', (29,)) + k.gate('t', (30,)) + k.gate('x', (30,)) + k.gate('ym90', (30,)) + k.gate('cnot', (14, 29)) + k.gate('tdag', (29,)) + k.gate('t', (14,)) + k.gate('cnot', (14, 29)) + k.gate('x', (16,)) + k.gate('ym90', (16,)) + k.gate('cnot', (15, 16)) + k.gate('tdag', (16,)) + k.gate('cnot', (30, 16)) + k.gate('t', (16,)) + k.gate('cnot', (15, 16)) + k.gate('tdag', (16,)) + k.gate('cnot', (30, 16)) + k.gate('t', (15,)) + k.gate('t', (16,)) + k.gate('x', (16,)) + k.gate('ym90', (16,)) + k.gate('cnot', (30, 15)) + k.gate('tdag', (15,)) + k.gate('t', (30,)) + k.gate('cnot', (30, 15)) + k.gate('x', (30,)) + k.gate('ym90', (30,)) + k.gate('cnot', (29, 30)) + k.gate('tdag', (30,)) + k.gate('cnot', (14, 30)) + k.gate('t', (30,)) + k.gate('cnot', (29, 30)) + k.gate('tdag', (30,)) + k.gate('cnot', (14, 30)) + k.gate('t', (29,)) + k.gate('t', (30,)) + k.gate('x', (30,)) + k.gate('ym90', (30,)) + k.gate('cnot', (14, 29)) + k.gate('tdag', (29,)) + k.gate('t', (14,)) + k.gate('cnot', (14, 29)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (28,)) + k.gate('t', (29,)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (13, 28)) + k.gate('tdag', (28,)) + k.gate('t', (13,)) + k.gate('cnot', (13, 28)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (27,)) + k.gate('t', (28,)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (12, 27)) + k.gate('tdag', (27,)) + k.gate('t', (12,)) + k.gate('cnot', (12, 27)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (26,)) + k.gate('t', (27,)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (11, 26)) + k.gate('tdag', (26,)) + k.gate('t', (11,)) + k.gate('cnot', (11, 26)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (25,)) + k.gate('t', (26,)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (10, 25)) + k.gate('tdag', (25,)) + k.gate('t', (10,)) + k.gate('cnot', (10, 25)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (24,)) + k.gate('t', (25,)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (9, 24)) + k.gate('tdag', (24,)) + k.gate('t', (9,)) + k.gate('cnot', (9, 24)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (23,)) + k.gate('t', (24,)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (8, 23)) + k.gate('tdag', (23,)) + k.gate('t', (8,)) + k.gate('cnot', (8, 23)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (22,)) + k.gate('t', (23,)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (7, 22)) + k.gate('tdag', (22,)) + k.gate('t', (7,)) + k.gate('cnot', (7, 22)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (21,)) + k.gate('t', (22,)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (6, 21)) + k.gate('tdag', (21,)) + k.gate('t', (6,)) + k.gate('cnot', (6, 21)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (20,)) + k.gate('t', (21,)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (5, 20)) + k.gate('tdag', (20,)) + k.gate('t', (5,)) + k.gate('cnot', (5, 20)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (19,)) + k.gate('t', (20,)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (4, 19)) + k.gate('tdag', (19,)) + k.gate('t', (4,)) + k.gate('cnot', (4, 19)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (18,)) + k.gate('t', (19,)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (3, 18)) + k.gate('tdag', (18,)) + k.gate('t', (3,)) + k.gate('cnot', (3, 18)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (17,)) + k.gate('t', (18,)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (2, 17)) + k.gate('tdag', (17,)) + k.gate('t', (2,)) + k.gate('cnot', (2, 17)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (1,)) + k.gate('t', (17,)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (0, 1)) + k.gate('tdag', (1,)) + k.gate('t', (0,)) + k.gate('cnot', (0, 1)) + k.gate('x', (0,)) + k.gate('x', (1,)) + k.gate('x', (2,)) + k.gate('x', (3,)) + k.gate('x', (4,)) + k.gate('x', (5,)) + k.gate('x', (6,)) + k.gate('x', (7,)) + k.gate('x', (8,)) + k.gate('x', (9,)) + k.gate('x', (10,)) + k.gate('x', (11,)) + k.gate('x', (12,)) + k.gate('x', (13,)) + k.gate('x', (14,)) + k.gate('x', (15,)) + k.gate('x', (0,)) + k.gate('ym90', (0,)) + k.gate('x', (1,)) + k.gate('ym90', (1,)) + k.gate('x', (2,)) + k.gate('ym90', (2,)) + k.gate('x', (3,)) + k.gate('ym90', (3,)) + k.gate('x', (4,)) + k.gate('ym90', (4,)) + k.gate('x', (5,)) + k.gate('ym90', (5,)) + k.gate('x', (6,)) + k.gate('ym90', (6,)) + k.gate('x', (7,)) + k.gate('ym90', (7,)) + k.gate('x', (8,)) + k.gate('ym90', (8,)) + k.gate('x', (9,)) + k.gate('ym90', (9,)) + k.gate('x', (10,)) + k.gate('ym90', (10,)) + k.gate('x', (11,)) + k.gate('ym90', (11,)) + k.gate('x', (12,)) + k.gate('ym90', (12,)) + k.gate('x', (13,)) + k.gate('ym90', (13,)) + k.gate('x', (14,)) + k.gate('ym90', (14,)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + k.gate('x', (0,)) + k.gate('x', (1,)) + k.gate('x', (2,)) + k.gate('x', (3,)) + k.gate('x', (4,)) + k.gate('x', (5,)) + k.gate('x', (6,)) + k.gate('x', (7,)) + k.gate('x', (8,)) + k.gate('x', (9,)) + k.gate('x', (10,)) + k.gate('x', (11,)) + k.gate('x', (12,)) + k.gate('x', (13,)) + k.gate('x', (14,)) + k.gate('x', (15,)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (1,)) + k.gate('t', (17,)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (0, 1)) + k.gate('tdag', (1,)) + k.gate('t', (0,)) + k.gate('cnot', (0, 1)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (17,)) + k.gate('t', (18,)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (2, 17)) + k.gate('tdag', (17,)) + k.gate('t', (2,)) + k.gate('cnot', (2, 17)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (18,)) + k.gate('t', (19,)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (3, 18)) + k.gate('tdag', (18,)) + k.gate('t', (3,)) + k.gate('cnot', (3, 18)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (19,)) + k.gate('t', (20,)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (4, 19)) + k.gate('tdag', (19,)) + k.gate('t', (4,)) + k.gate('cnot', (4, 19)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (20,)) + k.gate('t', (21,)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (5, 20)) + k.gate('tdag', (20,)) + k.gate('t', (5,)) + k.gate('cnot', (5, 20)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (21,)) + k.gate('t', (22,)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (6, 21)) + k.gate('tdag', (21,)) + k.gate('t', (6,)) + k.gate('cnot', (6, 21)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (22,)) + k.gate('t', (23,)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (7, 22)) + k.gate('tdag', (22,)) + k.gate('t', (7,)) + k.gate('cnot', (7, 22)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (23,)) + k.gate('t', (24,)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (8, 23)) + k.gate('tdag', (23,)) + k.gate('t', (8,)) + k.gate('cnot', (8, 23)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (24,)) + k.gate('t', (25,)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (9, 24)) + k.gate('tdag', (24,)) + k.gate('t', (9,)) + k.gate('cnot', (9, 24)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (25,)) + k.gate('t', (26,)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (10, 25)) + k.gate('tdag', (25,)) + k.gate('t', (10,)) + k.gate('cnot', (10, 25)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (26,)) + k.gate('t', (27,)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (11, 26)) + k.gate('tdag', (26,)) + k.gate('t', (11,)) + k.gate('cnot', (11, 26)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (27,)) + k.gate('t', (28,)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (12, 27)) + k.gate('tdag', (27,)) + k.gate('t', (12,)) + k.gate('cnot', (12, 27)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (28,)) + k.gate('t', (29,)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (13, 28)) + k.gate('tdag', (28,)) + k.gate('t', (13,)) + k.gate('cnot', (13, 28)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + k.gate('cnot', (14, 15)) + k.gate('tdag', (15,)) + k.gate('cnot', (29, 15)) + k.gate('t', (15,)) + k.gate('cnot', (14, 15)) + k.gate('tdag', (15,)) + k.gate('cnot', (29, 15)) + k.gate('t', (14,)) + k.gate('t', (15,)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + k.gate('cnot', (29, 14)) + k.gate('tdag', (14,)) + k.gate('t', (29,)) + k.gate('cnot', (29, 14)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (29,)) + k.gate('cnot', (28, 29)) + k.gate('tdag', (29,)) + k.gate('cnot', (13, 29)) + k.gate('t', (28,)) + k.gate('t', (29,)) + k.gate('x', (29,)) + k.gate('ym90', (29,)) + k.gate('cnot', (13, 28)) + k.gate('tdag', (28,)) + k.gate('t', (13,)) + k.gate('cnot', (13, 28)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (28,)) + k.gate('cnot', (27, 28)) + k.gate('tdag', (28,)) + k.gate('cnot', (12, 28)) + k.gate('t', (27,)) + k.gate('t', (28,)) + k.gate('x', (28,)) + k.gate('ym90', (28,)) + k.gate('cnot', (12, 27)) + k.gate('tdag', (27,)) + k.gate('t', (12,)) + k.gate('cnot', (12, 27)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (27,)) + k.gate('cnot', (26, 27)) + k.gate('tdag', (27,)) + k.gate('cnot', (11, 27)) + k.gate('t', (26,)) + k.gate('t', (27,)) + k.gate('x', (27,)) + k.gate('ym90', (27,)) + k.gate('cnot', (11, 26)) + k.gate('tdag', (26,)) + k.gate('t', (11,)) + k.gate('cnot', (11, 26)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (26,)) + k.gate('cnot', (25, 26)) + k.gate('tdag', (26,)) + k.gate('cnot', (10, 26)) + k.gate('t', (25,)) + k.gate('t', (26,)) + k.gate('x', (26,)) + k.gate('ym90', (26,)) + k.gate('cnot', (10, 25)) + k.gate('tdag', (25,)) + k.gate('t', (10,)) + k.gate('cnot', (10, 25)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (25,)) + k.gate('cnot', (24, 25)) + k.gate('tdag', (25,)) + k.gate('cnot', (9, 25)) + k.gate('t', (24,)) + k.gate('t', (25,)) + k.gate('x', (25,)) + k.gate('ym90', (25,)) + k.gate('cnot', (9, 24)) + k.gate('tdag', (24,)) + k.gate('t', (9,)) + k.gate('cnot', (9, 24)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (24,)) + k.gate('cnot', (23, 24)) + k.gate('tdag', (24,)) + k.gate('cnot', (8, 24)) + k.gate('t', (23,)) + k.gate('t', (24,)) + k.gate('x', (24,)) + k.gate('ym90', (24,)) + k.gate('cnot', (8, 23)) + k.gate('tdag', (23,)) + k.gate('t', (8,)) + k.gate('cnot', (8, 23)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (23,)) + k.gate('cnot', (22, 23)) + k.gate('tdag', (23,)) + k.gate('cnot', (7, 23)) + k.gate('t', (22,)) + k.gate('t', (23,)) + k.gate('x', (23,)) + k.gate('ym90', (23,)) + k.gate('cnot', (7, 22)) + k.gate('tdag', (22,)) + k.gate('t', (7,)) + k.gate('cnot', (7, 22)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (22,)) + k.gate('cnot', (21, 22)) + k.gate('tdag', (22,)) + k.gate('cnot', (6, 22)) + k.gate('t', (21,)) + k.gate('t', (22,)) + k.gate('x', (22,)) + k.gate('ym90', (22,)) + k.gate('cnot', (6, 21)) + k.gate('tdag', (21,)) + k.gate('t', (6,)) + k.gate('cnot', (6, 21)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (21,)) + k.gate('cnot', (20, 21)) + k.gate('tdag', (21,)) + k.gate('cnot', (5, 21)) + k.gate('t', (20,)) + k.gate('t', (21,)) + k.gate('x', (21,)) + k.gate('ym90', (21,)) + k.gate('cnot', (5, 20)) + k.gate('tdag', (20,)) + k.gate('t', (5,)) + k.gate('cnot', (5, 20)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (20,)) + k.gate('cnot', (19, 20)) + k.gate('tdag', (20,)) + k.gate('cnot', (4, 20)) + k.gate('t', (19,)) + k.gate('t', (20,)) + k.gate('x', (20,)) + k.gate('ym90', (20,)) + k.gate('cnot', (4, 19)) + k.gate('tdag', (19,)) + k.gate('t', (4,)) + k.gate('cnot', (4, 19)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (19,)) + k.gate('cnot', (18, 19)) + k.gate('tdag', (19,)) + k.gate('cnot', (3, 19)) + k.gate('t', (18,)) + k.gate('t', (19,)) + k.gate('x', (19,)) + k.gate('ym90', (19,)) + k.gate('cnot', (3, 18)) + k.gate('tdag', (18,)) + k.gate('t', (3,)) + k.gate('cnot', (3, 18)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (18,)) + k.gate('cnot', (17, 18)) + k.gate('tdag', (18,)) + k.gate('cnot', (2, 18)) + k.gate('t', (17,)) + k.gate('t', (18,)) + k.gate('x', (18,)) + k.gate('ym90', (18,)) + k.gate('cnot', (2, 17)) + k.gate('tdag', (17,)) + k.gate('t', (2,)) + k.gate('cnot', (2, 17)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (17,)) + k.gate('cnot', (1, 17)) + k.gate('tdag', (17,)) + k.gate('cnot', (0, 17)) + k.gate('t', (1,)) + k.gate('t', (17,)) + k.gate('x', (17,)) + k.gate('ym90', (17,)) + k.gate('cnot', (0, 1)) + k.gate('tdag', (1,)) + k.gate('t', (0,)) + k.gate('cnot', (0, 1)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + k.gate('x', (0,)) + k.gate('x', (1,)) + k.gate('x', (2,)) + k.gate('x', (3,)) + k.gate('x', (4,)) + k.gate('x', (5,)) + k.gate('x', (6,)) + k.gate('x', (7,)) + k.gate('x', (8,)) + k.gate('x', (9,)) + k.gate('x', (10,)) + k.gate('x', (11,)) + k.gate('x', (12,)) + k.gate('x', (13,)) + k.gate('x', (14,)) + k.gate('x', (15,)) + k.gate('x', (0,)) + k.gate('ym90', (0,)) + k.gate('x', (1,)) + k.gate('ym90', (1,)) + k.gate('x', (2,)) + k.gate('ym90', (2,)) + k.gate('x', (3,)) + k.gate('ym90', (3,)) + k.gate('x', (4,)) + k.gate('ym90', (4,)) + k.gate('x', (5,)) + k.gate('ym90', (5,)) + k.gate('x', (6,)) + k.gate('ym90', (6,)) + k.gate('x', (7,)) + k.gate('ym90', (7,)) + k.gate('x', (8,)) + k.gate('ym90', (8,)) + k.gate('x', (9,)) + k.gate('ym90', (9,)) + k.gate('x', (10,)) + k.gate('ym90', (10,)) + k.gate('x', (11,)) + k.gate('ym90', (11,)) + k.gate('x', (12,)) + k.gate('ym90', (12,)) + k.gate('x', (13,)) + k.gate('ym90', (13,)) + k.gate('x', (14,)) + k.gate('ym90', (14,)) + k.gate('x', (15,)) + k.gate('ym90', (15,)) + + if measurement: + for q in range(num_qubits): + k.gate('measure', [q]) + + p.add_kernel(k) + p.compile() + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='OpenQL compilation of a Quantum Algorithm') + parser.add_argument('--new_scheduler', nargs='?', default='yes', help='Scheduler defined by Hans') + parser.add_argument('--scheduler', nargs='?', default='ASAP', help='Scheduler specification (ASAP (default), ALAP, ...)') + parser.add_argument('--uniform_sched', nargs='?', default='no', help='Uniform shceduler actication (yes or no)') + parser.add_argument('--sched_commute', nargs='?', default='yes', help='Permits two-qubit gates to be commutable') + parser.add_argument('--mapper', nargs='?', default='minextend', help='Mapper specification (base, minextend, minextendrc)') + parser.add_argument('--moves', nargs='?', default='no', help='Let the use of moves') + parser.add_argument('--maptiebreak', nargs='?', default='random', help='') + parser.add_argument('--initial_placement', nargs='?', default='no', help='Initial placement specification (yes or no)') + parser.add_argument('--out_dir', nargs='?', default='compiler_output', help='Folder name to store the compilation') + parser.add_argument('--measurement', nargs='?', default=True, help='Add measurement to all the qubits in the end of the algorithm') + args = parser.parse_args() + try: + circuit(args.new_scheduler, args.scheduler, args.uniform_sched, args.sched_commute, args.mapper, args.moves, args.maptiebreak, args.initial_placement, args.out_dir) + except TypeError: + print('\nCompiled, but some gate is not defined in the configuration file. \nThe gate will be invoked like it is.') + raise \ No newline at end of file diff --git a/examples/cpp-standalone-example/test_multi_core_4x4_full.json b/examples/cpp-standalone-example/test_multi_core_4x4_full.json index 809df0ef6..2d5712d6c 100644 --- a/examples/cpp-standalone-example/test_multi_core_4x4_full.json +++ b/examples/cpp-standalone-example/test_multi_core_4x4_full.json @@ -2,7 +2,7 @@ "eqasm_compiler" : "cc_light_compiler", "hardware_settings": { - "qubit_number": 16, + "qubit_number": 32, "cycle_time" : 20, "mw_mw_buffer": 0, "mw_flux_buffer": 0, From e5a0c3bbaae1a4bf9173d1f395ae11325bdc0fc3 Mon Sep 17 00:00:00 2001 From: hopery Date: Wed, 8 Jun 2022 18:23:17 +0300 Subject: [PATCH 5/8] [WIP] Option to enable/disable rOEE --- src/ql/com/options.cc | 7 +++++++ src/ql/pass/map/qubits/map/detail/mapper.cc | 12 +++++++++--- src/ql/pass/map/qubits/map/detail/mapper.h | 12 +----------- src/ql/pass/map/qubits/map/detail/options.h | 5 +++++ src/ql/pass/map/qubits/map/map.cc | 18 ++++++++++++++++++ src/ql/pmgr/manager.cc | 6 ++++++ 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/ql/com/options.cc b/src/ql/com/options.cc index aa65f89a9..f31db2fb8 100644 --- a/src/ql/com/options.cc +++ b/src/ql/com/options.cc @@ -399,6 +399,13 @@ Options make_ql_options() { true ); + options.add_bool( + "maprOEE", + "Applies the rOEE routing algorithm for multi-core architecures " + "with an all to all connection.", + false + ); + #if 0 // FIXME: removed, use pass options //========================================================================// // Default-inserted CC code generation pass behavior // diff --git a/src/ql/pass/map/qubits/map/detail/mapper.cc b/src/ql/pass/map/qubits/map/detail/mapper.cc index a58efa750..88a1e5d44 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.cc +++ b/src/ql/pass/map/qubits/map/detail/mapper.cc @@ -561,6 +561,7 @@ Bool Mapper::map_mappable_gates( UInt d = platform->topology->get_min_hops(src, tgt); UInt partitions = platform->topology->get_num_cores(); + // Check if qubits are NN and they are in the same partition if (d == 1 && (partitions == 1 || src/partitions == tgt/partitions)) { // Just one hop, so gate is already nearest-neighbor and can @@ -827,7 +828,7 @@ void Mapper::select_alter( } -void Mapper::chong( +void Mapper::rOEE( List &gates, List &remaining_gates, Future &future, @@ -1085,9 +1086,14 @@ void Mapper::map_gates(Future &future, Past &past, Past &base_past) { // Handle all the gates one by one. map_mappable_gates returns false when no // gates remain. while (map_mappable_gates(future, past, gates, also_nn_two_qubit_gates)) { - if(platform->topology->get_num_cores() > 1 && + + // Check if rOEE mapping option is set and architecture constraints are + // satisfied + if(options->rOEE_routing_algorithm && + platform->topology->get_num_cores() > 1 && platform->topology->get_connectivity() == GridConnectivity::FULL){ - chong(gates, future.remaining_gates,future,past,base_past); + + rOEE(gates, future.remaining_gates,future,past,base_past); } else { // All gates in the gates list are two-qubit quantum gates that cannot diff --git a/src/ql/pass/map/qubits/map/detail/mapper.h b/src/ql/pass/map/qubits/map/detail/mapper.h index 76bb472f1..825baf020 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.h +++ b/src/ql/pass/map/qubits/map/detail/mapper.h @@ -507,23 +507,13 @@ class Mapper { */ void map_kernel(const ir::compat::KernelRef &k); - void chong( + void rOEE( utils::List &gates, utils::List &remaining_gates, Future &future, Past &past, Past &base_past); - void chong_mapper( - utils::UInt q1, - utils::UInt q2, - utils::UInt n_qubits, - Future &future, - Past &past, - Past &base_past, - const ir::compat::GateRef &gate - ); - public: /** diff --git a/src/ql/pass/map/qubits/map/detail/options.h b/src/ql/pass/map/qubits/map/detail/options.h index 639b2f9dc..7bd5ccade 100644 --- a/src/ql/pass/map/qubits/map/detail/options.h +++ b/src/ql/pass/map/qubits/map/detail/options.h @@ -315,6 +315,11 @@ struct Options { */ utils::Bool write_dot_graphs = false; + /** + * Use the rOEE routing algorithm algorithm for multi-core architectures. + */ + utils::Bool rOEE_routing_algorithm = false; + }; /** diff --git a/src/ql/pass/map/qubits/map/map.cc b/src/ql/pass/map/qubits/map/map.cc index 1bdae6ddb..b69de126c 100644 --- a/src/ql/pass/map/qubits/map/map.cc +++ b/src/ql/pass/map/qubits/map/map.cc @@ -383,6 +383,17 @@ MapQubitsPass::MapQubitsPass( false ); + //========================================================================// + // Options for the routing in multi-core architectures // + //========================================================================// + + options.add_bool( + "rOEE_routing_algorithm", + "Applies the rOEE routing algorithm for multi-core architecures " + "with an all to all connection.", + false + ); + } /** @@ -493,6 +504,13 @@ pmgr::pass_types::NodeType MapQubitsPass::on_construct( parsed_options->max_move_penalty = utils::parse_uint(use_moves); } + auto map_rOEE = options["rOEE_routing_algorithm"].as_str(); + if (map_rOEE == "no") { + parsed_options->rOEE_routing_algorithm = false; + } else { + parsed_options->rOEE_routing_algorithm = true; + } + parsed_options->reverse_swap_if_better = options["reverse_swap_if_better"].as_bool(); parsed_options->commute_multi_qubit = options["commute_multi_qubit"].as_bool(); parsed_options->commute_single_qubit = options["commute_single_qubit"].as_bool(); diff --git a/src/ql/pmgr/manager.cc b/src/ql/pmgr/manager.cc index a64293e12..4345e6e28 100644 --- a/src/ql/pmgr/manager.cc +++ b/src/ql/pmgr/manager.cc @@ -437,6 +437,12 @@ static utils::Map convert_global_to_pass_options() { retval.set("reverse_swap_if_better") = mapreverseswap.as_str(); } + const auto &maprOEE = com::options::global["maprOEE"]; + if (maprOEE.is_set()) { + retval.set("rOEE_routing_algorithm") = maprOEE.as_str(); + } + + #if 0 // FIXME: removed, use pass options // Set options for CC backend. const auto &backend_cc_map_input_file = com::options::global["backend_cc_map_input_file"]; From 5be06ab2cc8c56e3df906a08db03620285f676cc Mon Sep 17 00:00:00 2001 From: Hopery Date: Sun, 11 Sep 2022 16:43:12 +0200 Subject: [PATCH 6/8] Add rOEE test --- .gitignore | 5 +- examples/cpp-standalone-example/example.cc | 29 + examples/cpp-standalone-example/example.py | 1168 ----------------- .../test_multi_core_4x4_full.json | 279 ---- src/ql/com/topology.cc | 7 +- src/ql/pass/map/qubits/map/detail/mapper.cc | 3 +- tests/golden/test_rOEE_last.qasm | 109 ++ tests/test_rOEE.py | 51 + 8 files changed, 195 insertions(+), 1456 deletions(-) create mode 100644 examples/cpp-standalone-example/example.cc delete mode 100644 examples/cpp-standalone-example/example.py delete mode 100644 examples/cpp-standalone-example/test_multi_core_4x4_full.json create mode 100644 tests/golden/test_rOEE_last.qasm create mode 100644 tests/test_rOEE.py diff --git a/.gitignore b/.gitignore index 640c508dd..d5f2f6d26 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,4 @@ docs/_templates docs/_templates /.idea -/cmake-build-* -qiskit-vscode-log.test_output -qiskit-vscode-log.out -.vscode/settings.json +/cmake-build-* \ No newline at end of file diff --git a/examples/cpp-standalone-example/example.cc b/examples/cpp-standalone-example/example.cc new file mode 100644 index 000000000..dc2b8c123 --- /dev/null +++ b/examples/cpp-standalone-example/example.cc @@ -0,0 +1,29 @@ +#include +#include + +int main(int argc, char **argv) { + // create platform + auto platf = ql::Platform("seven_qubits_chip", "cc_light"); + + // create program + auto prog = ql::Program("aProgram", platf, 2); + + // create kernel + auto k = ql::Kernel("aKernel", platf, 2); + + k.gate("prepz", 0); + k.gate("prepz", 1); + k.gate("x", 0); + k.gate("y", 1); + k.measure(0); + k.measure(1); + + // add kernel to program + prog.add_kernel(k); + + // compile the program + prog.compile(); + + std::cout << "Seems good to me!" << std::endl; + return 0; +} \ No newline at end of file diff --git a/examples/cpp-standalone-example/example.py b/examples/cpp-standalone-example/example.py deleted file mode 100644 index b98b99a93..000000000 --- a/examples/cpp-standalone-example/example.py +++ /dev/null @@ -1,1168 +0,0 @@ - -from openql import openql as ql -import os -import argparse - -def circuit(new_scheduler='yes', scheduler='ASAP', uniform_sched= 'no', sched_commute = 'yes', mapper='no', moves='no', maptiebreak='random', initial_placement='no', output_dir_name='compiler_output', measurement=True, log_level='LOG_NOTHING'): - output_dir = output_dir_name - ql.initialize() - ql.set_option('output_dir', output_dir) - - ql.set_option('log_level', log_level) - ql.set_option('use_default_gates', 'no') - - ql.set_option('mapper', mapper) - - ql.set_option('write_qasm_files', 'yes') - ql.set_option('write_report_files', 'yes') - - platform = ql.Platform('mctests', 'test_multi_core_4x4_full.json') - num_circuits = 1 - num_qubits = 32 - p = ql.Program('grover_q32_1', platform, num_qubits) - k = ql.Kernel('grover_q32_1', platform, num_qubits) - k.gate('x', (16,)) - k.gate('x', (0,)) - k.gate('ym90', (0,)) - k.gate('x', (1,)) - k.gate('ym90', (1,)) - k.gate('x', (2,)) - k.gate('ym90', (2,)) - k.gate('x', (3,)) - k.gate('ym90', (3,)) - k.gate('x', (4,)) - k.gate('ym90', (4,)) - k.gate('x', (5,)) - k.gate('ym90', (5,)) - k.gate('x', (6,)) - k.gate('ym90', (6,)) - k.gate('x', (7,)) - k.gate('ym90', (7,)) - k.gate('x', (8,)) - k.gate('ym90', (8,)) - k.gate('x', (9,)) - k.gate('ym90', (9,)) - k.gate('x', (10,)) - k.gate('ym90', (10,)) - k.gate('x', (11,)) - k.gate('ym90', (11,)) - k.gate('x', (12,)) - k.gate('ym90', (12,)) - k.gate('x', (13,)) - k.gate('ym90', (13,)) - k.gate('x', (14,)) - k.gate('ym90', (14,)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - k.gate('x', (16,)) - k.gate('ym90', (16,)) - k.gate('x', (0,)) - k.gate('x', (1,)) - k.gate('x', (2,)) - k.gate('x', (3,)) - k.gate('x', (4,)) - k.gate('x', (5,)) - k.gate('x', (6,)) - k.gate('x', (7,)) - k.gate('x', (8,)) - k.gate('x', (9,)) - k.gate('x', (10,)) - k.gate('x', (11,)) - k.gate('x', (12,)) - k.gate('x', (13,)) - k.gate('x', (14,)) - k.gate('x', (15,)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (1,)) - k.gate('t', (17,)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (0, 1)) - k.gate('tdag', (1,)) - k.gate('t', (0,)) - k.gate('cnot', (0, 1)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (17,)) - k.gate('t', (18,)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (2, 17)) - k.gate('tdag', (17,)) - k.gate('t', (2,)) - k.gate('cnot', (2, 17)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (18,)) - k.gate('t', (19,)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (3, 18)) - k.gate('tdag', (18,)) - k.gate('t', (3,)) - k.gate('cnot', (3, 18)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (19,)) - k.gate('t', (20,)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (4, 19)) - k.gate('tdag', (19,)) - k.gate('t', (4,)) - k.gate('cnot', (4, 19)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (20,)) - k.gate('t', (21,)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (5, 20)) - k.gate('tdag', (20,)) - k.gate('t', (5,)) - k.gate('cnot', (5, 20)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (21,)) - k.gate('t', (22,)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (6, 21)) - k.gate('tdag', (21,)) - k.gate('t', (6,)) - k.gate('cnot', (6, 21)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (22,)) - k.gate('t', (23,)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (7, 22)) - k.gate('tdag', (22,)) - k.gate('t', (7,)) - k.gate('cnot', (7, 22)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (23,)) - k.gate('t', (24,)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (8, 23)) - k.gate('tdag', (23,)) - k.gate('t', (8,)) - k.gate('cnot', (8, 23)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (24,)) - k.gate('t', (25,)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (9, 24)) - k.gate('tdag', (24,)) - k.gate('t', (9,)) - k.gate('cnot', (9, 24)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (25,)) - k.gate('t', (26,)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (10, 25)) - k.gate('tdag', (25,)) - k.gate('t', (10,)) - k.gate('cnot', (10, 25)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (26,)) - k.gate('t', (27,)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (11, 26)) - k.gate('tdag', (26,)) - k.gate('t', (11,)) - k.gate('cnot', (11, 26)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (27,)) - k.gate('t', (28,)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (12, 27)) - k.gate('tdag', (27,)) - k.gate('t', (12,)) - k.gate('cnot', (12, 27)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (28,)) - k.gate('t', (29,)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (13, 28)) - k.gate('tdag', (28,)) - k.gate('t', (13,)) - k.gate('cnot', (13, 28)) - k.gate('x', (30,)) - k.gate('ym90', (30,)) - k.gate('cnot', (29, 30)) - k.gate('tdag', (30,)) - k.gate('cnot', (14, 30)) - k.gate('t', (30,)) - k.gate('cnot', (29, 30)) - k.gate('tdag', (30,)) - k.gate('cnot', (14, 30)) - k.gate('t', (29,)) - k.gate('t', (30,)) - k.gate('x', (30,)) - k.gate('ym90', (30,)) - k.gate('cnot', (14, 29)) - k.gate('tdag', (29,)) - k.gate('t', (14,)) - k.gate('cnot', (14, 29)) - k.gate('x', (16,)) - k.gate('ym90', (16,)) - k.gate('cnot', (15, 16)) - k.gate('tdag', (16,)) - k.gate('cnot', (30, 16)) - k.gate('t', (16,)) - k.gate('cnot', (15, 16)) - k.gate('tdag', (16,)) - k.gate('cnot', (30, 16)) - k.gate('t', (15,)) - k.gate('t', (16,)) - k.gate('x', (16,)) - k.gate('ym90', (16,)) - k.gate('cnot', (30, 15)) - k.gate('tdag', (15,)) - k.gate('t', (30,)) - k.gate('cnot', (30, 15)) - k.gate('x', (30,)) - k.gate('ym90', (30,)) - k.gate('cnot', (29, 30)) - k.gate('tdag', (30,)) - k.gate('cnot', (14, 30)) - k.gate('t', (30,)) - k.gate('cnot', (29, 30)) - k.gate('tdag', (30,)) - k.gate('cnot', (14, 30)) - k.gate('t', (29,)) - k.gate('t', (30,)) - k.gate('x', (30,)) - k.gate('ym90', (30,)) - k.gate('cnot', (14, 29)) - k.gate('tdag', (29,)) - k.gate('t', (14,)) - k.gate('cnot', (14, 29)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (28,)) - k.gate('t', (29,)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (13, 28)) - k.gate('tdag', (28,)) - k.gate('t', (13,)) - k.gate('cnot', (13, 28)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (27,)) - k.gate('t', (28,)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (12, 27)) - k.gate('tdag', (27,)) - k.gate('t', (12,)) - k.gate('cnot', (12, 27)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (26,)) - k.gate('t', (27,)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (11, 26)) - k.gate('tdag', (26,)) - k.gate('t', (11,)) - k.gate('cnot', (11, 26)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (25,)) - k.gate('t', (26,)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (10, 25)) - k.gate('tdag', (25,)) - k.gate('t', (10,)) - k.gate('cnot', (10, 25)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (24,)) - k.gate('t', (25,)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (9, 24)) - k.gate('tdag', (24,)) - k.gate('t', (9,)) - k.gate('cnot', (9, 24)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (23,)) - k.gate('t', (24,)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (8, 23)) - k.gate('tdag', (23,)) - k.gate('t', (8,)) - k.gate('cnot', (8, 23)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (22,)) - k.gate('t', (23,)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (7, 22)) - k.gate('tdag', (22,)) - k.gate('t', (7,)) - k.gate('cnot', (7, 22)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (21,)) - k.gate('t', (22,)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (6, 21)) - k.gate('tdag', (21,)) - k.gate('t', (6,)) - k.gate('cnot', (6, 21)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (20,)) - k.gate('t', (21,)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (5, 20)) - k.gate('tdag', (20,)) - k.gate('t', (5,)) - k.gate('cnot', (5, 20)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (19,)) - k.gate('t', (20,)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (4, 19)) - k.gate('tdag', (19,)) - k.gate('t', (4,)) - k.gate('cnot', (4, 19)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (18,)) - k.gate('t', (19,)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (3, 18)) - k.gate('tdag', (18,)) - k.gate('t', (3,)) - k.gate('cnot', (3, 18)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (17,)) - k.gate('t', (18,)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (2, 17)) - k.gate('tdag', (17,)) - k.gate('t', (2,)) - k.gate('cnot', (2, 17)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (1,)) - k.gate('t', (17,)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (0, 1)) - k.gate('tdag', (1,)) - k.gate('t', (0,)) - k.gate('cnot', (0, 1)) - k.gate('x', (0,)) - k.gate('x', (1,)) - k.gate('x', (2,)) - k.gate('x', (3,)) - k.gate('x', (4,)) - k.gate('x', (5,)) - k.gate('x', (6,)) - k.gate('x', (7,)) - k.gate('x', (8,)) - k.gate('x', (9,)) - k.gate('x', (10,)) - k.gate('x', (11,)) - k.gate('x', (12,)) - k.gate('x', (13,)) - k.gate('x', (14,)) - k.gate('x', (15,)) - k.gate('x', (0,)) - k.gate('ym90', (0,)) - k.gate('x', (1,)) - k.gate('ym90', (1,)) - k.gate('x', (2,)) - k.gate('ym90', (2,)) - k.gate('x', (3,)) - k.gate('ym90', (3,)) - k.gate('x', (4,)) - k.gate('ym90', (4,)) - k.gate('x', (5,)) - k.gate('ym90', (5,)) - k.gate('x', (6,)) - k.gate('ym90', (6,)) - k.gate('x', (7,)) - k.gate('ym90', (7,)) - k.gate('x', (8,)) - k.gate('ym90', (8,)) - k.gate('x', (9,)) - k.gate('ym90', (9,)) - k.gate('x', (10,)) - k.gate('ym90', (10,)) - k.gate('x', (11,)) - k.gate('ym90', (11,)) - k.gate('x', (12,)) - k.gate('ym90', (12,)) - k.gate('x', (13,)) - k.gate('ym90', (13,)) - k.gate('x', (14,)) - k.gate('ym90', (14,)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - k.gate('x', (0,)) - k.gate('x', (1,)) - k.gate('x', (2,)) - k.gate('x', (3,)) - k.gate('x', (4,)) - k.gate('x', (5,)) - k.gate('x', (6,)) - k.gate('x', (7,)) - k.gate('x', (8,)) - k.gate('x', (9,)) - k.gate('x', (10,)) - k.gate('x', (11,)) - k.gate('x', (12,)) - k.gate('x', (13,)) - k.gate('x', (14,)) - k.gate('x', (15,)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (1,)) - k.gate('t', (17,)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (0, 1)) - k.gate('tdag', (1,)) - k.gate('t', (0,)) - k.gate('cnot', (0, 1)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (17,)) - k.gate('t', (18,)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (2, 17)) - k.gate('tdag', (17,)) - k.gate('t', (2,)) - k.gate('cnot', (2, 17)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (18,)) - k.gate('t', (19,)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (3, 18)) - k.gate('tdag', (18,)) - k.gate('t', (3,)) - k.gate('cnot', (3, 18)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (19,)) - k.gate('t', (20,)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (4, 19)) - k.gate('tdag', (19,)) - k.gate('t', (4,)) - k.gate('cnot', (4, 19)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (20,)) - k.gate('t', (21,)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (5, 20)) - k.gate('tdag', (20,)) - k.gate('t', (5,)) - k.gate('cnot', (5, 20)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (21,)) - k.gate('t', (22,)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (6, 21)) - k.gate('tdag', (21,)) - k.gate('t', (6,)) - k.gate('cnot', (6, 21)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (22,)) - k.gate('t', (23,)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (7, 22)) - k.gate('tdag', (22,)) - k.gate('t', (7,)) - k.gate('cnot', (7, 22)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (23,)) - k.gate('t', (24,)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (8, 23)) - k.gate('tdag', (23,)) - k.gate('t', (8,)) - k.gate('cnot', (8, 23)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (24,)) - k.gate('t', (25,)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (9, 24)) - k.gate('tdag', (24,)) - k.gate('t', (9,)) - k.gate('cnot', (9, 24)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (25,)) - k.gate('t', (26,)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (10, 25)) - k.gate('tdag', (25,)) - k.gate('t', (10,)) - k.gate('cnot', (10, 25)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (26,)) - k.gate('t', (27,)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (11, 26)) - k.gate('tdag', (26,)) - k.gate('t', (11,)) - k.gate('cnot', (11, 26)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (27,)) - k.gate('t', (28,)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (12, 27)) - k.gate('tdag', (27,)) - k.gate('t', (12,)) - k.gate('cnot', (12, 27)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (28,)) - k.gate('t', (29,)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (13, 28)) - k.gate('tdag', (28,)) - k.gate('t', (13,)) - k.gate('cnot', (13, 28)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - k.gate('cnot', (14, 15)) - k.gate('tdag', (15,)) - k.gate('cnot', (29, 15)) - k.gate('t', (15,)) - k.gate('cnot', (14, 15)) - k.gate('tdag', (15,)) - k.gate('cnot', (29, 15)) - k.gate('t', (14,)) - k.gate('t', (15,)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - k.gate('cnot', (29, 14)) - k.gate('tdag', (14,)) - k.gate('t', (29,)) - k.gate('cnot', (29, 14)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (29,)) - k.gate('cnot', (28, 29)) - k.gate('tdag', (29,)) - k.gate('cnot', (13, 29)) - k.gate('t', (28,)) - k.gate('t', (29,)) - k.gate('x', (29,)) - k.gate('ym90', (29,)) - k.gate('cnot', (13, 28)) - k.gate('tdag', (28,)) - k.gate('t', (13,)) - k.gate('cnot', (13, 28)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (28,)) - k.gate('cnot', (27, 28)) - k.gate('tdag', (28,)) - k.gate('cnot', (12, 28)) - k.gate('t', (27,)) - k.gate('t', (28,)) - k.gate('x', (28,)) - k.gate('ym90', (28,)) - k.gate('cnot', (12, 27)) - k.gate('tdag', (27,)) - k.gate('t', (12,)) - k.gate('cnot', (12, 27)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (27,)) - k.gate('cnot', (26, 27)) - k.gate('tdag', (27,)) - k.gate('cnot', (11, 27)) - k.gate('t', (26,)) - k.gate('t', (27,)) - k.gate('x', (27,)) - k.gate('ym90', (27,)) - k.gate('cnot', (11, 26)) - k.gate('tdag', (26,)) - k.gate('t', (11,)) - k.gate('cnot', (11, 26)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (26,)) - k.gate('cnot', (25, 26)) - k.gate('tdag', (26,)) - k.gate('cnot', (10, 26)) - k.gate('t', (25,)) - k.gate('t', (26,)) - k.gate('x', (26,)) - k.gate('ym90', (26,)) - k.gate('cnot', (10, 25)) - k.gate('tdag', (25,)) - k.gate('t', (10,)) - k.gate('cnot', (10, 25)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (25,)) - k.gate('cnot', (24, 25)) - k.gate('tdag', (25,)) - k.gate('cnot', (9, 25)) - k.gate('t', (24,)) - k.gate('t', (25,)) - k.gate('x', (25,)) - k.gate('ym90', (25,)) - k.gate('cnot', (9, 24)) - k.gate('tdag', (24,)) - k.gate('t', (9,)) - k.gate('cnot', (9, 24)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (24,)) - k.gate('cnot', (23, 24)) - k.gate('tdag', (24,)) - k.gate('cnot', (8, 24)) - k.gate('t', (23,)) - k.gate('t', (24,)) - k.gate('x', (24,)) - k.gate('ym90', (24,)) - k.gate('cnot', (8, 23)) - k.gate('tdag', (23,)) - k.gate('t', (8,)) - k.gate('cnot', (8, 23)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (23,)) - k.gate('cnot', (22, 23)) - k.gate('tdag', (23,)) - k.gate('cnot', (7, 23)) - k.gate('t', (22,)) - k.gate('t', (23,)) - k.gate('x', (23,)) - k.gate('ym90', (23,)) - k.gate('cnot', (7, 22)) - k.gate('tdag', (22,)) - k.gate('t', (7,)) - k.gate('cnot', (7, 22)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (22,)) - k.gate('cnot', (21, 22)) - k.gate('tdag', (22,)) - k.gate('cnot', (6, 22)) - k.gate('t', (21,)) - k.gate('t', (22,)) - k.gate('x', (22,)) - k.gate('ym90', (22,)) - k.gate('cnot', (6, 21)) - k.gate('tdag', (21,)) - k.gate('t', (6,)) - k.gate('cnot', (6, 21)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (21,)) - k.gate('cnot', (20, 21)) - k.gate('tdag', (21,)) - k.gate('cnot', (5, 21)) - k.gate('t', (20,)) - k.gate('t', (21,)) - k.gate('x', (21,)) - k.gate('ym90', (21,)) - k.gate('cnot', (5, 20)) - k.gate('tdag', (20,)) - k.gate('t', (5,)) - k.gate('cnot', (5, 20)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (20,)) - k.gate('cnot', (19, 20)) - k.gate('tdag', (20,)) - k.gate('cnot', (4, 20)) - k.gate('t', (19,)) - k.gate('t', (20,)) - k.gate('x', (20,)) - k.gate('ym90', (20,)) - k.gate('cnot', (4, 19)) - k.gate('tdag', (19,)) - k.gate('t', (4,)) - k.gate('cnot', (4, 19)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (19,)) - k.gate('cnot', (18, 19)) - k.gate('tdag', (19,)) - k.gate('cnot', (3, 19)) - k.gate('t', (18,)) - k.gate('t', (19,)) - k.gate('x', (19,)) - k.gate('ym90', (19,)) - k.gate('cnot', (3, 18)) - k.gate('tdag', (18,)) - k.gate('t', (3,)) - k.gate('cnot', (3, 18)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (18,)) - k.gate('cnot', (17, 18)) - k.gate('tdag', (18,)) - k.gate('cnot', (2, 18)) - k.gate('t', (17,)) - k.gate('t', (18,)) - k.gate('x', (18,)) - k.gate('ym90', (18,)) - k.gate('cnot', (2, 17)) - k.gate('tdag', (17,)) - k.gate('t', (2,)) - k.gate('cnot', (2, 17)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (17,)) - k.gate('cnot', (1, 17)) - k.gate('tdag', (17,)) - k.gate('cnot', (0, 17)) - k.gate('t', (1,)) - k.gate('t', (17,)) - k.gate('x', (17,)) - k.gate('ym90', (17,)) - k.gate('cnot', (0, 1)) - k.gate('tdag', (1,)) - k.gate('t', (0,)) - k.gate('cnot', (0, 1)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - k.gate('x', (0,)) - k.gate('x', (1,)) - k.gate('x', (2,)) - k.gate('x', (3,)) - k.gate('x', (4,)) - k.gate('x', (5,)) - k.gate('x', (6,)) - k.gate('x', (7,)) - k.gate('x', (8,)) - k.gate('x', (9,)) - k.gate('x', (10,)) - k.gate('x', (11,)) - k.gate('x', (12,)) - k.gate('x', (13,)) - k.gate('x', (14,)) - k.gate('x', (15,)) - k.gate('x', (0,)) - k.gate('ym90', (0,)) - k.gate('x', (1,)) - k.gate('ym90', (1,)) - k.gate('x', (2,)) - k.gate('ym90', (2,)) - k.gate('x', (3,)) - k.gate('ym90', (3,)) - k.gate('x', (4,)) - k.gate('ym90', (4,)) - k.gate('x', (5,)) - k.gate('ym90', (5,)) - k.gate('x', (6,)) - k.gate('ym90', (6,)) - k.gate('x', (7,)) - k.gate('ym90', (7,)) - k.gate('x', (8,)) - k.gate('ym90', (8,)) - k.gate('x', (9,)) - k.gate('ym90', (9,)) - k.gate('x', (10,)) - k.gate('ym90', (10,)) - k.gate('x', (11,)) - k.gate('ym90', (11,)) - k.gate('x', (12,)) - k.gate('ym90', (12,)) - k.gate('x', (13,)) - k.gate('ym90', (13,)) - k.gate('x', (14,)) - k.gate('ym90', (14,)) - k.gate('x', (15,)) - k.gate('ym90', (15,)) - - if measurement: - for q in range(num_qubits): - k.gate('measure', [q]) - - p.add_kernel(k) - p.compile() - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='OpenQL compilation of a Quantum Algorithm') - parser.add_argument('--new_scheduler', nargs='?', default='yes', help='Scheduler defined by Hans') - parser.add_argument('--scheduler', nargs='?', default='ASAP', help='Scheduler specification (ASAP (default), ALAP, ...)') - parser.add_argument('--uniform_sched', nargs='?', default='no', help='Uniform shceduler actication (yes or no)') - parser.add_argument('--sched_commute', nargs='?', default='yes', help='Permits two-qubit gates to be commutable') - parser.add_argument('--mapper', nargs='?', default='minextend', help='Mapper specification (base, minextend, minextendrc)') - parser.add_argument('--moves', nargs='?', default='no', help='Let the use of moves') - parser.add_argument('--maptiebreak', nargs='?', default='random', help='') - parser.add_argument('--initial_placement', nargs='?', default='no', help='Initial placement specification (yes or no)') - parser.add_argument('--out_dir', nargs='?', default='compiler_output', help='Folder name to store the compilation') - parser.add_argument('--measurement', nargs='?', default=True, help='Add measurement to all the qubits in the end of the algorithm') - args = parser.parse_args() - try: - circuit(args.new_scheduler, args.scheduler, args.uniform_sched, args.sched_commute, args.mapper, args.moves, args.maptiebreak, args.initial_placement, args.out_dir) - except TypeError: - print('\nCompiled, but some gate is not defined in the configuration file. \nThe gate will be invoked like it is.') - raise \ No newline at end of file diff --git a/examples/cpp-standalone-example/test_multi_core_4x4_full.json b/examples/cpp-standalone-example/test_multi_core_4x4_full.json deleted file mode 100644 index 2d5712d6c..000000000 --- a/examples/cpp-standalone-example/test_multi_core_4x4_full.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "eqasm_compiler" : "cc_light_compiler", - - "hardware_settings": { - "qubit_number": 32, - "cycle_time" : 20, - "mw_mw_buffer": 0, - "mw_flux_buffer": 0, - "mw_readout_buffer": 0, - "flux_mw_buffer": 0, - "flux_flux_buffer": 0, - "flux_readout_buffer": 0, - "readout_mw_buffer": 0, - "readout_flux_buffer": 0, - "readout_readout_buffer": 0 - }, - - "qubit_attributes": - { - "relaxation_times": - { - "0" : [3000, 1500], - "1" : [3000, 1500], - "2" : [3000, 1500], - "3" : [3000, 1500], - "4" : [3000, 1500] - } - }, - - "topology" : - { - "number_of_cores": 4, - "connectivity": "full", - "form": "irregular", - "comm_qubits_per_core": 4 - }, - - "resources": - { - "qubits": - { - "description": "Each qubit can be used by only one gate at a time. There are 'count' qubits.", - "count": 16 - }, - "channels": - { - "description": "Each inter-core gate uses one channel in each core. There are 'count' such channels per core.", - "count": 4 - } - }, - - "instructions": { - "prepx": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "prepx" - }, - "prepz": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "prepz" - }, - "measx": { - "duration": 340, - "latency": 0, - "type": "readout", - "cc_light_instr": "measx" - }, - "measz": { - "duration": 300, - "latency": 0, - "type": "readout", - "cc_light_instr": "measz" - }, - "measure": { - "duration": 300, - "latency": 0, - "type": "readout", - "cc_light_instr": "measz" - }, - "i": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "i" - }, - "x": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "x" - }, - "y": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "y" - }, - "z": { - "duration": 40, - "latency": 0, - "type": "mw", - "cc_light_instr": "z" - }, - "rx": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "rx" - }, - "ry": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "ry" - }, - "rz": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "rz" - }, - "h": { - "duration": 40, - "latency": 0, - "type": "mw", - "cc_light_instr": "h" - }, - "s": { - "duration": 60, - "latency": 0, - "type": "mw", - "cc_light_instr": "s" - }, - "sdag": { - "duration": 60, - "latency": 0, - "type": "mw", - "cc_light_instr": "sdag" - }, - "x90": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "x90" - }, - "xm90": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "xm90" - }, - "y90": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "y90" - }, - "ym90": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "ym90" - }, - "t": { - "duration": 60, - "latency": 0, - "type": "mw", - "cc_light_instr": "t" - }, - "tdag": { - "duration": 60, - "latency": 0, - "type": "mw", - "cc_light_instr": "tdag" - }, - "x45": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "x45" - }, - "xm45": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "xm45" - }, - "y45": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "y45" - }, - "ym45": { - "duration": 20, - "latency": 0, - "type": "mw", - "cc_light_instr": "ym45" - }, - "cz": { - "duration": 60, - "latency": 0, - "type": "flux", - "cc_light_instr": "cz" - }, - "cnot": { - "duration": 100, - "latency": 0, - "type": "flux", - "cc_light_instr": "cnot" - }, - "swap": { - "duration": 260, - "latency": 0, - "type": "flux", - "cc_light_instr": "swap" - }, - "move": { - "duration": 180, - "latency": 0, - "type": "flux", - "cc_light_instr": "move" - }, - "teleportswap": { - "duration": 1000, - "latency": 0, - "type": "extern", - "cc_light_instr": "teleportswap" - }, - "teleportmove": { - "duration": 600, - "latency": 0, - "type": "extern", - "cc_light_instr": "teleportmove" - }, - "preswap": { - "duration": 100, - "latency": 0, - "type": "mw", - "cc_light_instr": "preswap" - }, - "premove": { - "duration": 100, - "latency": 0, - "type": "mw", - "cc_light_instr": "premove" - }, - "postswap": { - "duration": 100, - "latency": 0, - "type": "mw", - "cc_light_instr": "postswap" - }, - "postmove": { - "duration": 100, - "latency": 0, - "type": "mw", - "cc_light_instr": "postmove" - } - }, - - "gate_decomposition": { - "tswap_real %0,%1": ["preswap %0","teleportswap %0,%1","postswap %1"], - "tmove_real %0,%1": ["premove %0","teleportmove %0,%1","postmove %1"], - "rx180 %0" : ["x %0"], - "ry180 %0" : ["y %0"], - "rx90 %0" : ["x90 %0"], - "ry90 %0" : ["y90 %0"], - "mrx90 %0" : ["xm90 %0"], - "mry90 %0" : ["ym90 %0"], - "rx45 %0" : ["x45 %0"], - "ry45 %0" : ["y45 %0"], - "mrx45 %0" : ["xm45 %0"], - "mry45 %0" : ["ym45 %0"] - } -} diff --git a/src/ql/com/topology.cc b/src/ql/com/topology.cc index f3b3e4c88..1c7b90596 100644 --- a/src/ql/com/topology.cc +++ b/src/ql/com/topology.cc @@ -714,10 +714,11 @@ utils::UInt Topology::get_min_hops(Qubit source, Qubit target) const { utils::UInt d = get_distance(source, target); utils::UInt cd = get_core_distance(source, target); QL_ASSERT(cd <= d); - if (connectivity == GridConnectivity::FULL || cd != d){ - return d; - } else { + + if (cd == d) { return d+2; + } else { + return d; } } diff --git a/src/ql/pass/map/qubits/map/detail/mapper.cc b/src/ql/pass/map/qubits/map/detail/mapper.cc index 88a1e5d44..135efc10f 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.cc +++ b/src/ql/pass/map/qubits/map/detail/mapper.cc @@ -562,8 +562,7 @@ Bool Mapper::map_mappable_gates( UInt partitions = platform->topology->get_num_cores(); // Check if qubits are NN and they are in the same partition - if (d == 1 && (partitions == 1 || src/partitions == tgt/partitions)) { - + if (d == 1) { // Just one hop, so gate is already nearest-neighbor and can // be mapped. QL_DOUT(". NN gate, to be mapped: " << gate->qasm() << " in real (q" << src << ",q" << tgt << ")"); diff --git a/tests/golden/test_rOEE_last.qasm b/tests/golden/test_rOEE_last.qasm new file mode 100644 index 000000000..fa45399d2 --- /dev/null +++ b/tests/golden/test_rOEE_last.qasm @@ -0,0 +1,109 @@ +# Generated by OpenQL 0.10.5 for program test_rOEE +version 1.2 + +pragma @ql.name("test_rOEE") + + +.kernel_rOEE + { # start at cycle 0 + x q[0] + x q[1] + x q[4] + x q[5] + } + { # start at cycle 1 + cnot q[0], q[1] + cnot q[4], q[5] + } + skip 3 + { # start at cycle 5 + x q[8] + x q[9] + } + { # start at cycle 6 + cnot q[8], q[9] + cnot q[0], q[4] + cnot q[1], q[5] + cnot q[2], q[6] + cnot q[3], q[7] + } + skip 3 + { # start at cycle 10 + x q[12] + x q[13] + } + { # start at cycle 11 + cnot q[12], q[13] + cnot q[0], q[8] + cnot q[1], q[9] + cnot q[2], q[10] + cnot q[3], q[11] + } + skip 4 + { # start at cycle 16 + cnot q[0], q[12] + cnot q[1], q[13] + cnot q[2], q[14] + cnot q[3], q[15] + } + skip 4 + { # start at cycle 21 + cnot q[4], q[0] + cnot q[5], q[1] + cnot q[6], q[2] + cnot q[7], q[3] + } + skip 4 + { # start at cycle 26 + cnot q[4], q[8] + cnot q[5], q[9] + cnot q[6], q[10] + cnot q[7], q[11] + } + skip 4 + { # start at cycle 31 + cnot q[4], q[12] + cnot q[5], q[13] + cnot q[6], q[14] + cnot q[7], q[15] + cnot q[8], q[0] + cnot q[9], q[1] + cnot q[10], q[2] + cnot q[11], q[3] + } + skip 4 + { # start at cycle 36 + cnot q[8], q[4] + cnot q[9], q[5] + cnot q[10], q[6] + cnot q[11], q[7] + } + skip 4 + { # start at cycle 41 + cnot q[8], q[12] + cnot q[9], q[13] + cnot q[10], q[14] + cnot q[11], q[15] + } + skip 4 + { # start at cycle 46 + cnot q[12], q[0] + cnot q[13], q[1] + cnot q[14], q[2] + cnot q[15], q[3] + } + skip 4 + { # start at cycle 51 + cnot q[12], q[4] + cnot q[13], q[5] + cnot q[14], q[6] + cnot q[15], q[7] + } + skip 4 + { # start at cycle 56 + cnot q[12], q[8] + cnot q[13], q[9] + cnot q[14], q[10] + cnot q[15], q[11] + } + skip 4 diff --git a/tests/test_rOEE.py b/tests/test_rOEE.py new file mode 100644 index 000000000..4a432a7da --- /dev/null +++ b/tests/test_rOEE.py @@ -0,0 +1,51 @@ + +from openql import openql as ql +import os +import unittest +from utils import file_compare + +curdir = os.path.dirname(os.path.realpath(__file__)) +output_dir = os.path.join(curdir, 'test_output') + +class Test_rOEE(unittest.TestCase): + + def setUp(self): + ql.initialize() + ql.set_option('output_dir', output_dir) + ql.set_option('log_level', 'LOG_NOTHING') + ql.set_option('use_default_gates', 'no') + ql.set_option('optimize', 'no') + ql.set_option('generate_code', 'no') + ql.set_option('print_dot_graphs', 'no') + + ql.set_option('scheduler', 'ALAP') + ql.set_option('maprOEE', 'yes') + + def test_rOEE(self): + config = os.path.join(curdir, "test_multi_core_4x4_full.json") + platform = ql.Platform("mc4x4full", config) + num_qubits = 16 + p = ql.Program('test_rOEE', platform, num_qubits) + k = ql.Kernel('kernel_rOEE', platform, num_qubits) + for i in range(4): + k.gate("x", [4*i]) + k.gate("x", [4*i+1]) + for i in range(4): + k.gate("cnot", [4*i,4*i+1]) + for i in range(4): + for j in range(4): + if i != j: + k.gate("cnot", [4*i,4*j]) + k.gate("cnot", [4*i+1,4*j+1]) + k.gate("cnot", [4*i+2,4*j+2]) + k.gate("cnot", [4*i+3,4*j+3]) + + p.add_kernel(k) + p.compile() + + gold_fn = curdir + '/golden/' + 'test_rOEE' +'_last.qasm' + qasm_fn = os.path.join(output_dir, 'test_rOEE'+'_last.qasm') + self.assertTrue( file_compare(qasm_fn, gold_fn) ) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From 541f1cf15173af99b1c8546e15536e7c8de11116 Mon Sep 17 00:00:00 2001 From: Hopery Date: Sun, 11 Sep 2022 16:56:37 +0200 Subject: [PATCH 7/8] Add new lines and other minor details --- .gitignore | 2 +- examples/cpp-standalone-example/example.cc | 2 +- src/ql/pass/map/qubits/map/detail/mapper.cc | 2 +- tests/test_rOEE.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d5f2f6d26..25e80f7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,4 @@ docs/_templates docs/_templates /.idea -/cmake-build-* \ No newline at end of file +/cmake-build-* diff --git a/examples/cpp-standalone-example/example.cc b/examples/cpp-standalone-example/example.cc index dc2b8c123..b8113e195 100644 --- a/examples/cpp-standalone-example/example.cc +++ b/examples/cpp-standalone-example/example.cc @@ -26,4 +26,4 @@ int main(int argc, char **argv) { std::cout << "Seems good to me!" << std::endl; return 0; -} \ No newline at end of file +} diff --git a/src/ql/pass/map/qubits/map/detail/mapper.cc b/src/ql/pass/map/qubits/map/detail/mapper.cc index 135efc10f..d3fe5e793 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.cc +++ b/src/ql/pass/map/qubits/map/detail/mapper.cc @@ -561,8 +561,8 @@ Bool Mapper::map_mappable_gates( UInt d = platform->topology->get_min_hops(src, tgt); UInt partitions = platform->topology->get_num_cores(); - // Check if qubits are NN and they are in the same partition if (d == 1) { + // Just one hop, so gate is already nearest-neighbor and can // be mapped. QL_DOUT(". NN gate, to be mapped: " << gate->qasm() << " in real (q" << src << ",q" << tgt << ")"); diff --git a/tests/test_rOEE.py b/tests/test_rOEE.py index 4a432a7da..435fb7e63 100644 --- a/tests/test_rOEE.py +++ b/tests/test_rOEE.py @@ -48,4 +48,4 @@ def test_rOEE(self): self.assertTrue( file_compare(qasm_fn, gold_fn) ) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() From a64003c1be07ff874c8a55e22de9c9faf8c1bfa1 Mon Sep 17 00:00:00 2001 From: Hopery Date: Sun, 11 Sep 2022 16:58:32 +0200 Subject: [PATCH 8/8] Add new lines and other minor details --- src/ql/pass/map/qubits/map/detail/mapper.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ql/pass/map/qubits/map/detail/mapper.cc b/src/ql/pass/map/qubits/map/detail/mapper.cc index d3fe5e793..4be1c5207 100644 --- a/src/ql/pass/map/qubits/map/detail/mapper.cc +++ b/src/ql/pass/map/qubits/map/detail/mapper.cc @@ -562,7 +562,7 @@ Bool Mapper::map_mappable_gates( UInt partitions = platform->topology->get_num_cores(); if (d == 1) { - + // Just one hop, so gate is already nearest-neighbor and can // be mapped. QL_DOUT(". NN gate, to be mapped: " << gate->qasm() << " in real (q" << src << ",q" << tgt << ")");