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

Crystal: Force 64-bit maths #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

EddieRingle
Copy link
Contributor

As you pointed out in the last PR, the Crystal version was using 32-bit integers. This patch fixes that.

New benchmark against Clang:

ganglion:genprime eddie$ ./genprime-crystal 250000 1000000
Found   250000 primes in    1.65555 seconds (last was    3497861)
Found   500000 primes in    4.67614 seconds (last was    7368787)
Found   750000 primes in    8.79405 seconds (last was   11381621)
Found  1000000 primes in   13.79081 seconds (last was   15485863)

ganglion:genprime eddie$ ./genprime-c-clang 250000 1000000
Found   250000 primes in    1.75610 seconds (last was    3497861)
Found   500000 primes in    5.02919 seconds (last was    7368787)
Found   750000 primes in    9.30910 seconds (last was   11381621)
Found  1000000 primes in   15.12655 seconds (last was   15485863)

Signed-off-by: Eddie Ringle <eddie@ringle.io>
Signed-off-by: Eddie Ringle <eddie@ringle.io>
@EddieRingle
Copy link
Contributor Author

lim was already 64-bit, y was not, however.

New commit forces 64-bit maths, verified the LLVM IR to be equivalent to the Clang version.

@tycho
Copy link
Owner

tycho commented May 4, 2015

Also it would be ideal if it used the native integer width like the C
version does (instead of explicitly 64-bit)
On May 4, 2015 11:16 AM, "Eddie Ringle" notifications@github.com wrote:

lim was already 64-bit, y was not, however.

New commit forces 64-bit maths, verified the LLVM IR to be equivalent to
the Clang version.


Reply to this email directly or view it on GitHub
#5 (comment).

@EddieRingle
Copy link
Contributor Author

I'm not sure just using the native integer width types is so easy, as per:
http://crystal-lang.org/docs/builtin_types/integer_types.html

There are also to_i and to_u, which are just synonims [sic] of to_i32 and to_u32 respectively.

So it's 32-bit by default, I guess.

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