Skip to content

Commit

Permalink
Merge pull request #1010 from stan-dev/add_model_info
Browse files Browse the repository at this point in the history
Add `./model info` to obtain compile-time information
  • Loading branch information
rok-cesnovar authored May 18, 2021
2 parents b7a2321 + edd1d75 commit da4be45
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cmdstan/arguments/argument_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <cmdstan/arguments/arg_method.hpp>
#include <cmdstan/arguments/argument.hpp>
#include <cmdstan/write_stan.hpp>
#include <cmdstan/write_stan_flags.hpp>
#include <stan/services/error_codes.hpp>
#include <cstring>
#include <string>
Expand Down Expand Up @@ -86,6 +88,11 @@ class argument_parser {
print_help(info, true);
_help_flag |= true;
args.clear();
} else if (cat_name == "info") {
_help_flag |= true;
write_stan(info);
write_stan_flags(info);
return stan::services::error_codes::OK;
}

if (_help_flag) {
Expand Down
1 change: 1 addition & 0 deletions src/cmdstan/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cmdstan/write_parallel_info.hpp>
#include <cmdstan/write_profiling.hpp>
#include <cmdstan/write_stan.hpp>
#include <cmdstan/write_stan_flags.hpp>
#include <stan/callbacks/interrupt.hpp>
#include <stan/callbacks/logger.hpp>
#include <stan/callbacks/stream_logger.hpp>
Expand Down
38 changes: 38 additions & 0 deletions src/cmdstan/write_stan_flags.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef CMDSTAN_WRITE_STAN_FLAGS_HPP
#define CMDSTAN_WRITE_STAN_FLAGS_HPP

#include <stan/callbacks/writer.hpp>
#include <string>

namespace cmdstan {

void write_stan_flags(stan::callbacks::writer &writer) {
#ifdef STAN_THREADS
writer("STAN_THREADS=true");
#else
writer("STAN_THREADS=false");
#endif
#ifdef STAN_MPI
writer("STAN_MPI=true");
#else
writer("STAN_MPI=false");
#endif
#ifdef STAN_OPENCL
writer("STAN_OPENCL=true");
#else
writer("STAN_OPENCL=false");
#endif
#ifdef STAN_NO_RANGE_CHECKS
writer("STAN_NO_RANGE_CHECKS=true");
#else
writer("STAN_NO_RANGE_CHECKS=false");
#endif
#ifdef STAN_CPP_OPTIMS
writer("STAN_CPP_OPTIMS=true");
#else
writer("STAN_CPP_OPTIMS=false");
#endif
}

} // namespace cmdstan
#endif

0 comments on commit da4be45

Please sign in to comment.