Skip to content

Commit e19e58a

Browse files
Introduce consistent interface. Overhaul test and benchmark suites. Introduce benchmark and test scripts for canonicalization routines.
1 parent d6cb9ff commit e19e58a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2506
-1620
lines changed

benchmark/KernelAbstractions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Usage Instructions
22

3-
1. Modify the parameters listed in `implementation/definitions.jl` as desired, keeping in mind the limitations of the available device memory and the extent of the benchmark runtime.
3+
1. Modify the values listed in `implementation/definitions/[benchmark_configuration, tuning_parameters].jl` as desired, keeping in mind the limitations of the available device memory and the extent of the benchmark runtime.
44
2. Ensure that all the packages listed in `implementation/imports.jl` are installed as this is not handled automatically.
55
3. Ensure that the backend package(s) listed in the pertinent `benchmark_platform_*.jl` script are properly setup and configured.
66
4. Pass said script as an argument to julia (optionally, also set the number of executing host threads) and await for the benchmark to conclude.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
2+
#=============================================================================#
13
include("implementation/benchmark_platform.jl")
24

35
using CUDA: CuArray, devices, synchronize
46
const AT = CuArray
5-
const path = "QuantumClifford_benchmarks/CUDA"
7+
const path = "benchmarks/QuantumCliffordKAExt/CUDA"
68

79
const can_run = length(devices()) > 0
810

911
if can_run
10-
benchmark_platform(AT, synchronize, path)
12+
benchmark_platform(synchronize, AT, path)
1113
else
1214
@info "Unable to run CUDA benchmark. No suitable device was found."
1315
end
16+
#=============================================================================#
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
2+
#=============================================================================#
13
include("implementation/benchmark_platform.jl")
24

35
import pocl_jll
46
using OpenCL: CLArray, cl.devices, cl.platforms, cl.finish, cl.queue
57
const AT = CLArray
6-
const path = "QuantumClifford_benchmarks/OpenCL"
8+
const path = "benchmarks/QuantumCliffordKAExt/OpenCL"
79

810
const can_run = any(length(devices(platform)) > 0 for platform in platforms())
911

1012
if can_run
1113
synchronize() = finish(queue())
12-
benchmark_platform(AT, synchronize, path)
14+
benchmark_platform(synchronize, AT, path)
1315
else
1416
@info "Unable to run OpenCL benchmark. No suitable device was found."
1517
end
18+
#=============================================================================#
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
2+
#=============================================================================#
13
include("implementation/benchmark_platform.jl")
24

35
using AMDGPU: ROCArray, devices, synchronize
46
const AT = ROCArray
5-
const path = "QuantumClifford_benchmarks/ROCm"
7+
const path = "benchmarks/QuantumCliffordKAExt/ROCm"
68

79
const can_run = length(devices()) > 0
810

911
if can_run
10-
benchmark_platform(AT, synchronize, path)
12+
benchmark_platform(synchronize, AT, path)
1113
else
1214
@info "Unable to run ROCm benchmark. No suitable device was found."
1315
end
16+
#=============================================================================#

benchmark/KernelAbstractions/implementation/benchmark_KA_mul_leftright.jl

Lines changed: 0 additions & 195 deletions
This file was deleted.
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
2+
#=============================================================================#
13
include("imports.jl")
24
include("definitions.jl")
35
include("utilities.jl")
4-
include("benchmark_KA_mul_leftright.jl")
56

6-
@inline function benchmark_platform(AT, synchronize, path)
7+
include("suites/benchmark_KA_mul.jl")
8+
include("suites/benchmark_KA_canonicalization.jl")
9+
10+
@inline function benchmark_platform(synchronize, AT, path)::Nothing
11+
# BenchmarkTools evaluates the setup block at the global scope.
12+
global cache = AllocCache()
713
path *= "/" * string(value(now()) - UNIXEPOCH)
8-
benchmark_KA_mul_leftright(AT, synchronize, path; phases = Val(true))
9-
benchmark_KA_mul_leftright(AT, synchronize, path; phases = Val(false))
14+
15+
benchmark_KA_mul(synchronize, AT, path)
16+
benchmark_KA_canonicalization(synchronize, AT, path)
17+
18+
return nothing
1019
end
20+
#=============================================================================#
Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
# (La)TeX hates SVG but the Plots package has issues with transparent PDFs.
2-
const format = "svg"
31

