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

RFC: Contributed shootout pidigits.jl to Julia and created shootout directory #693

Closed

Conversation

yledu
Copy link
Contributor

@yledu yledu commented Apr 10, 2012

Hi,

After issue #660, I send the pidigits.jl, hopefully the first in a series.

I added divmod and lshift from gmp.

The pidigits.jl code runs as fast as Python's given on the shooutout website, and I had to comment out the printouts that took much longer than for Python -- I don't know Julia well enough to see how to optimise the code any further.

I also created a separate directory for the shootout codes, in the examples directory, because it's a project in itself as someone mentioned in issue 660.

…e examples; it is a straighforward rewrite of the Python version available on the shootout. Also had to modify the bigint.jl module and corresponding gmp_wrapper.c in order to make 'divmod' and 'lshift' available. Without the printouts (commented out in the code), the speed is on par with Python -- use the timeit macro now available in timing.jl (also in shootout directory) and adapted from perf.jl. Also moved fasta.jl to that new shootout directory.
@pao
Copy link
Member

pao commented Apr 10, 2012

Overall, looks fine.

Can we make @timeit more general, to take the number of loops as an argument? And is it cheating to warm up the JIT first by running the method once untimed to force compilation? I don't know their rules on warmup loops.

And I missed this earlier; Github only adds linkbacks from other issues if you use the # syntax. Let's do that now: #660.

@yledu
Copy link
Contributor Author

yledu commented Apr 10, 2012

Thanks for the comments pao. I've committed all corrections, but did not add the variable number of repetitions in the timeit macro, because I don't know how to simulate default values in macros. By the way, I took the original timeit macro from the perf.jl file in tests/perf. Apparently, it gives better results than both @time and tic toc.

I pushed the corrections to my master, but in between I have other small commits, so I don't know if you'll want to take everything. Tell me how you'd like to proceed.

I also have some questions on the performance :

1/ why isn't it faster than python,

2/ why is the print and show so slow compared to Python,

3/ how to make macros with varying number of arguments (helpful to specify default values like in the timeit macro if I wanted to add an optional 'number of repetitions' parameter,

4/ why does pidigits.jl take up so much memory (try pidigits(10000), and saturates my 8GB ram, while it works well for the python version.

Python's version : http://shootout.alioth.debian.org/u64q/program.php?test=pidigits&lang=python3&id=2

@pao
Copy link
Member

pao commented Apr 10, 2012

I can't answer most of your questions (you may want to bring them up on julia-dev), but I can recommend a course of action for the commits; we'll copy them to a topic branch so you can do a pull request on that:

$ # First, create a clean copy of JuliaLang:master
$ git branch -t upstream remotes/origin/master #assumes you have the JuliaLang remote as "origin"
$ git checkout upstream
$ git pull
$ # Then, make a branch for shootout code
$ git checkout -b topic/shootout #you could call this something else; this is my convention
$ # And get the commits you actually want
$ git cherry-pick 892a03a 61af6d3 1e7ffad
$ git push mine HEAD #assuming your remote is named "mine"

Then, submit a new pull request from the head of the topic/shootout branch you just pushed (Github will put a "recently pushed" banner on your julia repository page with a button for that), mention "#693" in the message body so it links to this conversation, and close this request.

Routine cherry-picking isn't the way you should be working, but I think it's the best way to get you back on track in this case. Remember, branch early, branch often!

@yledu
Copy link
Contributor Author

yledu commented Apr 11, 2012

Thanks for the detailed and patient help pao.

On Wed, Apr 11, 2012 at 12:51 AM, pao <
reply@reply.github.com

wrote:

I can't answer most of your questions (you may want to bring them up on
julia-dev), but I can recommend a course of action for the commits; we'll
copy them to a topic branch so you can do a pull request on that:

$ # First, create a clean copy of JuliaLang:master
$ git branch -t upstream remotes/origin/master #assumes you have the
JuliaLang remote as "origin"
$ git checkout upstream
$ git pull
$ # Then, make a branch for shootout code
$ git checkout -b topic/shootout #you could call this something else; this
is my convention
$ # And get the commits you actually want
$ git cherry-pick 892a03a 61af6d3 1e7ffad
$ git push mine HEAD #assuming your remote is named "mine"

Then, submit a new pull request from the head of the topic/shootout branch
you just pushed (Github will put a "recently pushed" banner on your julia
repository page with a button for that), mention "#693" in the message body
so it links to this conversation, and close this request.

Routine cherry-picking isn't the way you should be working, but I think
it's the best way to get you back on track in this case. Remember, branch
early, branch often!


Reply to this email directly or view it on GitHub:
#693 (comment)

@yledu yledu closed this Apr 11, 2012
ararslan pushed a commit to JuliaAttic/Examples that referenced this pull request Feb 21, 2018
…code. Also: added some documentation for pidigits ; added an option to print the intermediate digits as requested by the shootout, leaving it as a non-default option because printing is so slow in Julia compared to Python...
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