Skip to content
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

Add vectorization/simd benchmark #266

Merged
merged 6 commits into from
Aug 30, 2023
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
56 changes: 56 additions & 0 deletions benchmarks/mem/vsmul.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@rand(seq: ptr<int>, max: int) : int {
a: int = const 25214903917;
c: int = const 11;
m: int = const 281474976710656;
x: int = load seq;
ax: int = mul a x;
axpc: int = add ax c;
next: int = div axpc m;
next: int = mul next m;
next: int = sub axpc next;
store seq next;
val: int = div next max;
val: int = mul val max;
val: int = sub next val;
ret val;
}

# Generates a random array of length `size`
@randarray(size: int, rng: ptr<int>) : ptr<int> {
arr: ptr<int> = alloc size;
i: int = const 0;
max: int = const 1000;
one: int = const 1;
.loop:
cond: bool = lt i size;
br cond .body .done;
.body:
val: int = call @rand rng max;
loc: ptr<int> = ptradd arr i;
store loc val;
.loop_end:
i: int = add i one;
jmp .loop;
.done:
ret arr;
}

# ARGS: 4096 2023
@main(size: int, seed: int) {
two: int = const 2;
rng: ptr<int> = alloc seed;
store rng seed;
arr: ptr<int> = call @randarray size rng;
i: int = const 0;
.loop:
cond: bool = lt i size;
br cond .body .done;
.body:
loc: ptr<int> = ptradd arr i;
val: int = load loc;
val: int = mul val two;
store loc val;
.done:
free arr;
free rng;
}
Empty file added benchmarks/mem/vsmul.out
Empty file.
1 change: 1 addition & 0 deletions benchmarks/mem/vsmul.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
total_dyn_inst: 86036
1 change: 1 addition & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The current benchmarks are:
* `sum-divisors`: Prints the positive integer divisors of the input integer, followed by the sum of the divisors.
* `sum-sq-diff`: Output the difference between the sum of the squares of the first *n* natural numbers and the square of their sum.
* `up-arrow`: Computes [Knuth's up arrow][uparrow] notation, with the first argument being the number, the second argument being the number of Knuth's up arrows, and the third argument being the number of repeats.
* `vsmul`: Multiplies a constant scalar to each element of a large array. Tests the performance of vectorization optimizations.
* `reverse`: Compute number with reversed digits (e.g. 123 -> 321).

Credit for several of these benchmarks goes to Alexa VanHattum and Gregory Yauney, who implemented them for their [global value numbering project][gvnblog].
Expand Down