Maestro 0.3.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Factory.cpp
Go to the documentation of this file.
1
19
20#include "FactoryBackends.h"
21
22namespace Simulators
23{
24
26{
27 switch (type)
28 {
31#ifndef NO_QISKIT_AER
33 // Aer owns its method selection and does not use the fusion adapter.
34 return CreateSimulatorUnique(type, method);
35#endif
36#ifdef __linux__
38 return FactoryBackends::CreateGpuImmediate(method);
39#endif
40 default:
41 throw std::invalid_argument("Unsupported immediate backend");
42 }
43}
44
46{
47 return CreateSimulatorUnique(t, m);
48}
49
51{
52 switch (t)
53 {
56#ifndef NO_QISKIT_AER
61#endif
64#ifdef __linux__
67 throw std::invalid_argument("Distributed GPU supports only statevector");
68 if (!IsDistributedGpuAvailable())
69 return nullptr;
70 return FactoryBackends::CreateDistributedGpuSimulator();
73 throw std::invalid_argument("Distributed MPI GPU supports only statevector");
74 return FactoryBackends::CreateDistributedMpiGpuSimulator();
75
77 // Library initialization is checked before advertising the backend;
78 // device resources remain lazy and configuration follows creation.
79 if (GetGpuDeviceCount() <= 0)
80 return nullptr;
81 if (auto immediate = CreateImmediateSimulatorUnique(t, m))
82 return FactoryBackends::CreateGpuSimulator(std::move(immediate));
83 return nullptr;
84#endif
87 throw std::invalid_argument("Simulation Type not supported for Quest Simulator");
88 else if (IsQuestLibraryAvailable())
89 {
91 }
92 return nullptr;
93 default:
94 break;
95 }
96
97 throw std::invalid_argument("Simulator Type not supported");
98
99 return nullptr; // keep compillers happy
100}
101} // namespace Simulators
static MAESTRO_FACTORY_EXPORT std::unique_ptr< ISimulator > CreateImmediateSimulatorUnique(SimulatorType type, SimulationType method=SimulationType::kStatevector)
Definition Factory.cpp:25
static MAESTRO_FACTORY_EXPORT std::shared_ptr< ISimulator > CreateSimulator(SimulatorType t=SimulatorType::kQCSim, SimulationType method=SimulationType::kMatrixProductState)
Create a quantum computing simulator.
Definition Factory.cpp:45
static MAESTRO_FACTORY_EXPORT std::unique_ptr< ISimulator > CreateSimulatorUnique(SimulatorType t=SimulatorType::kQCSim, SimulationType method=SimulationType::kMatrixProductState)
Create a quantum computing simulator.
Definition Factory.cpp:50
static MAESTRO_FACTORY_EXPORT bool IsQuestLibraryAvailable()
std::unique_ptr< ISimulator > CreateQCSimImmediate(SimulationType method)
std::unique_ptr< ISimulator > CreateAerSimulator(SimulationType method)
std::unique_ptr< ISimulator > CreateQCSimSimulator(std::unique_ptr< ISimulator > immediate)
std::unique_ptr< ISimulator > CreateCompositeSimulator(SimulatorType type)
std::unique_ptr< ISimulator > CreateQuestSimulator()
std::unique_ptr< ISimulator > CreateImmediateCompositeSimulator(SimulatorType type)
Bounded online routing based on current physical bond dimensions.
SimulationType
The type of simulation.
Definition State.h:109
@ kStatevector
statevector simulation type
Definition State.h:110
SimulatorType
The type of simulator.
Definition State.h:79
@ kCompositeQCSim
composite qcsim simulator type
Definition State.h:87
@ kQCSim
qcsim simulator type
Definition State.h:83
@ kQiskitAer
qiskit aer simulator type
Definition State.h:81
@ kQuestSim
quest simulator type
Definition State.h:89
@ kDistMpiGpuSim
state distributed across MPI ranks/GPUs
Definition State.h:91
@ kCompositeQiskitAer
composite qiskit aer simulator type
Definition State.h:85
@ kDistGpuSim
state distributed across local GPUs
Definition State.h:90
@ kGpuSim
gpu simulator type
Definition State.h:88