Skip to content

Commit

Permalink
Merge pull request sampsyo#274 from emwangs/main
Browse files Browse the repository at this point in the history
LCM Benchmark
  • Loading branch information
sampsyo authored Sep 7, 2023
2 parents 5ff0a3c + 98e8936 commit 5ca3cff
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
34 changes: 34 additions & 0 deletions benchmarks/core/lcm.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ARGS: 64 24
@main(x: int, y: int) {
greater: int = id y;
v4: bool = gt x y;
br v4 .then.1 .else.1;
.then.1:
greater: int = id x;
jmp .endif.1;
.else.1:
.endif.1:
.foreverloop:
modX : int = call @getMod greater x;
modY : int = call @getMod greater y;
zero: int = const 0;
xZero : bool = eq modX zero;
yZero : bool = eq modY zero;
bothZero : bool = and xZero yZero;
br bothZero .then.2 .else.2;
.then.2:
print greater;
jmp .loopend;
.else.2:
one: int = const 1;
greater:int = add greater one;
jmp .foreverloop;
.loopend:
}

@getMod(val: int, mod: int): int{
divisor: int = div val mod;
multiple: int = mul divisor mod;
rem: int = sub val multiple;
ret rem;
}
1 change: 1 addition & 0 deletions benchmarks/core/lcm.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
192
1 change: 1 addition & 0 deletions benchmarks/core/lcm.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
total_dyn_inst: 2326
1 change: 1 addition & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The current benchmarks are:
* `function_call`: For benchmarking the overhead of simple function calls.
* `gcd`: Calculate Greatest Common Divisor (GCD) of two input positive integer using [Euclidean algorithm][euclidean_into].
* `hanoi`: Print the solution to the *n*-disk [Tower of Hanoi][hanoi] puzzle.
* `lcm`: Compute LCM for two numbers using a very inefficient loop.
* `loopfact`: Compute *n!* imperatively using a loop.
* `mandelbrot`: Generates a really low resolution, ascii, [mandelbrot set][mandelbrot].
* `mat-inv` : Calculates the inverse of a 3x3 matrix and prints it out.
Expand Down

0 comments on commit 5ca3cff

Please sign in to comment.