4-
# BenchmarkTools parameters.
5-
# Evaluations per sample point.
6-
const evals = 16
7-
# Maximum number of samples.
8-
const samples = 2^10
9-
# Maximum runtime for each sample group.
10-
const seconds = 60
11-
12-
# By definition, (unsigned) char is the smallest addressable unit of memory.
13-
const MiB = 1024 * 1024 * count_zeros(zero(Cuchar))
14-
# Avoid consuming too many resources, 1 GiB is plenty.
15-
const n_MiB = [2^i for i = 1:10]
16-
# TODO: Keep these or remove them now that a good default has been set?
17-
const batch_sizes = [1, 4, 8, 16, 32, 64]
18-
19-
# These values originate from a package extension, hence the query.
20-
const KAExt = Base.get_extension(QuantumClifford, :QuantumCliffordKAExt)
21-
const default_phases = KAExt.default_phases
22-
const default_primary_axis = KAExt.default_primary_axis
23-
const default_block_size = KAExt.default_block_size
24-
const default_batch_size = KAExt.default_batch_size
2+
#=============================================================================#
3+
include("definitions/benchmark_configuration.jl")
4+
include("definitions/plot_configuration.jl")
5+
include("definitions/tuning_parameters.jl")
6+
#=============================================================================#
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
#=============================================================================#
3+
4+
#==============================================================================
5+
BENCHMARK TOOLS
6+
==============================================================================#
7+
8+
# CAUTION: Functions mutate their arguments, induces disparity between runs.
9+
# Evaluations per sample point.
10+
const evals = 1
11+
12+
# Maximum number of sample points.
13+
const samples = 2^14
14+
15+
# Maximum runtime for each trial.
16+
const seconds = 60
17+
18+
#==============================================================================
19+
SAMPLE EXTRAPOLATION
20+
==============================================================================#
21+
22+
# Maximum sampling period before before being aborted and extrapolated instead.
23+
const extrapolation_threshold = seconds << 1
24+
25+
# Whether to include the aborted run in the data set used for extrapolation.
26+
const include_threshold_point = false
27+
28+
# In the absence of sufficient data points for a fit, perform O(n^k) scaling.
29+
const host_permit_simple_scaling = true
30+
const device_permit_simple_scaling = true
31+
32+
#==============================================================================
33+
PROBLEM SIZE
34+
==============================================================================#
35+
36+
# By definition, (unsigned) char is the smallest addressable unit of memory.
37+
const MiB = 1024 * 1024 * count_zeros(zero(Cuchar))
38+
39+
# Avoid consuming too many resources, 1 GiB is plenty.
40+
const sizes_MiB = [2^i for i in 1 : 10]
41+
42+
#==============================================================================
43+
TUNING PARAMETERS
44+
==============================================================================#
45+
46+
const benchmark_primary_axis = true
47+
48+
const benchmark_phases = true
49+
50+
# TODO: Enable this by default once the POCL code generation bugs are fixed.
51+
const benchmark_block_size = false
52+
53+
const benchmark_batch_size = true
54+
#=============================================================================#
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#=============================================================================#
3+
# The output should be both stylish and informative.
4+
const plot_style = Dict(
5+
:xticks => sizes_MiB,
6+
:xscale => :log2,
7+
:shape => :circle,
8+
:background_color => :transparent
9+
)
10+
11+
# (La)TeX hates SVG but the Plots package has issues with transparent PDFs.
12+
const file_format = "svg"
13+
#=============================================================================#

0 commit comments

Comments
 (0)