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

Use precompiled headers to shave off ~15% compile time for models. #582

Merged
merged 1 commit into from Nov 3, 2017

Conversation

seantalts
Copy link
Member

Submisison Checklist

  • Run tests: ./runCmdStanTests.py src/test
  • Declare copyright holder and open-source license: see below

Summary:

Change CmdStan to use precompiled headers. On my machine this cuts out about 4-5 seconds of compile time (once everything else is compiled and we're just compiling and linking the CPP model). I doubt this scales linearly with more complicated models but who knows! My bernoulli example takes about 24s without PCH and 19s with. @bgoodri might be worth porting to RStan?

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Columbia University

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@bgoodri
Copy link
Contributor

bgoodri commented Nov 2, 2017 via email

@seantalts
Copy link
Member Author

Can't we build it locally like with this patch? I don't fully understand how RStan works.

@bgoodri
Copy link
Contributor

bgoodri commented Nov 3, 2017 via email

@seantalts
Copy link
Member Author

seantalts commented Nov 3, 2017

What does CRAN make a shared object for? I would imagine it would just make one for the stan compiler, but we still need the source code of the stan and math headers on disk on a user's machine in order to compile a Stan model, no? If we have those on disk we can always stop using them as .hpp files and use an amalgamated .hpp.gch precompiled file that we construct as part of the build process instead... I might still be missing something.

@seantalts
Copy link
Member Author

@bob-carpenter are you the best person to review this? Or maybe @mitzimorris?

@syclik
Copy link
Member

syclik commented Nov 3, 2017 via email

@seantalts
Copy link
Member Author

Maybe someone else has time to do it today? I have been putting a ton of PRs through to you and I think that's unfair given that this isn't your full time job anymore.

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Nov 3, 2017 via email

@seantalts
Copy link
Member Author

So an interesting question is - does this even need code review if Daniel was the only one who could read makefiles before?

@sakrejda
Copy link

sakrejda commented Nov 3, 2017

Strictly speaking I can read that and it looks good. I can't read it well enough that I would trust that it would work as intended without verifying the actual compiler calls that are generated but I assume you did that.

@seantalts
Copy link
Member Author

Yep, and all the tests pass, it runs the same number of tests, that kind of thing. Want to approve it for me? We can always back it out later if someone else finds an issue with it. I don't think there's any "CmdStan czar" that needs to see every PR or anything.

Copy link

@sakrejda sakrejda left a comment

Choose a reason for hiding this comment

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

looks good

@seantalts
Copy link
Member Author

Thanks!

@seantalts seantalts merged commit 2d58bb3 into develop Nov 3, 2017
@seantalts seantalts deleted the build/use-precompiled-headers branch November 3, 2017 17:01
@syclik
Copy link
Member

syclik commented Nov 3, 2017 via email

@syclik
Copy link
Member

syclik commented Nov 3, 2017

Oh... I know it's merged now, but could you verify that it works on both Mac and Windows? I thought we had trouble with Windows g++ and precompiled headers.

@seantalts
Copy link
Member Author

Funny story - CmdStan does not seem to work on windows before this commit. I checked out the one before:

image

@syclik
Copy link
Member

syclik commented Nov 3, 2017 via email

@sakrejda
Copy link

sakrejda commented Nov 3, 2017

(╯°□°)╯︵ ┻━┻ <--- Windows

@seantalts
Copy link
Member Author

seantalts commented Nov 3, 2017 via email

@seantalts
Copy link
Member Author

I have to say, that .exe trick works way better. Unfortunately, it still doesn't seem to totally work:
image

What else am I doing wrong? 😅

@sakrejda
Copy link

sakrejda commented Nov 3, 2017

Does the libsundials directory exist? Does the library exist?

@seantalts
Copy link
Member Author

seantalts commented Nov 3, 2017 via email

@seantalts
Copy link
Member Author

seantalts commented Nov 3, 2017 via email

@sakrejda
Copy link

sakrejda commented Nov 3, 2017

Did you install g++ via Rtools?

@syclik
Copy link
Member

syclik commented Nov 3, 2017 via email

@seantalts
Copy link
Member Author

seantalts commented Nov 3, 2017 via email

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.

None yet

5 participants