1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include "maths/matrix.h"
#include "maths/vector.h"
enum PsiGateType
{
PSI_GATE_TYPE_DIAGONAL,
PSI_GATE_TYPE_NON_DIAGONAL,
PSI_GATE_TYPE_CONTROLLED,
};
struct PsiKernel
{
struct PsiMatrix matrix;
size_t *targets;
size_t target_count;
char *name;
enum PsiGateType gate_type;
};
struct PsiKernel psi_new_kernel(const char *name, struct PsiMatrix matrix, const size_t *targets, size_t target_count);
struct PsiKernel psi_clone_kernel(struct PsiKernel kernel);
void psi_free_kernel(struct PsiKernel *kernel);
bool psi_kernels_share_qubits(struct PsiKernel a, struct PsiKernel b);
bool psi_kernels_commute(struct PsiKernel a, struct PsiKernel b);
bool psi_kernels_can_fuse(struct PsiKernel a, struct PsiKernel b);
bool psi_fuse_kernels(struct PsiKernel a, struct PsiKernel b, struct PsiKernel *out);
struct PsiKernelBatch
{
struct PsiKernel *kernels;
size_t count;
size_t capacity;
size_t num_qubits;
};
struct PsiKernelBatch psi_new_kernel_batch(size_t num_qubits);
void psi_free_kernel_batch(struct PsiKernelBatch *batch);
void psi_add_kernel(struct PsiKernelBatch *batch, struct PsiKernel kernel);
void psi_optimize_kernel_batch(struct PsiKernelBatch *batch);
void psi_execute_kernel_batch(struct PsiKernelBatch batch, struct PsiVector *state);
struct PsiExecutionLayer
{
struct PsiKernel *kernels;
size_t count;
size_t capacity;
};
struct PsiKernelStats
{
size_t total_kernels;
size_t single_qubit;
size_t two_qubit;
size_t multi_qubit;
size_t diagonal;
size_t execution_layers;
};
struct PsiStructureAwareBatch
{
struct PsiKernel *kernels;
size_t count;
size_t capacity;
struct PsiExecutionLayer *layers;
size_t layer_count;
size_t layer_capacity;
size_t num_qubits;
bool optimised;
};
struct PsiStructureAwareBatch psi_new_structure_aware_batch(size_t num_qubits);
void psi_free_structure_aware_batch(struct PsiStructureAwareBatch *batch);
void psi_add_structure_aware_kernel(struct PsiStructureAwareBatch *batch, struct PsiKernel kernel);
void psi_optimize_structure_aware_batch(struct PsiStructureAwareBatch *batch);
void psi_execute_structure_aware_batch(struct PsiStructureAwareBatch batch, struct PsiVector *state);
void psi_execute_structure_aware_batch_layered(struct PsiStructureAwareBatch batch, struct PsiVector *state);
struct PsiKernelStats psi_structure_aware_batch_stats(struct PsiStructureAwareBatch batch);
|