File: autodetectCpus.R

package info (click to toggle)
r-cran-parallelmap 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: sh: 13; makefile: 2
file content (14 lines) | stat: -rw-r--r-- 448 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
autodetectCpus = function(mode) {
  if (mode == MODE_MULTICORE) {
    cpus = detectCores()
  } else if (mode == MODE_MPI) {
    cpus = max(1L, Rmpi::mpi.universe.size() - 1L)
  } else {
    cpus = NA_integer_
  }
  if (!testCount(cpus, positive = TRUE)) {
    stopf("The was some problem in autodetecting the number of cpus. Autodetection returned:\n%s", printStrToChar(cpus))
  }
  showInfoMessage("Autodetecting cpus: %i", cpus)
  return(cpus)
}