Skip to content

Add virtual function model_compile_info to the model_base.hpp #2932

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

Merged
merged 18 commits into from
Nov 24, 2020

Conversation

rok-cesnovar
Copy link
Member

@rok-cesnovar rok-cesnovar commented Jun 28, 2020

Submission Checklist

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

Summary

Adds the virtual function model_compile_info to the model_base, which will be used to retrieve the info about the compiler version and flags used.

Related Cmdstan PR stan-dev/cmdstan#896 and issue stan-dev/cmdstan#887

Stanc3 now adds this function to the model:

  std::vector<std::string> model_compile_info() const {
    std::vector<std::string> stanc_info;
    stanc_info.push_back("stanc_version = stanc3 e010e06c");
    stanc_info.push_back("stancflags = --warn-pedantic");
    return stanc_info;
  }

This PR adds a virtual function model_compile_info() and the generation of the same function (sans flags) in order to still support compiling models with STANC2=true. As compiling with STANC2 is only for debugging purpose, I did not implement the stancflags functionality for stanc2 as well.

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):
Rok Češnovar, Univ. of Ljubljana

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

@rok-cesnovar rok-cesnovar changed the title Feature/compile info Add virtual function model_compile_info to the model_base.hpp Jun 28, 2020
@mitzimorris
Copy link
Member

@rok-cesnovar - branch names should include issue number

@rok-cesnovar
Copy link
Member Author

rok-cesnovar commented Jun 30, 2020

I keep forgetting on the branch names. I made the branches before the issues and then forgot to rename them.
I also got really used to the Github CLI, where you can just do gh pr checkout 2932.

Anyhow this should be ready for review. I added the generation of the model_compile_info to stanc2 for 2 reasons:

  • the tests still work with stanc2
  • compiling with STANC2=true would break

The relevant issue is stan-dev/cmdstan#887

@bob-carpenter
Copy link
Member

Is there a reason this can't be a regular function instead of a virtual one? It just seems like something that would fit into the basic CRTP structure of the generated model class.

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 4.03 4.0 1.01 0.8% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.97 -2.68% slower
eight_schools/eight_schools.stan 0.09 0.09 1.03 2.48% faster
gp_regr/gp_regr.stan 0.19 0.19 1.0 0.39% faster
irt_2pl/irt_2pl.stan 5.28 5.37 0.98 -1.72% slower
performance.compilation 87.33 85.07 1.03 2.59% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 7.69 7.72 1.0 -0.44% slower
pkpd/one_comp_mm_elim_abs.stan 20.49 21.55 0.95 -5.16% slower
sir/sir.stan 93.14 97.63 0.95 -4.82% slower
gp_regr/gen_gp_data.stan 0.04 0.04 0.99 -1.41% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.13 3.03 1.03 3.3% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.32 0.32 0.98 -1.94% slower
arK/arK.stan 1.79 1.79 1.0 -0.05% slower
arma/arma.stan 0.69 0.59 1.16 13.78% faster
garch/garch.stan 0.53 0.52 1.02 1.98% faster
Mean result: 1.00682847769

Jenkins Console Log
Blue Ocean
Commit hash: 8c5ef352d01ac83747fa4ff6dc3dfb400f0c0547


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

@rok-cesnovar
Copy link
Member Author

Is there a reason this can't be a regular function instead of a virtual one? It just seems like something that would fit into the basic CRTP structure of the generated model class.

If I dont put the virtual method in model_base I get the following error

In file included from src/cmdstan/main.cpp:1:0:
src/cmdstan/command.hpp: In function ‘int cmdstan::command(int, const char**)’:
src/cmdstan/command.hpp:131:51: error: ‘class stan::model::model_base’ has no member named ‘model_compile_info’
     std::vector<std::string> compile_info = model.model_compile_info();
                                                   ^~~~~~~~~~~~~~~~~~

@bob-carpenter would you mind reviewing this? I updated the top-level comment with more details.

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 4.03 4.08 0.99 -1.07% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.0 0.02% faster
eight_schools/eight_schools.stan 0.09 0.09 1.0 -0.0% slower
gp_regr/gp_regr.stan 0.19 0.19 0.98 -1.85% slower
irt_2pl/irt_2pl.stan 5.33 5.33 1.0 -0.15% slower
performance.compilation 85.9 85.0 1.01 1.05% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 7.69 7.74 0.99 -0.55% slower
pkpd/one_comp_mm_elim_abs.stan 23.26 22.66 1.03 2.56% faster
sir/sir.stan 92.18 98.31 0.94 -6.64% slower
gp_regr/gen_gp_data.stan 0.04 0.04 1.0 -0.47% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.01 3.1 0.97 -3.07% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.32 0.33 0.97 -2.81% slower
arK/arK.stan 1.78 1.78 1.0 0.2% faster
arma/arma.stan 0.66 0.59 1.12 10.43% faster
garch/garch.stan 0.54 0.52 1.04 3.91% faster
Mean result: 1.00241562789

Jenkins Console Log
Blue Ocean
Commit hash: 8c5ef352d01ac83747fa4ff6dc3dfb400f0c0547


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

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 4.0 4.2 0.95 -4.87% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.99 -1.52% slower
eight_schools/eight_schools.stan 0.09 0.09 1.04 3.47% faster
gp_regr/gp_regr.stan 0.19 0.19 0.98 -1.73% slower
irt_2pl/irt_2pl.stan 5.32 5.41 0.98 -1.55% slower
performance.compilation 87.52 85.7 1.02 2.08% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 7.71 8.44 0.91 -9.46% slower
pkpd/one_comp_mm_elim_abs.stan 21.24 20.26 1.05 4.58% faster
sir/sir.stan 95.6 91.75 1.04 4.03% faster
gp_regr/gen_gp_data.stan 0.04 0.04 1.0 0.47% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.05 3.27 0.93 -6.96% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.32 0.34 0.96 -4.71% slower
arK/arK.stan 1.79 1.83 0.98 -2.28% slower
arma/arma.stan 0.72 0.61 1.18 15.26% faster
garch/garch.stan 0.52 0.63 0.82 -22.5% slower
Mean result: 0.989059282904

Jenkins Console Log
Blue Ocean
Commit hash: 17729d3


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

@rok-cesnovar
Copy link
Member Author

Anyone up for reviewing this?

Copy link
Member

@mitzimorris mitzimorris left a comment

Choose a reason for hiding this comment

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

LGTM!

@rok-cesnovar rok-cesnovar merged commit c0a65e2 into develop Nov 24, 2020
@rok-cesnovar rok-cesnovar deleted the feature/compile_info branch November 24, 2020 18:53
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.

4 participants