Skip to content

Commit da4be45

Browse files
authored
Merge pull request #1010 from stan-dev/add_model_info
Add `./model info` to obtain compile-time information
2 parents b7a2321 + edd1d75 commit da4be45

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/cmdstan/arguments/argument_parser.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <cmdstan/arguments/arg_method.hpp>
55
#include <cmdstan/arguments/argument.hpp>
6+
#include <cmdstan/write_stan.hpp>
7+
#include <cmdstan/write_stan_flags.hpp>
68
#include <stan/services/error_codes.hpp>
79
#include <cstring>
810
#include <string>
@@ -86,6 +88,11 @@ class argument_parser {
8688
print_help(info, true);
8789
_help_flag |= true;
8890
args.clear();
91+
} else if (cat_name == "info") {
92+
_help_flag |= true;
93+
write_stan(info);
94+
write_stan_flags(info);
95+
return stan::services::error_codes::OK;
8996
}
9097

9198
if (_help_flag) {

src/cmdstan/command.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <cmdstan/write_parallel_info.hpp>
1717
#include <cmdstan/write_profiling.hpp>
1818
#include <cmdstan/write_stan.hpp>
19+
#include <cmdstan/write_stan_flags.hpp>
1920
#include <stan/callbacks/interrupt.hpp>
2021
#include <stan/callbacks/logger.hpp>
2122
#include <stan/callbacks/stream_logger.hpp>

src/cmdstan/write_stan_flags.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef CMDSTAN_WRITE_STAN_FLAGS_HPP
2+
#define CMDSTAN_WRITE_STAN_FLAGS_HPP
3+
4+
#include <stan/callbacks/writer.hpp>
5+
#include <string>
6+
7+
namespace cmdstan {
8+
9+
void write_stan_flags(stan::callbacks::writer &writer) {
10+
#ifdef STAN_THREADS
11+
writer("STAN_THREADS=true");
12+
#else
13+
writer("STAN_THREADS=false");
14+
#endif
15+
#ifdef STAN_MPI
16+
writer("STAN_MPI=true");
17+
#else
18+
writer("STAN_MPI=false");
19+
#endif
20+
#ifdef STAN_OPENCL
21+
writer("STAN_OPENCL=true");
22+
#else
23+
writer("STAN_OPENCL=false");
24+
#endif
25+
#ifdef STAN_NO_RANGE_CHECKS
26+
writer("STAN_NO_RANGE_CHECKS=true");
27+
#else
28+
writer("STAN_NO_RANGE_CHECKS=false");
29+
#endif
30+
#ifdef STAN_CPP_OPTIMS
31+
writer("STAN_CPP_OPTIMS=true");
32+
#else
33+
writer("STAN_CPP_OPTIMS=false");
34+
#endif
35+
}
36+
37+
} // namespace cmdstan
38+
#endif

0 commit comments

Comments
 (0)