fix benchmark-dec, remove callWrapper

This commit is contained in:
Luke Boswell 2024-11-29 09:32:12 +11:00
parent 2feb5d3c2e
commit 7d4026bd00
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 4 additions and 9 deletions

View file

@ -138,7 +138,7 @@ fn avg_runs(comptime T: type, comptime n: usize, comptime op: fn (T, T) T, v: T)
var i: usize = 0;
while (i < warmups + repeats) : (i += 1) {
// Never inline run to ensure it doesn't optimize for the value of `v`.
runs[i] = callWrapper(u64, .never_inline, run, .{ T, n, op, v });
runs[i] = @call(.never_inline, run, .{ T, n, op, v });
}
const real_runs = runs[warmups..runs.len];
@ -164,13 +164,13 @@ fn run(comptime T: type, comptime n: usize, comptime op: fn (T, T) T, v: T) u64
while (i < outer) : (i += 1) {
comptime var j = 0;
inline while (j < inner) : (j += 1) {
a = callWrapper(T, .always_inline, op, .{ a, v });
a = @call(.always_inline, op, .{ a, v });
}
}
const rem = n % max_inline;
const j = 0;
inline while (j < rem) : (j += 1) {
a = callWrapper(T, .always_inline, op, .{ a, v });
a = @call(.always_inline, op, .{ a, v });
}
// Clobber `a` to avoid removal as dead code.
@ -182,11 +182,6 @@ fn run(comptime T: type, comptime n: usize, comptime op: fn (T, T) T, v: T) u64
return timer.read();
}
// This is needed to work around a bug with using `@call` in loops.
inline fn callWrapper(comptime T: type, call_modifier: anytype, comptime func: anytype, params: anytype) T {
return @call(call_modifier, func, params);
}
fn addF64(x: f64, y: f64) f64 {
return x + y;
}

View file

@ -4,4 +4,4 @@
set -euxo pipefail
zig build-exe benchmark-dec.zig -O ReleaseFast
./dec
./benchmark-dec