GCC Code Coverage Report


Directory: ./
File: Mapping/include/Mapping/MappingManager.hpp
Date: 2022-10-15 05:10:18
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%
Decisions: 0 0 -%

Line Branch Decision Exec Source
1 // Copyright 2019-2022 Cambridge Quantum Computing
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #pragma once
16
17 #include "Architecture/Architecture.hpp"
18 #include "Circuit/Circuit.hpp"
19 #include "Mapping/RoutingMethod.hpp"
20 #include "Utils/UnitID.hpp"
21
22 namespace tket {
23
24 // list of error types to throw out
25 class MappingManagerError : public std::logic_error {
26 public:
27 2 explicit MappingManagerError(const std::string& message)
28 2 : std::logic_error(message) {}
29 };
30
31 class MappingManager {
32 public:
33 /* Mapping Manager Constructor */
34 // MappingManager object defined by Architecture initialised with
35 MappingManager(const ArchitecturePtr& _architecture);
36
37 /**
38 * route_circuit
39 * Referenced Circuit modified such that all multi-qubit gates are permitted
40 * by this->architecture_ RoutingIncompability thrown if Circuit has more
41 * logical qubits than Architecture has physical qubits RoutingIncompability
42 * thrown if Circuit has a gate of OpType not in Architecture's permitted
43 * OpTypes
44 *
45 * @param circuit Circuit to be routed
46 * @param routing_methods Ranked RoutingMethod objects to use for routing
47 * segments.
48 * @param label_isolated_qubits will not label qubits without gates or only
49 * single qubit gates on them if this is set false
50 * @return True if circuit is modified
51 */
52 bool route_circuit(
53 Circuit& circuit, const std::vector<RoutingMethodPtr>& routing_methods,
54 bool label_isolated_qubits = true) const;
55
56 /**
57 * route_circuit_maps
58 * Referenced Circuit modified such that all multi-qubit gates are permitted
59 * by this->architecture_ RoutingIncompability thrown if Circuit has more
60 * logical qubits than Architecture has physical qubits RoutingIncompability
61 * thrown if Circuit has a gate of OpType not in Architecture's permitted
62 * OpTypes
63 *
64 * @param circuit Circuit to be routed
65 * @param routing_methods Ranked RoutingMethod objects to use for routing
66 * segments.
67 * @param maps For tracking placed and permuted qubits during Compilation
68 * @param label_isolated_qubits will not label qubits without gates or only
69 * single qubit gates on them if this is set false
70 *
71 * @return True if circuit is modified
72 */
73 bool route_circuit_with_maps(
74 Circuit& circuit, const std::vector<RoutingMethodPtr>& routing_methods,
75 std::shared_ptr<unit_bimaps_t> maps,
76 bool label_isolated_qubits = true) const;
77
78 private:
79 ArchitecturePtr architecture_;
80 };
81 } // namespace tket
82