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 sim->Configure(
"method",
"path_integral");
117 throw std::invalid_argument(
"Simulation Type not supported for QCSim");
123 auto sim = std::make_shared<Private::AerSimulator>();
125 sim->Configure(
"method",
"matrix_product_state");
127 sim->Configure(
"method",
"stabilizer");
129 sim->Configure(
"method",
"tensor_network");
131 sim->Configure(
"method",
"extended_stabilizer");
133 sim->Configure(
"method",
"statevector");
135 throw std::invalid_argument(
136 "Simulation Type not supported for Qiskit Aer");
141 return std::make_shared<Private::CompositeSimulator>(
145 return std::make_shared<Private::CompositeSimulator>(
149 if (gpuLibrary && gpuLibrary->IsValid() &&
154 auto sim = std::make_shared<Private::GpuSimulator>();
156 sim->Configure(
"method",
"matrix_product_state");
158 sim->Configure(
"method",
"tensor_network");
160 sim->Configure(
"method",
"pauli_propagator");
162 sim->Configure(
"method",
"statevector");
171 throw std::invalid_argument(
172 "Simulation Type not supported for Quest Simulator");
173 else if (questLibrary && questLibrary->IsValid()) {
174 return std::make_shared<Private::QuestSimulator>();
181 throw std::invalid_argument(
"Simulator Type not supported");
190 auto sim = std::make_unique<Private::QCSimSimulator>();
192 sim->Configure(
"method",
"matrix_product_state");
194 sim->Configure(
"method",
"stabilizer");
196 sim->Configure(
"method",
"tensor_network");
198 sim->Configure(
"method",
"pauli_propagator");
200 sim->Configure(
"method",
"path_integral");
202 throw std::invalid_argument(
"Simulation Type not supported for QCSim");
208 auto sim = std::make_unique<Private::AerSimulator>();
210 sim->Configure(
"method",
"matrix_product_state");
212 sim->Configure(
"method",
"stabilizer");
214 sim->Configure(
"method",
"tensor_network");
216 sim->Configure(
"method",
"extended_stabilizer");
218 sim->Configure(
"method",
"statevector");
220 throw std::invalid_argument(
221 "Simulation Type not supported for Qiskit Aer");
226 return std::make_unique<Private::CompositeSimulator>(
230 return std::make_unique<Private::CompositeSimulator>(
234 if (gpuLibrary && gpuLibrary->IsValid() &&
239 auto sim = std::make_unique<Private::GpuSimulator>();
241 sim->Configure(
"method",
"matrix_product_state");
243 sim->Configure(
"method",
"tensor_network");
245 sim->Configure(
"method",
"pauli_propagator");
247 sim->Configure(
"method",
"statevector");
256 throw std::invalid_argument(
257 "Simulation Type not supported for Quest Simulator");
258 else if (questLibrary && questLibrary->IsValid()) {
259 return std::make_unique<Private::QuestSimulator>();
266 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.
@ kPathIntegral
Path integral 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