15class DistributedGpuLibrary :
public Utils::Library {
18 static std::shared_ptr<DistributedGpuLibrary> GetInstance();
19 ~DistributedGpuLibrary()
override {
20 if (context && FreeLib) FreeLib();
23 std::lock_guard<std::recursive_mutex> lock(mutex);
24 if (loaded)
return true;
25 const char* path = std::getenv(mpi ?
"MAESTRO_DIST_MPI_GPU_LIBRARY"
26 :
"MAESTRO_DIST_GPU_LIBRARY");
28 path = mpi ?
"libmaestro_gpu_distributed_mpi.so"
29 :
"libmaestro_gpu_distributed.so";
33 SetGpuDevice =
reinterpret_cast<DistributedGpuApi::SetGpuDeviceFn
>(
34 GetFunction(
"SetGpuDevice"));
36 throw std::runtime_error(
"Distributed GPU plugin missing SetGpuDevice");
38 reinterpret_cast<DistributedGpuApi::GetGpuDeviceCountFn
>(
39 GetFunction(
"GetGpuDeviceCount"));
40 if (!GetGpuDeviceCount)
41 throw std::runtime_error(
42 "Distributed GPU plugin missing GetGpuDeviceCount");
43 ValidateLicense =
reinterpret_cast<DistributedGpuApi::ValidateLicenseFn
>(
44 GetFunction(
"ValidateLicense"));
46 throw std::runtime_error(
47 "Distributed GPU plugin missing ValidateLicense");
48 CheckLicense =
reinterpret_cast<DistributedGpuApi::CheckLicenseFn
>(
49 GetFunction(
"CheckLicense"));
51 throw std::runtime_error(
"Distributed GPU plugin missing CheckLicense");
53 reinterpret_cast<DistributedGpuApi::InitLibFn
>(GetFunction(
"InitLib"));
55 throw std::runtime_error(
"Distributed GPU plugin missing InitLib");
57 reinterpret_cast<DistributedGpuApi::FreeLibFn
>(GetFunction(
"FreeLib"));
59 throw std::runtime_error(
"Distributed GPU plugin missing FreeLib");
61 reinterpret_cast<DistributedGpuApi::CreateStateVectorFn
>(
62 GetFunction(
"CreateStateVector"));
63 if (!CreateStateVector)
64 throw std::runtime_error(
65 "Distributed GPU plugin missing CreateStateVector");
66 CreateStateVectorWithBackend =
67 reinterpret_cast<DistributedGpuApi::CreateStateVectorWithBackendFn
>(
68 GetFunction(
"CreateStateVectorWithBackend"));
69 if (!CreateStateVectorWithBackend)
70 throw std::runtime_error(
71 "Distributed GPU plugin missing CreateStateVectorWithBackend");
72 GetBackend =
reinterpret_cast<DistributedGpuApi::GetBackendFn
>(
73 GetFunction(
"GetBackend"));
75 throw std::runtime_error(
"Distributed GPU plugin missing GetBackend");
76 SetExExecutionConfig =
77 reinterpret_cast<DistributedGpuApi::SetExExecutionConfigFn
>(
78 GetFunction(
"SetExExecutionConfig"));
79 if (!SetExExecutionConfig)
80 throw std::runtime_error(
81 "Distributed GPU plugin missing SetExExecutionConfig");
83 reinterpret_cast<DistributedGpuApi::DestroyStateVectorFn
>(
84 GetFunction(
"DestroyStateVector"));
85 if (!DestroyStateVector)
86 throw std::runtime_error(
87 "Distributed GPU plugin missing DestroyStateVector");
88 SetDataType =
reinterpret_cast<DistributedGpuApi::SetDataTypeFn
>(
89 GetFunction(
"SetDataType"));
91 throw std::runtime_error(
"Distributed GPU plugin missing SetDataType");
93 reinterpret_cast<DistributedGpuApi::SetSeedFn
>(GetFunction(
"SetSeed"));
95 throw std::runtime_error(
"Distributed GPU plugin missing SetSeed");
97 reinterpret_cast<DistributedGpuApi::IsDoublePrecisionFn
>(
98 GetFunction(
"IsDoublePrecision"));
99 if (!IsDoublePrecision)
100 throw std::runtime_error(
101 "Distributed GPU plugin missing IsDoublePrecision");
102 GetNrQubits =
reinterpret_cast<DistributedGpuApi::GetNrQubitsFn
>(
103 GetFunction(
"GetNrQubits"));
105 throw std::runtime_error(
"Distributed GPU plugin missing GetNrQubits");
106 GetStateVectorGpuId =
107 reinterpret_cast<DistributedGpuApi::GetStateVectorGpuIdFn
>(
108 GetFunction(
"GetStateVectorGpuId"));
109 if (!GetStateVectorGpuId)
110 throw std::runtime_error(
111 "Distributed GPU plugin missing GetStateVectorGpuId");
113 reinterpret_cast<DistributedGpuApi::CreateFn
>(GetFunction(
"Create"));
115 throw std::runtime_error(
"Distributed GPU plugin missing Create");
116 CreateWithState =
reinterpret_cast<DistributedGpuApi::CreateWithStateFn
>(
117 GetFunction(
"CreateWithState"));
118 if (!CreateWithState)
119 throw std::runtime_error(
120 "Distributed GPU plugin missing CreateWithState");
121 Reset =
reinterpret_cast<DistributedGpuApi::ResetFn
>(GetFunction(
"Reset"));
123 throw std::runtime_error(
"Distributed GPU plugin missing Reset");
124 MeasureQubitCollapse =
125 reinterpret_cast<DistributedGpuApi::MeasureQubitCollapseFn
>(
126 GetFunction(
"MeasureQubitCollapse"));
127 if (!MeasureQubitCollapse)
128 throw std::runtime_error(
129 "Distributed GPU plugin missing MeasureQubitCollapse");
130 MeasureQubitNoCollapse =
131 reinterpret_cast<DistributedGpuApi::MeasureQubitNoCollapseFn
>(
132 GetFunction(
"MeasureQubitNoCollapse"));
133 if (!MeasureQubitNoCollapse)
134 throw std::runtime_error(
135 "Distributed GPU plugin missing MeasureQubitNoCollapse");
136 MeasureQubitsCollapse =
137 reinterpret_cast<DistributedGpuApi::MeasureQubitsCollapseFn
>(
138 GetFunction(
"MeasureQubitsCollapse"));
139 if (!MeasureQubitsCollapse)
140 throw std::runtime_error(
141 "Distributed GPU plugin missing MeasureQubitsCollapse");
142 MeasureQubitsNoCollapse =
143 reinterpret_cast<DistributedGpuApi::MeasureQubitsNoCollapseFn
>(
144 GetFunction(
"MeasureQubitsNoCollapse"));
145 if (!MeasureQubitsNoCollapse)
146 throw std::runtime_error(
147 "Distributed GPU plugin missing MeasureQubitsNoCollapse");
148 MeasureAllQubitsCollapse =
149 reinterpret_cast<DistributedGpuApi::MeasureAllQubitsCollapseFn
>(
150 GetFunction(
"MeasureAllQubitsCollapse"));
151 if (!MeasureAllQubitsCollapse)
152 throw std::runtime_error(
153 "Distributed GPU plugin missing MeasureAllQubitsCollapse");
154 MeasureAllQubitsNoCollapse =
155 reinterpret_cast<DistributedGpuApi::MeasureAllQubitsNoCollapseFn
>(
156 GetFunction(
"MeasureAllQubitsNoCollapse"));
157 if (!MeasureAllQubitsNoCollapse)
158 throw std::runtime_error(
159 "Distributed GPU plugin missing MeasureAllQubitsNoCollapse");
160 SaveState =
reinterpret_cast<DistributedGpuApi::SaveStateFn
>(
161 GetFunction(
"SaveState"));
163 throw std::runtime_error(
"Distributed GPU plugin missing SaveState");
164 SaveStateToHost =
reinterpret_cast<DistributedGpuApi::SaveStateToHostFn
>(
165 GetFunction(
"SaveStateToHost"));
166 if (!SaveStateToHost)
167 throw std::runtime_error(
168 "Distributed GPU plugin missing SaveStateToHost");
169 SaveStateDestructive =
170 reinterpret_cast<DistributedGpuApi::SaveStateDestructiveFn
>(
171 GetFunction(
"SaveStateDestructive"));
172 if (!SaveStateDestructive)
173 throw std::runtime_error(
174 "Distributed GPU plugin missing SaveStateDestructive");
175 RestoreStateFreeSaved =
176 reinterpret_cast<DistributedGpuApi::RestoreStateFreeSavedFn
>(
177 GetFunction(
"RestoreStateFreeSaved"));
178 if (!RestoreStateFreeSaved)
179 throw std::runtime_error(
180 "Distributed GPU plugin missing RestoreStateFreeSaved");
181 RestoreStateNoFreeSaved =
182 reinterpret_cast<DistributedGpuApi::RestoreStateNoFreeSavedFn
>(
183 GetFunction(
"RestoreStateNoFreeSaved"));
184 if (!RestoreStateNoFreeSaved)
185 throw std::runtime_error(
186 "Distributed GPU plugin missing RestoreStateNoFreeSaved");
187 FreeSavedState =
reinterpret_cast<DistributedGpuApi::FreeSavedStateFn
>(
188 GetFunction(
"FreeSavedState"));
190 throw std::runtime_error(
"Distributed GPU plugin missing FreeSavedState");
191 Clone =
reinterpret_cast<DistributedGpuApi::CloneFn
>(GetFunction(
"Clone"));
193 throw std::runtime_error(
"Distributed GPU plugin missing Clone");
195 reinterpret_cast<DistributedGpuApi::SampleFn
>(GetFunction(
"Sample"));
197 throw std::runtime_error(
"Distributed GPU plugin missing Sample");
198 SampleAll =
reinterpret_cast<DistributedGpuApi::SampleAllFn
>(
199 GetFunction(
"SampleAll"));
201 throw std::runtime_error(
"Distributed GPU plugin missing SampleAll");
202 Amplitude =
reinterpret_cast<DistributedGpuApi::AmplitudeFn
>(
203 GetFunction(
"Amplitude"));
205 throw std::runtime_error(
"Distributed GPU plugin missing Amplitude");
206 Probability =
reinterpret_cast<DistributedGpuApi::ProbabilityFn
>(
207 GetFunction(
"Probability"));
209 throw std::runtime_error(
"Distributed GPU plugin missing Probability");
210 BasisStateProbability =
211 reinterpret_cast<DistributedGpuApi::BasisStateProbabilityFn
>(
212 GetFunction(
"BasisStateProbability"));
213 if (!BasisStateProbability)
214 throw std::runtime_error(
215 "Distributed GPU plugin missing BasisStateProbability");
217 GetFunction(
"AllProbabilities"));
219 throw std::runtime_error(
220 "Distributed GPU plugin missing AllProbabilities");
221 ExpectationValue =
reinterpret_cast<DistributedGpuApi::ExpectationValueFn
>(
222 GetFunction(
"ExpectationValue"));
223 if (!ExpectationValue)
224 throw std::runtime_error(
225 "Distributed GPU plugin missing ExpectationValue");
227 reinterpret_cast<DistributedGpuApi::ApplyXFn
>(GetFunction(
"ApplyX"));
229 throw std::runtime_error(
"Distributed GPU plugin missing ApplyX");
231 reinterpret_cast<DistributedGpuApi::ApplyYFn
>(GetFunction(
"ApplyY"));
233 throw std::runtime_error(
"Distributed GPU plugin missing ApplyY");
235 reinterpret_cast<DistributedGpuApi::ApplyZFn
>(GetFunction(
"ApplyZ"));
237 throw std::runtime_error(
"Distributed GPU plugin missing ApplyZ");
239 reinterpret_cast<DistributedGpuApi::ApplyHFn
>(GetFunction(
"ApplyH"));
241 throw std::runtime_error(
"Distributed GPU plugin missing ApplyH");
243 reinterpret_cast<DistributedGpuApi::ApplySFn
>(GetFunction(
"ApplyS"));
245 throw std::runtime_error(
"Distributed GPU plugin missing ApplyS");
246 ApplySDG =
reinterpret_cast<DistributedGpuApi::ApplySDGFn
>(
247 GetFunction(
"ApplySDG"));
249 throw std::runtime_error(
"Distributed GPU plugin missing ApplySDG");
251 reinterpret_cast<DistributedGpuApi::ApplyTFn
>(GetFunction(
"ApplyT"));
253 throw std::runtime_error(
"Distributed GPU plugin missing ApplyT");
254 ApplyTDG =
reinterpret_cast<DistributedGpuApi::ApplyTDGFn
>(
255 GetFunction(
"ApplyTDG"));
257 throw std::runtime_error(
"Distributed GPU plugin missing ApplyTDG");
259 reinterpret_cast<DistributedGpuApi::ApplySXFn
>(GetFunction(
"ApplySX"));
261 throw std::runtime_error(
"Distributed GPU plugin missing ApplySX");
262 ApplySXDG =
reinterpret_cast<DistributedGpuApi::ApplySXDGFn
>(
263 GetFunction(
"ApplySXDG"));
265 throw std::runtime_error(
"Distributed GPU plugin missing ApplySXDG");
267 reinterpret_cast<DistributedGpuApi::ApplyKFn
>(GetFunction(
"ApplyK"));
269 throw std::runtime_error(
"Distributed GPU plugin missing ApplyK");
271 reinterpret_cast<DistributedGpuApi::ApplyPFn
>(GetFunction(
"ApplyP"));
273 throw std::runtime_error(
"Distributed GPU plugin missing ApplyP");
275 reinterpret_cast<DistributedGpuApi::ApplyRxFn
>(GetFunction(
"ApplyRx"));
277 throw std::runtime_error(
"Distributed GPU plugin missing ApplyRx");
279 reinterpret_cast<DistributedGpuApi::ApplyRyFn
>(GetFunction(
"ApplyRy"));
281 throw std::runtime_error(
"Distributed GPU plugin missing ApplyRy");
283 reinterpret_cast<DistributedGpuApi::ApplyRzFn
>(GetFunction(
"ApplyRz"));
285 throw std::runtime_error(
"Distributed GPU plugin missing ApplyRz");
287 reinterpret_cast<DistributedGpuApi::ApplyUFn
>(GetFunction(
"ApplyU"));
289 throw std::runtime_error(
"Distributed GPU plugin missing ApplyU");
291 reinterpret_cast<DistributedGpuApi::ApplyCXFn
>(GetFunction(
"ApplyCX"));
293 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCX");
295 reinterpret_cast<DistributedGpuApi::ApplyCYFn
>(GetFunction(
"ApplyCY"));
297 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCY");
299 reinterpret_cast<DistributedGpuApi::ApplyCZFn
>(GetFunction(
"ApplyCZ"));
301 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCZ");
303 reinterpret_cast<DistributedGpuApi::ApplyCHFn
>(GetFunction(
"ApplyCH"));
305 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCH");
306 ApplyCSX =
reinterpret_cast<DistributedGpuApi::ApplyCSXFn
>(
307 GetFunction(
"ApplyCSX"));
309 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCSX");
310 ApplyCSXDG =
reinterpret_cast<DistributedGpuApi::ApplyCSXDGFn
>(
311 GetFunction(
"ApplyCSXDG"));
313 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCSXDG");
315 reinterpret_cast<DistributedGpuApi::ApplyCPFn
>(GetFunction(
"ApplyCP"));
317 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCP");
318 ApplyCRx =
reinterpret_cast<DistributedGpuApi::ApplyCRxFn
>(
319 GetFunction(
"ApplyCRx"));
321 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCRx");
322 ApplyCRy =
reinterpret_cast<DistributedGpuApi::ApplyCRyFn
>(
323 GetFunction(
"ApplyCRy"));
325 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCRy");
326 ApplyCRz =
reinterpret_cast<DistributedGpuApi::ApplyCRzFn
>(
327 GetFunction(
"ApplyCRz"));
329 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCRz");
330 ApplyCCX =
reinterpret_cast<DistributedGpuApi::ApplyCCXFn
>(
331 GetFunction(
"ApplyCCX"));
333 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCCX");
334 ApplySwap =
reinterpret_cast<DistributedGpuApi::ApplySwapFn
>(
335 GetFunction(
"ApplySwap"));
337 throw std::runtime_error(
"Distributed GPU plugin missing ApplySwap");
338 ApplyCSwap =
reinterpret_cast<DistributedGpuApi::ApplyCSwapFn
>(
339 GetFunction(
"ApplyCSwap"));
341 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCSwap");
343 reinterpret_cast<DistributedGpuApi::ApplyCUFn
>(GetFunction(
"ApplyCU"));
345 throw std::runtime_error(
"Distributed GPU plugin missing ApplyCU");
346 GetApiVersion =
reinterpret_cast<DistributedGpuApi::GetApiVersionFn
>(
347 GetFunction(
"GetApiVersion"));
349 throw std::runtime_error(
"Distributed GPU plugin missing GetApiVersion");
350 GetCapabilities =
reinterpret_cast<DistributedGpuApi::GetCapabilitiesFn
>(
351 GetFunction(
"GetCapabilities"));
352 if (!GetCapabilities)
353 throw std::runtime_error(
354 "Distributed GPU plugin missing GetCapabilities");
355 GetLastError =
reinterpret_cast<DistributedGpuApi::GetLastErrorFn
>(
356 GetFunction(
"GetLastError"));
358 throw std::runtime_error(
"Distributed GPU plugin missing GetLastError");
359 ConfigureDistribution =
360 reinterpret_cast<DistributedGpuApi::ConfigureDistributionFn
>(
361 GetFunction(
"ConfigureDistribution"));
362 if (!ConfigureDistribution)
363 throw std::runtime_error(
364 "Distributed GPU plugin missing ConfigureDistribution");
365 GetShardDevices =
reinterpret_cast<DistributedGpuApi::GetShardDevicesFn
>(
366 GetFunction(
"GetShardDevices"));
367 if (!GetShardDevices)
368 throw std::runtime_error(
369 "Distributed GPU plugin missing GetShardDevices");
370 GetGlobalQubits =
reinterpret_cast<DistributedGpuApi::GetGlobalQubitsFn
>(
371 GetFunction(
"GetGlobalQubits"));
372 if (!GetGlobalQubits)
373 throw std::runtime_error(
374 "Distributed GPU plugin missing GetGlobalQubits");
375 GetQubitLayout =
reinterpret_cast<DistributedGpuApi::GetQubitLayoutFn
>(
376 GetFunction(
"GetQubitLayout"));
378 throw std::runtime_error(
"Distributed GPU plugin missing GetQubitLayout");
379 Redistribute =
reinterpret_cast<DistributedGpuApi::RedistributeFn
>(
380 GetFunction(
"Redistribute"));
382 throw std::runtime_error(
"Distributed GPU plugin missing Redistribute");
383 SwapGlobalLocalQubits =
384 reinterpret_cast<DistributedGpuApi::SwapGlobalLocalQubitsFn
>(
385 GetFunction(
"SwapGlobalLocalQubits"));
386 if (!SwapGlobalLocalQubits)
387 throw std::runtime_error(
388 "Distributed GPU plugin missing SwapGlobalLocalQubits");
389 Synchronize =
reinterpret_cast<DistributedGpuApi::SynchronizeFn
>(
390 GetFunction(
"Synchronize"));
392 throw std::runtime_error(
"Distributed GPU plugin missing Synchronize");
393 GetStateRange =
reinterpret_cast<DistributedGpuApi::GetStateRangeFn
>(
394 GetFunction(
"GetStateRange"));
396 throw std::runtime_error(
"Distributed GPU plugin missing GetStateRange");
397 SetStateRange =
reinterpret_cast<DistributedGpuApi::SetStateRangeFn
>(
398 GetFunction(
"SetStateRange"));
400 throw std::runtime_error(
"Distributed GPU plugin missing SetStateRange");
401 GetLocalStateBounds =
402 reinterpret_cast<DistributedGpuApi::GetLocalStateBoundsFn
>(
403 GetFunction(
"GetLocalStateBounds"));
404 if (!GetLocalStateBounds)
405 throw std::runtime_error(
406 "Distributed GPU plugin missing GetLocalStateBounds");
408 reinterpret_cast<DistributedGpuApi::GetLocalStateRangeFn
>(
409 GetFunction(
"GetLocalStateRange"));
410 if (!GetLocalStateRange)
411 throw std::runtime_error(
412 "Distributed GPU plugin missing GetLocalStateRange");
414 reinterpret_cast<DistributedGpuApi::SetLocalStateRangeFn
>(
415 GetFunction(
"SetLocalStateRange"));
416 if (!SetLocalStateRange)
417 throw std::runtime_error(
418 "Distributed GPU plugin missing SetLocalStateRange");
419 CreateWithBasisState =
420 reinterpret_cast<DistributedGpuApi::CreateWithBasisStateFn
>(
421 GetFunction(
"CreateWithBasisState"));
422 if (!CreateWithBasisState)
423 throw std::runtime_error(
424 "Distributed GPU plugin missing CreateWithBasisState");
425 ApplyOneQubitMatrix =
426 reinterpret_cast<DistributedGpuApi::ApplyOneQubitMatrixFn
>(
427 GetFunction(
"ApplyOneQubitMatrix"));
428 if (!ApplyOneQubitMatrix)
429 throw std::runtime_error(
430 "Distributed GPU plugin missing ApplyOneQubitMatrix");
431 ApplyOneQubitMatrixWithLayout =
432 reinterpret_cast<DistributedGpuApi::ApplyOneQubitMatrixWithLayoutFn
>(
433 GetFunction(
"ApplyOneQubitMatrixWithLayout"));
434 if (!ApplyOneQubitMatrixWithLayout)
435 throw std::runtime_error(
436 "Distributed GPU plugin missing ApplyOneQubitMatrixWithLayout");
437 ApplyTwoQubitMatrix =
438 reinterpret_cast<DistributedGpuApi::ApplyTwoQubitMatrixFn
>(
439 GetFunction(
"ApplyTwoQubitMatrix"));
440 if (!ApplyTwoQubitMatrix)
441 throw std::runtime_error(
442 "Distributed GPU plugin missing ApplyTwoQubitMatrix");
443 ApplyTwoQubitMatrixWithLayout =
444 reinterpret_cast<DistributedGpuApi::ApplyTwoQubitMatrixWithLayoutFn
>(
445 GetFunction(
"ApplyTwoQubitMatrixWithLayout"));
446 if (!ApplyTwoQubitMatrixWithLayout)
447 throw std::runtime_error(
448 "Distributed GPU plugin missing ApplyTwoQubitMatrixWithLayout");
449 if (GetApiVersion() != 1)
450 throw std::runtime_error(
"Unsupported distributed GPU API version");
454 virtual void* CreateNative(
int device,
int backend) {
455 std::lock_guard<std::recursive_mutex> lock(mutex);
458 Check(ValidateLicense(std::getenv(
"MAESTRO_LICENSE_KEY")),
461 if (!context) Fail(
"InitLib");
463 Check(SetGpuDevice(device),
"SetGpuDevice");
464 auto obj = CreateStateVectorWithBackend(context, backend);
465 if (!obj) Fail(
"CreateStateVectorWithBackend");
469 void DestroyNative(
void* obj)
noexcept {
471 DestroyStateVector(obj);
475 void* CloneNative(
void* obj) {
476 auto copy = Clone(obj);
477 if (!copy) Fail(
"Clone");
481 void RequireLoaded() {
483 throw std::runtime_error(
484 "Unable to load distributed GPU plugin; set MAESTRO_DIST_GPU_LIBRARY "
485 "or MAESTRO_DIST_MPI_GPU_LIBRARY");
487 [[noreturn]]
void Fail(
const char* operation)
const {
488 const char* error = GetLastError ? GetLastError() : nullptr;
489 throw std::runtime_error(std::string(
"Distributed GPU ") + operation +
491 (error && *error ? error :
"operation failed"));
493 void Check(
int status,
const char* operation)
const {
494 if (status != 1) Fail(operation);
496 DistributedGpuApi::SetGpuDeviceFn SetGpuDevice =
nullptr;
497 DistributedGpuApi::GetGpuDeviceCountFn GetGpuDeviceCount =
nullptr;
498 DistributedGpuApi::ValidateLicenseFn ValidateLicense =
nullptr;
499 DistributedGpuApi::CheckLicenseFn CheckLicense =
nullptr;
500 DistributedGpuApi::InitLibFn InitLib =
nullptr;
501 DistributedGpuApi::FreeLibFn FreeLib =
nullptr;
502 DistributedGpuApi::CreateStateVectorFn CreateStateVector =
nullptr;
503 DistributedGpuApi::CreateStateVectorWithBackendFn
504 CreateStateVectorWithBackend =
nullptr;
505 DistributedGpuApi::GetBackendFn GetBackend =
nullptr;
506 DistributedGpuApi::SetExExecutionConfigFn SetExExecutionConfig =
nullptr;
507 DistributedGpuApi::DestroyStateVectorFn DestroyStateVector =
nullptr;
508 DistributedGpuApi::SetDataTypeFn SetDataType =
nullptr;
509 DistributedGpuApi::SetSeedFn SetSeed =
nullptr;
510 DistributedGpuApi::IsDoublePrecisionFn IsDoublePrecision =
nullptr;
511 DistributedGpuApi::GetNrQubitsFn GetNrQubits =
nullptr;
512 DistributedGpuApi::GetStateVectorGpuIdFn GetStateVectorGpuId =
nullptr;
513 DistributedGpuApi::CreateFn Create =
nullptr;
514 DistributedGpuApi::CreateWithStateFn CreateWithState =
nullptr;
515 DistributedGpuApi::ResetFn Reset =
nullptr;
516 DistributedGpuApi::MeasureQubitCollapseFn MeasureQubitCollapse =
nullptr;
517 DistributedGpuApi::MeasureQubitNoCollapseFn MeasureQubitNoCollapse =
nullptr;
518 DistributedGpuApi::MeasureQubitsCollapseFn MeasureQubitsCollapse =
nullptr;
519 DistributedGpuApi::MeasureQubitsNoCollapseFn MeasureQubitsNoCollapse =
521 DistributedGpuApi::MeasureAllQubitsCollapseFn MeasureAllQubitsCollapse =
523 DistributedGpuApi::MeasureAllQubitsNoCollapseFn MeasureAllQubitsNoCollapse =
525 DistributedGpuApi::SaveStateFn
SaveState =
nullptr;
526 DistributedGpuApi::SaveStateToHostFn SaveStateToHost =
nullptr;
527 DistributedGpuApi::SaveStateDestructiveFn SaveStateDestructive =
nullptr;
528 DistributedGpuApi::RestoreStateFreeSavedFn RestoreStateFreeSaved =
nullptr;
529 DistributedGpuApi::RestoreStateNoFreeSavedFn RestoreStateNoFreeSaved =
531 DistributedGpuApi::FreeSavedStateFn FreeSavedState =
nullptr;
532 DistributedGpuApi::CloneFn Clone =
nullptr;
533 DistributedGpuApi::SampleFn Sample =
nullptr;
534 DistributedGpuApi::SampleAllFn SampleAll =
nullptr;
535 DistributedGpuApi::AmplitudeFn
Amplitude =
nullptr;
536 DistributedGpuApi::ProbabilityFn
Probability =
nullptr;
537 DistributedGpuApi::BasisStateProbabilityFn BasisStateProbability =
nullptr;
539 DistributedGpuApi::ExpectationValueFn ExpectationValue =
nullptr;
540 DistributedGpuApi::ApplyXFn
ApplyX =
nullptr;
541 DistributedGpuApi::ApplyYFn
ApplyY =
nullptr;
542 DistributedGpuApi::ApplyZFn
ApplyZ =
nullptr;
543 DistributedGpuApi::ApplyHFn
ApplyH =
nullptr;
544 DistributedGpuApi::ApplySFn
ApplyS =
nullptr;
545 DistributedGpuApi::ApplySDGFn
ApplySDG =
nullptr;
546 DistributedGpuApi::ApplyTFn
ApplyT =
nullptr;
547 DistributedGpuApi::ApplyTDGFn
ApplyTDG =
nullptr;
548 DistributedGpuApi::ApplySXFn
ApplySX =
nullptr;
549 DistributedGpuApi::ApplySXDGFn
ApplySXDG =
nullptr;
550 DistributedGpuApi::ApplyKFn
ApplyK =
nullptr;
551 DistributedGpuApi::ApplyPFn
ApplyP =
nullptr;
552 DistributedGpuApi::ApplyRxFn
ApplyRx =
nullptr;
553 DistributedGpuApi::ApplyRyFn
ApplyRy =
nullptr;
554 DistributedGpuApi::ApplyRzFn
ApplyRz =
nullptr;
555 DistributedGpuApi::ApplyUFn
ApplyU =
nullptr;
556 DistributedGpuApi::ApplyCXFn
ApplyCX =
nullptr;
557 DistributedGpuApi::ApplyCYFn
ApplyCY =
nullptr;
558 DistributedGpuApi::ApplyCZFn
ApplyCZ =
nullptr;
559 DistributedGpuApi::ApplyCHFn
ApplyCH =
nullptr;
560 DistributedGpuApi::ApplyCSXFn
ApplyCSX =
nullptr;
561 DistributedGpuApi::ApplyCSXDGFn
ApplyCSXDG =
nullptr;
562 DistributedGpuApi::ApplyCPFn
ApplyCP =
nullptr;
563 DistributedGpuApi::ApplyCRxFn
ApplyCRx =
nullptr;
564 DistributedGpuApi::ApplyCRyFn
ApplyCRy =
nullptr;
565 DistributedGpuApi::ApplyCRzFn
ApplyCRz =
nullptr;
566 DistributedGpuApi::ApplyCCXFn
ApplyCCX =
nullptr;
567 DistributedGpuApi::ApplySwapFn
ApplySwap =
nullptr;
568 DistributedGpuApi::ApplyCSwapFn
ApplyCSwap =
nullptr;
569 DistributedGpuApi::ApplyCUFn
ApplyCU =
nullptr;
570 DistributedGpuApi::GetApiVersionFn GetApiVersion =
nullptr;
571 DistributedGpuApi::GetCapabilitiesFn GetCapabilities =
nullptr;
572 DistributedGpuApi::GetLastErrorFn GetLastError =
nullptr;
573 DistributedGpuApi::ConfigureDistributionFn ConfigureDistribution =
nullptr;
574 DistributedGpuApi::GetShardDevicesFn GetShardDevices =
nullptr;
575 DistributedGpuApi::GetGlobalQubitsFn GetGlobalQubits =
nullptr;
576 DistributedGpuApi::GetQubitLayoutFn GetQubitLayout =
nullptr;
577 DistributedGpuApi::RedistributeFn Redistribute =
nullptr;
578 DistributedGpuApi::SwapGlobalLocalQubitsFn SwapGlobalLocalQubits =
nullptr;
579 DistributedGpuApi::SynchronizeFn Synchronize =
nullptr;
580 DistributedGpuApi::GetStateRangeFn GetStateRange =
nullptr;
581 DistributedGpuApi::SetStateRangeFn SetStateRange =
nullptr;
582 DistributedGpuApi::GetLocalStateBoundsFn GetLocalStateBounds =
nullptr;
583 DistributedGpuApi::GetLocalStateRangeFn GetLocalStateRange =
nullptr;
584 DistributedGpuApi::SetLocalStateRangeFn SetLocalStateRange =
nullptr;
585 DistributedGpuApi::CreateWithBasisStateFn CreateWithBasisState =
nullptr;
586 DistributedGpuApi::ApplyOneQubitMatrixFn ApplyOneQubitMatrix =
nullptr;
587 DistributedGpuApi::ApplyOneQubitMatrixWithLayoutFn
588 ApplyOneQubitMatrixWithLayout =
nullptr;
589 DistributedGpuApi::ApplyTwoQubitMatrixFn ApplyTwoQubitMatrix =
nullptr;
590 DistributedGpuApi::ApplyTwoQubitMatrixWithLayoutFn
591 ApplyTwoQubitMatrixWithLayout =
nullptr;
594 explicit DistributedGpuLibrary(
bool mpi =
false) : mpi(mpi) {}
595 std::recursive_mutex mutex;
596 std::atomic_size_t liveStates{0};
597 void* context =
nullptr;
int ApplyK(void *sim, int qubit)
double Probability(void *sim, unsigned long long int outcome)
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 ApplyCSXDG(void *sim, int controlQubit, int targetQubit)
int ApplyS(void *sim, int qubit)
int ApplyCX(void *sim, int controlQubit, int targetQubit)
int ApplyCRz(void *sim, int controlQubit, int targetQubit, double theta)
double * AllProbabilities(void *sim)
int ApplyCP(void *sim, int controlQubit, int targetQubit, double theta)
int ApplySXDG(void *sim, int qubit)
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)
double * Amplitude(void *sim, unsigned long long int outcome)
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 ApplySX(void *sim, int qubit)
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)
int ApplyCSX(void *sim, int controlQubit, int targetQubit)
virtual bool Init(const char *libName) noexcept