Skip to content

change cpp_options[["stan_threads"]] to cpp_options[["STAN_THREADS"]] #1100

Description

@toddpocuca

This issue was discussed in wlandau/instantiate#30 and the solution recommended was to create an issue here to ask for capitalizing "stan_threads" in

cmdstanr/R/cpp_opts.R

Lines 149 to 171 in 5f2a8c8

assert_valid_threads <- function(threads, cpp_options, multiple_chains = FALSE) {
threads_arg <- if (multiple_chains) "threads_per_chain" else "threads"
checkmate::assert_integerish(threads, .var.name = threads_arg,
null.ok = TRUE, lower = 1, len = 1)
if (is.null(cpp_options[["stan_threads"]]) || !isTRUE(cpp_options[["stan_threads"]])) {
if (!is.null(threads)) {
warning(
"'", threads_arg, "' is set but the model was not compiled with ",
"'cpp_options = list(stan_threads = TRUE)' ",
"so '", threads_arg, "' will have no effect!",
call. = FALSE
)
threads <- NULL
}
} else if (isTRUE(cpp_options[["stan_threads"]]) && is.null(threads)) {
stop(
"The model was compiled with 'cpp_options = list(stan_threads = TRUE)' ",
"but '", threads_arg, "' was not set!",
call. = FALSE
)
}
invisible(threads)
}
.

I don't know if this would be possible or if it would also be allowed for both "stan_threads " and "STAN_THREADS" to point to the same setting internally, but this would fix an issue with getting instantiate to allow for pre-compiling with multi-threading allowed without generating a warning.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions