On Tue, Nov 23, 2021 at 12:06 PM Gábor Csárdi <csardi.ga...@gmail.com> wrote: > > On Tue, Nov 23, 2021 at 8:49 PM Henrik Bengtsson > <henrik.bengts...@gmail.com> wrote: > > > > > Is there any reliable way to let packages to know if they are on CRAN, so > > > they can set omp cores to 2 by default? > > > > Instead of testing for "on CRAN" or not, you can test for 'R CMD > > check' running or not. 'R CMD check' sets environment variable > > _R_CHECK_LIMIT_CORES_=TRUE. You can use that to limit your code to run > > at most two (2) parallel threads or processes. > > AFAICT this is only set with --as-cran and many CRAN machines don't > use that and I am fairly sure that some of them don't set this env var > manually, either.
Oh my - yes & yes, especially on the second part - I totally forgot. So, that alone is not sufficient. It's not meant to be easy, eh? So, parallelly::availableCores() tries to account for this as well by detecting that 'R CMD check' runs, cf. https://github.com/HenrikBengtsson/parallelly/blob/3e403f600e7181423b9d77c739373d36b4fe34df/R/zzz.R#L42-L47 /Henrik > > Gabor > > [...] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel