1
1
# This must be done explicitly as they are not exported.
2
2
using QuantumClifford: mul_left!, mul_right!, Tableau
3
3
4
- @inline host_f (x, y; phases:: Val{phase_B} = Val (true )) where {phase_B} =
4
+ @inline function host_f! (
5
+ x, y;
6
+ phases:: Val{phase_B} = Val (default_phases)
7
+ ) where {phase_B}
8
+
5
9
mul_left! (x, y; phases = phases)
6
10
7
- @inline function device_f (
11
+ end
12
+
13
+ @inline function device_f! (
8
14
x, y, synchronize;
9
- phases:: Val{phase_B} = Val (true ),
15
+ phases:: Val{phase_B} = Val (default_phases),
16
+ primary_axis:: Val{primary_axis_E} = Val (default_primary_axis),
10
17
block_size:: Val{block_SZ} = Val (default_block_size),
11
18
batch_size:: Val{batch_SZ} = Val (default_batch_size)
12
- ) where {phase_B, block_SZ, batch_SZ}
19
+ ) where {phase_B, primary_axis_E, block_SZ, batch_SZ}
13
20
14
21
mul_left! (
15
22
x, y;
16
- phases = phases, block_size = block_size, batch_size = batch_size
23
+ phases = phases, primary_axis = primary_axis,
24
+ block_size = block_size, batch_size = batch_size
17
25
)
18
26
synchronize ()
19
27
20
28
end
21
29
22
30
@inline function benchmark_KA_mul_pauli_pauli (
23
31
AT, synchronize, path;
24
- phases:: Val{phase_B} = Val (true )
32
+ phases:: Val{phase_B} = Val (default_phases )
25
33
) where {phase_B}
26
34
27
35
host_time = zeros (Float64, length (n_MiB))
46
54
d_p2 = copy (d_p1)
47
55
synchronize ()
48
56
# Trigger compilation before benchmarking.
49
- host_f (h_p1, h_p2; phases = phases)
50
- host_time[i] = @belapsed host_f (
57
+ host_f! (h_p1, h_p2; phases = phases)
58
+ host_time[i] = @belapsed host_f! (
51
59
$ h_p1, $ h_p2; phases = $ phases
52
60
) evals = evals samples = samples seconds = seconds
53
61
for (j, size) in enumerate (batch_sizes)
54
- device_f (
62
+ device_f! (
55
63
d_p1, d_p2, synchronize;
56
64
phases = phases, batch_size = Val (size)
57
65
)
58
66
device_time[j, i] =
59
- @belapsed device_f (
67
+ @belapsed device_f! (
60
68
$ d_p1, $ d_p2, $ synchronize;
61
69
phases = $ phases, batch_size = Val ($ size)
62
70
) evals = evals samples = samples seconds = seconds
72
80
string (Sys. CPU_THREADS) * " , Device block size = $default_block_size "
73
81
xlabel = " Pauli operator size (MiB)"
74
82
label = hcat ((" Device - batch size = " .* string .(batch_sizes)). .. , " Host" )
83
+ path *= " /pauli_pauli"
84
+ mkpath (path)
75
85
76
86
plot (
77
87
n_MiB, 10 ^ 3 .* hcat (device_cat... , host_time);
78
88
shape = :circle , xticks = n_MiB, xscale = :log2 , yscale = :log10 ,
79
89
title = title, label = label, xlabel = xlabel, ylabel = " Runtime (ms)" ,
80
90
background_color = :transparent
81
91
)
82
- savefig (" $path /runtime_pauli_pauli_phase_ $phase_B .$format " )
92
+ savefig (" $path /runtime .$format " )
83
93
84
94
plot (
85
95
n_MiB, map (x -> host_time ./ x, device_cat);
86
96
shape = :circle , xticks = n_MiB, xscale = :log2 , title = title,
87
97
label = hcat (label[1 : end - 1 ]. .. ), xlabel = xlabel,
88
98
ylabel = " Ratio (host/device)" , background_color = :transparent
89
99
)
90
- savefig (" $path /ratio_pauli_pauli_phase_ $phase_B .$format " )
100
+ savefig (" $path /ratio .$format " )
91
101
92
102
end
93
103
94
104
@inline function benchmark_KA_mul_tableau_pauli (
95
105
AT, synchronize, path;
96
- phases:: Val{phase_B} = Val (true )
106
+ phases:: Val{phase_B} = Val (default_phases )
97
107
) where {phase_B}
98
108
99
109
host_time = zeros (Float64, length (n_MiB))
@@ -126,17 +136,17 @@ end
126
136
)
127
137
synchronize ()
128
138
# Trigger compilation before benchmarking.
129
- host_f (h_t, h_p; phases = phases)
130
- host_time[i] = @belapsed host_f (
139
+ host_f! (h_t, h_p; phases = phases)
140
+ host_time[i] = @belapsed host_f! (
131
141
$ h_t, $ h_p; phases = $ phases
132
142
) evals = evals samples = samples seconds = seconds
133
143
for (j, size) in enumerate (batch_sizes)
134
- device_f (
144
+ device_f! (
135
145
d_t, d_p, synchronize;
136
146
phases = phases, batch_size = Val (size)
137
147
)
138
148
device_time[j, i] =
139
- @belapsed device_f (
149
+ @belapsed device_f! (
140
150
$ d_t, $ d_p, $ synchronize;
141
151
phases = $ phases, batch_size = Val ($ size)
142
152
) evals = evals samples = samples seconds = seconds
@@ -152,32 +162,33 @@ end
152
162
string (Sys. CPU_THREADS) * " , Device block size = $default_block_size "
153
163
xlabel = " Tableau size (MiB)"
154
164
label = hcat ((" Device - batch size = " .* string .(batch_sizes)). .. , " Host" )
165
+ path *= " /tableau_pauli"
166
+ mkpath (path)
155
167
156
168
plot (
157
169
n_MiB, 10 ^ 3 .* hcat (device_cat... , host_time);
158
170
shape = :circle , xticks = n_MiB, xscale = :log2 , yscale = :log10 ,
159
171
title = title, label = label, xlabel = xlabel, ylabel = " Runtime (ms)" ,
160
172
background_color = :transparent
161
173
)
162
- savefig (" $path /runtime_tableau_pauli_phase_ $phase_B .$format " )
174
+ savefig (" $path /runtime .$format " )
163
175
164
176
plot (
165
177
n_MiB, map (x -> host_time ./ x, device_cat);
166
178
shape = :circle , xticks = n_MiB, xscale = :log2 , title = title,
167
179
label = hcat (label[1 : end - 1 ]. .. ), xlabel = xlabel,
168
180
ylabel = " Ratio (host/device)" , background_color = :transparent
169
181
)
170
- savefig (" $path /ratio_tableau_pauli_phase_ $phase_B .$format " )
182
+ savefig (" $path /ratio .$format " )
171
183
172
184
end
173
185
174
186
@inline function benchmark_KA_mul_leftright (
175
187
AT, synchronize, path;
176
- phases:: Val{phase_B} = Val (true )
188
+ phases:: Val{phase_B} = Val (default_phases )
177
189
) where {phase_B}
178
190
179
- path = " $path /mul_leftright"
180
- mkpath (path)
191
+ path *= " /mul_leftright/phase_$phase_B "
181
192
benchmark_KA_mul_pauli_pauli (AT, synchronize, path; phases = phases)
182
193
benchmark_KA_mul_tableau_pauli (AT, synchronize, path; phases = phases)
183
194
0 commit comments