22
33# running and parsing exe info --------------------------------
44# run <model> info command
5+ # ' @example `.cmdstan/bin`
56run_info_cli <- function (exe_file ) {
67 withr :: with_path(
78 c(
@@ -76,6 +77,7 @@ model_compile_info <- function(exe_file, version) {
7677}
7778
7879# convert to compile flags --------------------
80+ # from list(flag1=TRUE, flag2=FALSE) to "FLAG1=TRUE\nFLAG2=FALSE"
7981cpp_options_to_compile_flags <- function (cpp_options ) {
8082 if (length(cpp_options ) == 0 ) {
8183 return (NULL )
@@ -94,7 +96,8 @@ cpp_options_to_compile_flags <- function(cpp_options) {
9496
9597
9698# check options overall for validity ---------------------------------
97-
99+ # takes list of options as input and returns list of options
100+ # returns list with names standardized to lowercase
98101validate_cpp_options <- function (cpp_options ) {
99102 if (is.null(cpp_options ) || length(cpp_options ) == 0 ) return (list ())
100103
@@ -129,7 +132,9 @@ validate_cpp_options <- function(cpp_options) {
129132}
130133
131134# check specific options for validity ---------------------------------
132-
135+ # no type checking for opencl_ids
136+ # cpp_options must be a list
137+ # opencl_ids returned unchanged
133138assert_valid_opencl <- function (opencl_ids , cpp_options ) {
134139 if (is.null(cpp_options [[" stan_opencl" ]])
135140 && ! is.null(opencl_ids )) {
@@ -140,6 +145,7 @@ assert_valid_opencl <- function(opencl_ids, cpp_options) {
140145 invisible (opencl_ids )
141146}
142147
148+ # cpp_options must be a list
143149assert_valid_threads <- function (threads , cpp_options , multiple_chains = FALSE ) {
144150 threads_arg <- if (multiple_chains ) " threads_per_chain" else " threads"
145151 checkmate :: assert_integerish(threads , .var.name = threads_arg ,
@@ -164,7 +170,11 @@ assert_valid_threads <- function(threads, cpp_options, multiple_chains = FALSE)
164170 invisible (threads )
165171}
166172
167- # compare exe info and cpp options to one another
173+ # For two functions below
174+ # both styles are lists which should have flag names in lower case as names of the list
175+ # cpp_options style means is NULL or empty string
176+ # exe_info style means off is FALSE
177+
168178exe_info_style_cpp_options <- function (cpp_options ) {
169179 if (is.null(cpp_options )) cpp_options <- list ()
170180 names(cpp_options ) <- tolower(names(cpp_options ))
0 commit comments