Skip to content

Commit a365246

Browse files
authored
Don't use @assert, and print some debugging info if C is not approximately equal to reference (#47)
* Don't use `@assert`, and print some debugging info if `C` is not approximately equal to `reference` * Update runbenchmark.jl
1 parent 8f2ccc1 commit a365246

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BLASBenchmarksCPU"
22
uuid = "5fdc822c-4560-4d20-af7e-e5ee461714d5"
33
authors = ["Chris Elrod <[email protected]> and contributors"]
4-
version = "0.2.1"
4+
version = "0.3.0"
55

66
[deps]
77
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"

src/runbenchmark.jl

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,23 @@ function maybe_sleep(x)
7373
end
7474

7575
function benchmark_fun!(
76-
f!::F, summarystat, C, A, B, sleep_time, force_belapsed = false, reference = nothing
76+
f!::F,
77+
summarystat,
78+
C,
79+
A,
80+
B,
81+
sleep_time,
82+
force_belapsed,
83+
reference,
84+
comment::String, # `comment` is a place to put the library name, the dimensions of the matrices, etc.
7785
) where {F}
7886
maybe_sleep(sleep_time)
7987
t0 = @elapsed f!(C, A, B)
80-
isnothing(reference) || @assert C reference
88+
if (reference !== nothing) && (!(C reference))
89+
msg = "C is not approximately equal to reference"
90+
@error(msg, comment)
91+
throw(ErrorException(msg))
92+
end
8193
if force_belapsed || 2t0 < BenchmarkTools.DEFAULT_PARAMETERS.seconds
8294
maybe_sleep(sleep_time)
8395
br = @benchmark $f!($C, $A, $B)
@@ -287,8 +299,18 @@ function runbench(
287299
last_perfs[1] = (:Size, (M,K,N) .% Int)
288300
for i eachindex(funcs)
289301
C, ref = i == 1 ? (C0, nothing) : (fill!(C1,junk(T)), C0)
302+
lib = library[i]
303+
comment = "lib=$(lib), M=$(M), K=$(K), N=$(N)"
290304
t = benchmark_fun!(
291-
funcs[i], summarystat, C, A, B, sleep_time, force_belapsed, ref
305+
funcs[i],
306+
summarystat,
307+
C,
308+
A,
309+
B,
310+
sleep_time,
311+
force_belapsed,
312+
ref,
313+
comment,
292314
)
293315
gffactor = 2e-9M*K*N
294316
@inbounds for k 1:4

0 commit comments

Comments
 (0)