Skip to content

benchmarks: add Ramanujan's formula for calculating pi#483

Merged
axic merged 1 commit intomasterfrom
bench-ramunajan
Aug 23, 2020
Merged

benchmarks: add Ramanujan's formula for calculating pi#483
axic merged 1 commit intomasterfrom
bench-ramunajan

Conversation

@axic axic force-pushed the bench-ramunajan branch from aae84bc to a34401d Compare August 13, 2020 15:10
@axic axic force-pushed the bench-taylor branch 2 times, most recently from 6c6335e to a468409 Compare August 13, 2020 17:05
@axic axic changed the title benchmarks: add Ramunajan's formula for calculating pi benchmarks: add Ramanujan's formula for calculating pi Aug 13, 2020
Copy link
Copy Markdown
Collaborator

@chfast chfast left a comment

Choose a reason for hiding this comment

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

Looks ok. How long does it run?

Comment thread test/benchmarks/ramunajan_pi.inputs Outdated

31415926535897932

pi_30_runs
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think adding more than one execution benchmark adds any additional information. It rather just make running benchmarks take longer.

@axic axic force-pushed the bench-ramunajan branch 2 times, most recently from 62f20d0 to 9f97cd7 Compare August 14, 2020 18:57
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 14, 2020

Codecov Report

Merging #483 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #483   +/-   ##
=======================================
  Coverage   99.67%   99.67%           
=======================================
  Files          54       54           
  Lines       17180    17180           
=======================================
  Hits        17125    17125           
  Misses         55       55           

@axic axic changed the base branch from bench-taylor to master August 14, 2020 19:04
@axic axic force-pushed the bench-ramunajan branch from 9f97cd7 to 244ef11 Compare August 14, 2020 19:33
@axic
Copy link
Copy Markdown
Member Author

axic commented Aug 14, 2020

The wat can be found here: https://gist.github.com/axic/1b330d744148e2aa46085f0f69521b40

@axic axic requested a review from chfast August 14, 2020 19:37
{
// This dumb implementation of Ramanujan series calculates 1/pi
double ret = 0.0;
for (unsigned k = 0; k < n; k++) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For "more floating point" and fun, you can make it double k.


#define WASM_EXPORT __attribute__((visibility("default")))

static unsigned factorial(unsigned n)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can be also implemented with double n.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah thought about those, but kind of resorted that perhaps for forcefully having "more floating point" perhaps a hand crafted synthetic benchmark using all ops is better?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So what's the point of this benchmark if only 10-20% of instructions is floating-point?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Absolute number of instructions or instructions weighted by the number of times they are executed?

If you profile it it should be clear the heavy part is the floating point calculation (pow, etc.). The factorial part only works with small number (<30).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok then.

@axic axic force-pushed the bench-ramunajan branch from 244ef11 to 364ef02 Compare August 21, 2020 23:26
@axic axic force-pushed the bench-ramunajan branch from 364ef02 to cd55199 Compare August 23, 2020 10:28
@axic axic merged commit 10e1d14 into master Aug 23, 2020
@axic axic deleted the bench-ramunajan branch August 23, 2020 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants