3#if defined(__linux__) && defined(INCLUDED_BY_FACTORY)
5namespace Simulators::Private {
7class DistributedGpuSimulatorBase :
public State {
10 const Eigen::Matrix2cd& gate)
override {
12 this->Native().ApplyOneQubitMatrixWithLayout(
13 q,
reinterpret_cast<const double*
>(gate.data()), 1);
14 this->NotifyObservers({q});
17 const Eigen::Matrix4cd& gate)
override {
20 this->Native().ApplyTwoQubitMatrixWithLayout(
21 q0, q1,
reinterpret_cast<const double*
>(gate.data()), 1);
22 this->NotifyObservers({q0, q1});
25 this->QubitIndex(qubit);
26 this->Native().ApplyP(qubit, lambda);
27 this->NotifyObservers({qubit});
30 this->QubitIndex(qubit);
31 this->Native().ApplyX(qubit);
32 this->NotifyObservers({qubit});
35 this->QubitIndex(qubit);
36 this->Native().ApplyY(qubit);
37 this->NotifyObservers({qubit});
40 this->QubitIndex(qubit);
41 this->Native().ApplyZ(qubit);
42 this->NotifyObservers({qubit});
45 this->QubitIndex(qubit);
46 this->Native().ApplyH(qubit);
47 this->NotifyObservers({qubit});
50 this->QubitIndex(qubit);
51 this->Native().ApplyS(qubit);
52 this->NotifyObservers({qubit});
55 this->QubitIndex(qubit);
56 this->Native().ApplySDG(qubit);
57 this->NotifyObservers({qubit});
60 this->QubitIndex(qubit);
61 this->Native().ApplyT(qubit);
62 this->NotifyObservers({qubit});
65 this->QubitIndex(qubit);
66 this->Native().ApplyTDG(qubit);
67 this->NotifyObservers({qubit});
70 this->QubitIndex(qubit);
71 this->Native().ApplySX(qubit);
72 this->NotifyObservers({qubit});
75 this->QubitIndex(qubit);
76 this->Native().ApplySXDG(qubit);
77 this->NotifyObservers({qubit});
80 this->QubitIndex(qubit);
81 this->Native().ApplyK(qubit);
82 this->NotifyObservers({qubit});
85 this->QubitIndex(qubit);
86 this->Native().ApplyRx(qubit, theta);
87 this->NotifyObservers({qubit});
90 this->QubitIndex(qubit);
91 this->Native().ApplyRy(qubit, theta);
92 this->NotifyObservers({qubit});
95 this->QubitIndex(qubit);
96 this->Native().ApplyRz(qubit, theta);
97 this->NotifyObservers({qubit});
100 double gamma)
override {
101 this->QubitIndex(qubit);
102 this->Native().ApplyU(qubit, theta, phi, lambda, gamma);
103 this->NotifyObservers({qubit});
106 this->QubitIndex(ctrl_qubit);
107 this->QubitIndex(tgt_qubit);
108 this->Native().ApplyCX(ctrl_qubit, tgt_qubit);
109 this->NotifyObservers({ctrl_qubit, tgt_qubit});
112 this->QubitIndex(ctrl_qubit);
113 this->QubitIndex(tgt_qubit);
114 this->Native().ApplyCY(ctrl_qubit, tgt_qubit);
115 this->NotifyObservers({ctrl_qubit, tgt_qubit});
118 this->QubitIndex(ctrl_qubit);
119 this->QubitIndex(tgt_qubit);
120 this->Native().ApplyCZ(ctrl_qubit, tgt_qubit);
121 this->NotifyObservers({ctrl_qubit, tgt_qubit});
124 double lambda)
override {
125 this->QubitIndex(ctrl_qubit);
126 this->QubitIndex(tgt_qubit);
127 this->Native().ApplyCP(ctrl_qubit, tgt_qubit, lambda);
128 this->NotifyObservers({ctrl_qubit, tgt_qubit});
131 double theta)
override {
132 this->QubitIndex(ctrl_qubit);
133 this->QubitIndex(tgt_qubit);
134 this->Native().ApplyCRx(ctrl_qubit, tgt_qubit, theta);
135 this->NotifyObservers({ctrl_qubit, tgt_qubit});
138 double theta)
override {
139 this->QubitIndex(ctrl_qubit);
140 this->QubitIndex(tgt_qubit);
141 this->Native().ApplyCRy(ctrl_qubit, tgt_qubit, theta);
142 this->NotifyObservers({ctrl_qubit, tgt_qubit});
145 double theta)
override {
146 this->QubitIndex(ctrl_qubit);
147 this->QubitIndex(tgt_qubit);
148 this->Native().ApplyCRz(ctrl_qubit, tgt_qubit, theta);
149 this->NotifyObservers({ctrl_qubit, tgt_qubit});
152 this->QubitIndex(ctrl_qubit);
153 this->QubitIndex(tgt_qubit);
154 this->Native().ApplyCH(ctrl_qubit, tgt_qubit);
155 this->NotifyObservers({ctrl_qubit, tgt_qubit});
158 this->QubitIndex(ctrl_qubit);
159 this->QubitIndex(tgt_qubit);
160 this->Native().ApplyCSX(ctrl_qubit, tgt_qubit);
161 this->NotifyObservers({ctrl_qubit, tgt_qubit});
165 this->QubitIndex(ctrl_qubit);
166 this->QubitIndex(tgt_qubit);
167 this->Native().ApplyCSXDG(ctrl_qubit, tgt_qubit);
168 this->NotifyObservers({ctrl_qubit, tgt_qubit});
171 this->QubitIndex(qubit0);
172 this->QubitIndex(qubit1);
173 this->Native().ApplySwap(qubit0, qubit1);
174 this->NotifyObservers({qubit0, qubit1});
178 this->QubitIndex(qubit0);
179 this->QubitIndex(qubit1);
180 this->QubitIndex(qubit2);
181 this->Native().ApplyCCX(qubit0, qubit1, qubit2);
182 this->NotifyObservers({qubit0, qubit1, qubit2});
186 this->QubitIndex(ctrl_qubit);
187 this->QubitIndex(qubit0);
188 this->QubitIndex(qubit1);
189 this->Native().ApplyCSwap(ctrl_qubit, qubit0, qubit1);
190 this->NotifyObservers({ctrl_qubit, qubit0, qubit1});
193 double theta,
double phi,
double lambda,
double gamma)
override {
194 this->QubitIndex(ctrl_qubit);
195 this->QubitIndex(tgt_qubit);
196 this->Native().ApplyCU(ctrl_qubit, tgt_qubit, theta, phi, lambda, gamma);
197 this->NotifyObservers({ctrl_qubit, tgt_qubit});
199 void ApplyNop()
override { this->NotifyObservers({}); }
200 std::unique_ptr<ISimulator> Clone()
override {
201 auto copy = std::make_unique<DistributedGpuSimulatorBase<State>>();
202 copy->configuration = this->configuration;
203 copy->nrQubits = this->nrQubits;
204 if (this->state) copy->state = this->state->Clone();
208using DistributedGpuSimulator =
209 DistributedGpuSimulatorBase<DistributedGpuState>;
210using DistributedMpiGpuSimulator =
211 DistributedGpuSimulatorBase<DistributedMpiGpuState>;
int ApplyK(void *sim, int qubit)
int ApplyRx(void *sim, int qubit, double theta)
int ApplyX(void *sim, int qubit)
int ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
int ApplyCRy(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyTDG(void *sim, int qubit)
int ApplyS(void *sim, int qubit)
int ApplyCX(void *sim, int controlQubit, int targetQubit)
int ApplyCRz(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCP(void *sim, int controlQubit, int targetQubit, double theta)
int ApplySDG(void *sim, int qubit)
int ApplyCSwap(void *sim, int controlQubit, int qubit1, int qubit2)
int ApplyCCX(void *sim, int controlQubit1, int controlQubit2, int targetQubit)
int ApplyY(void *sim, int qubit)
int ApplyZ(void *sim, int qubit)
int ApplyH(void *sim, int qubit)
int ApplyCY(void *sim, int controlQubit, int targetQubit)
int ApplyCU(void *sim, int controlQubit, int targetQubit, double theta, double phi, double lambda, double gamma)
int ApplySwap(void *sim, int qubit1, int qubit2)
int ApplyRy(void *sim, int qubit, double theta)
int ApplyP(void *sim, int qubit, double theta)
int ApplyCH(void *sim, int controlQubit, int targetQubit)
int ApplyCZ(void *sim, int controlQubit, int targetQubit)
int ApplyRz(void *sim, int qubit, double theta)
int ApplyT(void *sim, int qubit)
int ApplyCRx(void *sim, int controlQubit, int targetQubit, double theta)
uint_fast64_t qubit_t
The type of a qubit.