Skip to content

Benchmark result df #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ julia = "1.5"

[extras]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"

[targets]
test = ["InteractiveUtils", "Test", "VectorizationBase"]
test = ["InteractiveUtils", "StatsPlots", "Test", "VectorizationBase"]
4 changes: 2 additions & 2 deletions src/benchconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function getfuncs(libs::Vector{Symbol}, threaded::Bool)::Vector{Function}
elseif i === :BLIS || i === :blis
gemmblis!
elseif i === :Octavian
matmul!
threaded ? matmul! : matmul_serial!
elseif i === :Tullio
threaded ? tmul_threads! : tmul_no_threads!
elseif i === :Gaius
Gaius.mul!
threaded ? Gaius.mul! : Gaius.mul_serial!
elseif i === :generic || i === :Generic || i === :GENERIC
generic_matmul!
else
Expand Down
23 changes: 18 additions & 5 deletions src/runbenchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,26 @@ function benchmark_result_type(::BenchmarkResult{T}) where {T}
return T
end

function _benchmark_result_df(sizes, libraries, mat)
df = DataFrame(Size = sizes)
for i ∈ eachindex(libraries)
setproperty!(df, libraries[i], mat[:,i])
end
return df
end
function _benchmark_result_df(br::BenchmarkResult, s::Symbol = :gflops)
_benchmark_result_df(br.sizes, br.libraries, getproperty(br, s))
end


"""
benchmark_result_df(benchmark_result::BenchmarkResult)
"""
function benchmark_result_df(benchmark_result::BenchmarkResult)
return deepcopy(benchmark_result.df)
df = _benchmark_result_df(benchmark_result, :times)
df = stack(df, Not(:Size), variable_name = :Library, value_name = :Seconds)
df.GFLOPS = @. 2e-9 * matmul_length(df.Size) ./ df.Seconds
return df
end

"""
Expand All @@ -29,10 +44,7 @@ end

function Base.show(io::IO, br::BenchmarkResult{T}) where {T}
println(io, "Bennchmark Result of Matrix{$T}, threaded = $(br.threaded)")
df = DataFrame(Sizes = br.sizes)
for i ∈ eachindex(br.libraries)
setproperty!(df, br.libraries[i], br.gflops[:,i])
end
df = _benchmark_result_df(br)
println(io, df)
end

Expand Down Expand Up @@ -70,6 +82,7 @@ end

matmul_sizes(s::Integer) = (s,s,s)
matmul_sizes(mkn::Tuple{Vararg{Integer,3}}) = mkn
matmul_length(s) = prod(matmul_sizes(s))

junk(::Type{T}) where {T <: Integer} = typemax(T) >> 1
junk(::Type{T}) where {T} = T(NaN)
Expand Down
13 changes: 13 additions & 0 deletions test/interface.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import BLASBenchmarksCPU
import StatsPlots
@testset "Interface" begin
benchmark_result = BLASBenchmarksCPU.runbench(Float64; sizes = [1, 2, 5, 10, 20, 50, 100, 200], threaded=false) #test that threads=false at least doesn't throw somewhere.
df = BLASBenchmarksCPU.benchmark_result_df(benchmark_result)
@test df isa BLASBenchmarksCPU.DataFrame
df[!, :Size] = Float64.(df[!, :Size]);
df[!, :GFLOPS] = Float64.(df[!, :GFLOPS]);
df[!, :Seconds] = Float64.(df[!, :Seconds]);
p = StatsPlots.@df df StatsPlots.plot(:Size, :GFLOPS; group = :Library, legend = :bottomright)
@test p isa StatsPlots.Plots.Plot
end
2 changes: 2 additions & 0 deletions test/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ for T in [Float64, Float32]
)
@test benchmark_result isa BLASBenchmarksCPU.BenchmarkResult
@test benchmark_result_type(benchmark_result) === T
df = benchmark_result_df(benchmark_result)
@test df isa BLASBenchmarksCPU.DataFrame
plot_directory = mktempdir()
BLASBenchmarksCPU.plot(
benchmark_result;
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ include("test-suite-preamble.jl")
@info("VectorizationBase.num_cores() is $(VectorizationBase.num_cores())")

include("main.jl")
include("interface.jl")