-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Make constants constexpr (where possible) #2478
Make constants constexpr (where possible) #2478
Conversation
Interesting, it looks like this is failing the sir model in the cmdstan upstream performance tests https://jenkins.mc-stan.org/job/CmdStan%20Performance%20Tests/job/downstream_tests/2577/consoleFull
|
@SteveBronder Oddly enough I can't reproduce the performance test failures locally, either on Linux or Windows. Would you mind trying it locally at some point to see if you can reproduce? |
Ack sorry I've been so slow on this been making a really steady amount of progress on the new matrix type in the compiler. I can run this on the mac we use for testing tomorrow. My guess is that whatever old clang version is on that mac doesn't follow something in the standard on infinities. But let me run this tmrw before we change anything |
Actually I can't login to the mac because I had to wipe my hard drive recently because of a computer crash and think I lost the ssh I needed to get in. I tried replicating this locally to no avail so I think this must be something with the mac Let me email Ben G and see if I can get access to that mac. The MCSE difference is wide enough that I think it's worth looking into. |
No wokkas at all, thanks for looking into it! This is much lower priority than the |
@serban-nicusor-toptal it looks like after the Jenkins update the little drop down arrows do not work anymore, is it possible to fix that? (Ftr can still see the full log if I go to the Jenkins site but it's nice to have the dropdown) |
@SteveBronder fixed! I didn't see that one, thanks! PS: If the mac you want to get into is the one we're using on Jenkins I can help you regain your ssh access, just send me an email. |
@serban-nicusor-toptal much appreciated! |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@SteveBronder looks like the macOS issues were just temporary, all seems to have completed without issue (phew!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thanks!
Summary
This PR changes the declaration of constants to use
static constexpr
where supported.static constexpr
was used over plainconstexpr
as it compiles to more efficient assembly. Examples provided on godbolt below:constexpr
: https://godbolt.org/z/9q9cx38z6static constexpr
: https://godbolt.org/z/1hds8EKKeconst double
: https://godbolt.org/z/MvWj73eY7Additionally the Euler's Gamma constant was added after a request on the forum
Tests
Added test for
egamma
, and existing tests for constants all passSide Effects
N/A
Release notes
Changed constants to
static constexpr
for efficiency, added Euler's Gamma constantChecklist
Math issue #(issue number)
Copyright holder: Andrew Johnson
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested