16#define _CRT_SECURE_NO_WARNINGS 1
23#pragma warning(disable : 4789)
24#include "simulators/statevector/qv_avx2.cpp"
32#define INCLUDED_BY_FACTORY
44std::shared_ptr<GpuLibrary> SimulatorsFactory::gpuLibrary =
nullptr;
45std::atomic_bool SimulatorsFactory::firstTime =
true;
49 gpuLibrary = std::make_shared<GpuLibrary>();
50 if (!firstTime.exchange(
false)) gpuLibrary->SetMute(
true);
52 if (gpuLibrary->Init(
"libmaestro_gpu_simulators.so"))
61bool SimulatorsFactory::InitGpuLibraryWithMute() {
63 gpuLibrary = std::make_shared<GpuLibrary>();
65 gpuLibrary->SetMute(
true);
67 if (gpuLibrary->Init(
"libmaestro_gpu_simulators.so"))
78std::shared_ptr<QuestLibSim> SimulatorsFactory::questLibrary =
nullptr;
79std::atomic_bool SimulatorsFactory::firstTimeQuest =
true;
83 questLibrary = std::make_shared<QuestLibSim>();
84 if (!firstTimeQuest.exchange(
false)) questLibrary->SetMute(
true);
85 if (questLibrary->Init(
88#elif defined(__APPLE__)
89 "libmaestroquest.dylib"
96 questLibrary =
nullptr;
105 auto sim = std::make_shared<Private::QCSimSimulator>();
107 sim->Configure(
"method",
"matrix_product_state");
109 sim->Configure(
"method",
"stabilizer");
111 sim->Configure(
"method",
"tensor_network");
113 sim->Configure(
"method",
"pauli_propagator");
115 throw std::invalid_argument(
"Simulation Type not supported for QCSim");
121 auto sim = std::make_shared<Private::AerSimulator>();
123 sim->Configure(
"method",
"matrix_product_state");
125 sim->Configure(
"method",
"stabilizer");
127 sim->Configure(
"method",
"tensor_network");
129 sim->Configure(
"method",
"extended_stabilizer");
131 sim->Configure(
"method",
"statevector");
133 throw std::invalid_argument(
134 "Simulation Type not supported for Qiskit Aer");
139 return std::make_shared<Private::CompositeSimulator>(
143 return std::make_shared<Private::CompositeSimulator>(
147 if (gpuLibrary && gpuLibrary->IsValid() &&
152 auto sim = std::make_shared<Private::GpuSimulator>();
154 sim->Configure(
"method",
"matrix_product_state");
156 sim->Configure(
"method",
"tensor_network");
158 sim->Configure(
"method",
"pauli_propagator");
160 sim->Configure(
"method",
"statevector");
169 throw std::invalid_argument(
170 "Simulation Type not supported for Quest Simulator");
171 else if (questLibrary && questLibrary->IsValid()) {
172 return std::make_shared<Private::QuestSimulator>();
179 throw std::invalid_argument(
"Simulator Type not supported");
188 auto sim = std::make_unique<Private::QCSimSimulator>();
190 sim->Configure(
"method",
"matrix_product_state");
192 sim->Configure(
"method",
"stabilizer");
194 sim->Configure(
"method",
"tensor_network");
196 sim->Configure(
"method",
"pauli_propagator");
198 throw std::invalid_argument(
"Simulation Type not supported for QCSim");
204 auto sim = std::make_unique<Private::AerSimulator>();
206 sim->Configure(
"method",
"matrix_product_state");
208 sim->Configure(
"method",
"stabilizer");
210 sim->Configure(
"method",
"tensor_network");
212 sim->Configure(
"method",
"extended_stabilizer");
214 sim->Configure(
"method",
"statevector");
216 throw std::invalid_argument(
217 "Simulation Type not supported for Qiskit Aer");
222 return std::make_unique<Private::CompositeSimulator>(
226 return std::make_unique<Private::CompositeSimulator>(
230 if (gpuLibrary && gpuLibrary->IsValid() &&
235 auto sim = std::make_unique<Private::GpuSimulator>();
237 sim->Configure(
"method",
"matrix_product_state");
239 sim->Configure(
"method",
"tensor_network");
241 sim->Configure(
"method",
"pauli_propagator");
243 sim->Configure(
"method",
"statevector");
252 throw std::invalid_argument(
253 "Simulation Type not supported for Quest Simulator");
254 else if (questLibrary && questLibrary->IsValid()) {
255 return std::make_unique<Private::QuestSimulator>();
262 throw std::invalid_argument(
"Simulator Type not supported");
static std::shared_ptr< ISimulator > CreateSimulator(SimulatorType t=SimulatorType::kQCSim, SimulationType method=SimulationType::kMatrixProductState)
Create a quantum computing simulator.
static bool InitQuestLibrary()
static std::unique_ptr< ISimulator > CreateSimulatorUnique(SimulatorType t=SimulatorType::kQCSim, SimulationType method=SimulationType::kMatrixProductState)
Create a quantum computing simulator.
static bool InitGpuLibrary()
SimulationType
The type of simulation.
@ kExtendedStabilizer
Extended stabilizer simulation type.
@ kStatevector
statevector simulation type
@ kMatrixProductState
matrix product state simulation type
@ kStabilizer
Clifford gates simulation type.
@ kPauliPropagator
Pauli propagator simulation type.
@ kTensorNetwork
Tensor network simulation type.
SimulatorType
The type of simulator.
@ kCompositeQCSim
composite qcsim simulator type
@ kQCSim
qcsim simulator type
@ kQiskitAer
qiskit aer simulator type
@ kQuestSim
quest simulator type
@ kCompositeQiskitAer
composite qiskit aer simulator type
@ kGpuSim
gpu simulator type