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

Adding nilakantha pi approximation benchmark #284

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
586 changes: 586 additions & 0 deletions adler32.json

Large diffs are not rendered by default.

9,589 changes: 9,589 additions & 0 deletions after_gc.txt

Large diffs are not rendered by default.

9,549 changes: 9,549 additions & 0 deletions baseline.txt

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions benchmarks/float/nilakantha.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@main {
v37: float = const 3;
PI: float = id v37;
v38: float = const 2;
n: float = id v38;
v39: float = const 1;
sign: float = id v39;
v40: float = id PI;
v41: float = id n;
v42: float = id sign;
call @calculatePI v40 v41 v42;
v43: int = const 0;
}
@calculatePI(PI: float, n: float, sign: float) {
v1: float = const 0;
i: float = id v1;
.for.cond.0:
v2: float = id i;
v3: float = const 1000000;
v4: bool = fle v2 v3;
br v4 .for.body.0 .for.end.0;
.for.body.0:
v5: float = id n;
v6: float = const 1;
v7: float = fadd v5 v6;
nPlusOne: float = id v7;
v8: float = id n;
v9: float = const 2;
v10: float = fadd v8 v9;
nPlusTwo: float = id v10;
v11: float = id nPlusOne;
v12: float = id nPlusTwo;
v13: float = fmul v11 v12;
nPlusOne_Times_nPlusTwo: float = id v13;
v14: float = id n;
v15: float = id nPlusOne_Times_nPlusTwo;
v16: float = fmul v14 v15;
denom: float = id v16;
v17: float = const 4;
v18: float = id denom;
v19: float = fdiv v17 v18;
frac: float = id v19;
v20: float = id sign;
v21: float = id frac;
v22: float = fmul v20 v21;
rhs: float = id v22;
v23: float = id PI;
v24: float = id rhs;
v25: float = fadd v23 v24;
PI: float = id v25;
v26: float = const 0;
v27: float = id sign;
v28: float = fsub v26 v27;
sign: float = id v28;
v29: float = id n;
v30: float = const 2;
v31: float = fadd v29 v30;
n: float = id v31;
v32: float = id i;
v33: float = const 1;
v34: float = fadd v32 v33;
i: float = id v34;
jmp .for.cond.0;
.for.end.0:
v35: float = id PI;
print v35;
v36: int = const 0;
}
13 changes: 13 additions & 0 deletions benchmarks/float/nilakantha.out
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be the wrong output—it looks like the output for your block extractor/CFG builder. Maybe try turnt --save nilakantha.bril once again?

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cfg for main: {'label_0': []}




cfg for calculatePI: {'label_0': ['for.cond.0'], 'for.cond.0': ['for.body.0', 'for.end.0'], 'for.body.0': ['for.cond.0'], 'for.end.0': []}


Block label_0 falls through to ['for.cond.0']
Block for.cond.0 branches to ['for.body.0', 'for.end.0']
Block for.body.0 jumps to ['for.cond.0']


2 changes: 2 additions & 0 deletions benchmarks/float/nilakantha.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
3.14159265358978690
total_dyn_inst: 45000065
2 changes: 1 addition & 1 deletion brili.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,4 +974,4 @@ async function main() {
}
}

main();
main();
2 changes: 2 additions & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The current benchmarks are:
* `max-subarray`: solution to the classic Maximum Subarray problem.
* `mod_inv`: Calculates the [modular inverse][modinv] of `n` under to a prime modulus p.
* `newton`: Calculate the square root of 99,999 using the [newton method][newton]
* `nilakantha`: Calculate the value of pi using the [nilakantha infinite series][nilakantha]
* `norm`: Calculate the [euclidean norm][euclidean] of a vector
* `n_root`: Calculate nth root of a float using newton's method.
* `orders`: Compute the order ord(u) for each u in a cyclic group [<Zn,+>][cgroup] of integers modulo *n* under the group operation + (modulo *n*). Set the second argument *is_lcm* to true if you would like to compute the orders using the lowest common multiple and otherwise the program will use the greatest common divisor.
Expand Down Expand Up @@ -111,3 +112,4 @@ Credit for several of these benchmarks goes to Alexa VanHattum and Gregory Yaune
[qsort-hoare]: https://en.wikipedia.org/wiki/Quicksort#Hoare_partition_scheme
[modinv]: https://en.wikipedia.org/wiki/Modular_multiplicative_inverse
[totient]: https://en.wikipedia.org/wiki/Euler's_totient_function
[nilakantha]: https://en.wikipedia.org/wiki/List_of_formulae_involving_%CF%80
1 change: 1 addition & 0 deletions turnt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
command = "bril2json < {filename} | python3 brili.ts {args}