Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Simulators/Factory.h
Go to the documentation of this file.
1
14
15#pragma once
16
17#ifndef _SIMULATORS_FACTORY_H_
18#define _SIMULATORS_FACTORY_H_
19
20#include "GpuLibMPSSim.h"
22#include "GpuLibrary.h"
23#include "Simulator.h"
24
25namespace Simulators {
26
34public:
41 static std::shared_ptr<ISimulator>
44
51 static std::unique_ptr<ISimulator> CreateSimulatorUnique(
54
55#ifdef __linux__
56 static std::unique_ptr<GpuLibStateVectorSim> CreateGpuLibStateVectorSim() {
57 if (!gpuLibrary || !gpuLibrary->IsValid())
58 return nullptr;
59
60 return std::make_unique<GpuLibStateVectorSim>(gpuLibrary);
61 }
62
63 static std::unique_ptr<GpuLibMPSSim> CreateGpuLibMPSSim() {
64 if (!gpuLibrary || !gpuLibrary->IsValid())
65 return nullptr;
66
67 return std::make_unique<GpuLibMPSSim>(gpuLibrary);
68 }
69
70 static std::shared_ptr<GpuLibrary> GetGpuLibrary() {
71 if (!gpuLibrary || !gpuLibrary->IsValid())
72 return nullptr;
73 return gpuLibrary;
74 }
75
76 static bool IsGpuLibraryAvailable() {
77 return gpuLibrary && gpuLibrary->IsValid();
78 }
79
80 static bool InitGpuLibrary();
81 static bool InitGpuLibraryWithMute();
82
83private:
84 static std::shared_ptr<GpuLibrary> gpuLibrary;
85 static std::atomic_bool firstTime;
86#else
87 static bool IsGpuLibraryAvailable() { return false; }
88
89 static bool InitGpuLibrary() { return false; }
90#endif
91};
92
93} // namespace Simulators
94
95#endif // !_SIMULATORS_FACTORY_H_
static std::shared_ptr< ISimulator > CreateSimulator(SimulatorType t=SimulatorType::kQCSim, SimulationType method=SimulationType::kMatrixProductState)
Create a quantum computing simulator.
Definition Factory.cpp:78
static std::unique_ptr< ISimulator > CreateSimulatorUnique(SimulatorType t=SimulatorType::kQCSim, SimulationType method=SimulationType::kMatrixProductState)
Create a quantum computing simulator.
Definition Factory.cpp:135
SimulationType
The type of simulation.
Definition State.h:82
@ kMatrixProductState
matrix product state simulation type
Definition State.h:84
SimulatorType
The type of simulator.
Definition State.h:63
@ kQCSim
qcsim simulator type
Definition State.h:67