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

Mark rethrow_located as [[noreturn]] #3059

Merged
merged 1 commit into from
Sep 1, 2021
Merged

Conversation

WardBrian
Copy link
Member

Submission Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

Marks rethrow_located as never returning using the noreturn attribute. This should allow us to simplify the existing code generation in stanc3, as currently we generate this code:

    try {
        ....
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
      // Next line prevents compiler griping about no return
      throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 
    }

This should make that extra throw unnecessary.

Intended Effect

Let the compiler know that rethrow_located will never return

How to Verify

I've tested this in a local cmdstan instance, though I was not able to get the error described in the comment to appear, with or without this change.

Side Effects

None

Documentation

None

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):
Simons Foundation

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

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.45 3.52 0.98 -1.87% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.99 -0.9% slower
eight_schools/eight_schools.stan 0.09 0.09 0.98 -1.65% slower
gp_regr/gp_regr.stan 0.14 0.14 1.01 0.85% faster
irt_2pl/irt_2pl.stan 5.02 5.2 0.96 -3.7% slower
performance.compilation 91.8 89.0 1.03 3.05% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.13 8.13 1.0 -0.0% slower
pkpd/one_comp_mm_elim_abs.stan 31.35 30.79 1.02 1.77% faster
sir/sir.stan 127.91 118.09 1.08 7.67% faster
gp_regr/gen_gp_data.stan 0.03 0.03 0.98 -1.76% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.99 2.98 1.0 0.35% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.39 0.4 0.98 -1.9% slower
arK/arK.stan 2.06 2.05 1.0 0.45% faster
arma/arma.stan 0.23 0.25 0.91 -9.87% slower
garch/garch.stan 0.65 0.6 1.08 7.58% faster
Mean result: 1.00175460523

Jenkins Console Log
Blue Ocean
Commit hash: 9ad8d3b


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Copy link
Contributor

@bob-carpenter bob-carpenter 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. Thanks to @blackwer for suggesting this fix.

@bob-carpenter bob-carpenter merged commit 46be45b into develop Sep 1, 2021
@WardBrian WardBrian deleted the make-rethrow-noreturn branch December 17, 2021 18:52
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

3 participants