Skip to content

Commit

Permalink
Now availableCores() recognizes PBSPro environment variable 'NCPUS' […
Browse files Browse the repository at this point in the history
…#22]
  • Loading branch information
HenrikBengtsson committed Apr 10, 2019
1 parent 7c33b08 commit 501978c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Package: future
===============

Version: 1.12.0-9000 [2019-04-01]
Version: 1.12.0-9000 [2019-04-10]

NEW FEATURES:

* Now availableCores() recognizes PBSPro environment variable 'NCPUS'.

* makeClusterPSOCK() gained support for argument 'rscript_init' for
evaluating one or more R expressions in the background R worker prior
to the worker event loop being launched. This provides a more convenient
Expand Down
7 changes: 6 additions & 1 deletion R/availableCores.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#' parameter may or may not default to one.
#' An example of a job submission that results in this is
#' \code{qsub -l nodes=1:ppn=2}, which requests one node with two cores.
#' \item \code{"PBSPro"} -
#' Query PBSPro environment variable \env{NCPUS}.
#' \item \code{"SGE"} -
#' Query Sun/Oracle Grid Engine (SGE) environment variable
#' \env{NSLOTS}.
Expand Down Expand Up @@ -83,7 +85,7 @@
#'
#' @export
#' @keywords internal
availableCores <- function(constraints = NULL, methods = getOption("future.availableCores.methods", c("system", "mc.cores", "_R_CHECK_LIMIT_CORES_", "PBS", "SGE", "Slurm", "fallback")), na.rm = TRUE, default = c(current = 1L), which = c("min", "max", "all")) {
availableCores <- function(constraints = NULL, methods = getOption("future.availableCores.methods", c("system", "mc.cores", "_R_CHECK_LIMIT_CORES_", "PBS", "PBSPro", "SGE", "Slurm", "fallback")), na.rm = TRUE, default = c(current = 1L), which = c("min", "max", "all")) {
## Local functions
getenv <- function(name) {
as.integer(trim(Sys.getenv(name, NA_character_)))
Expand All @@ -106,6 +108,9 @@ availableCores <- function(constraints = NULL, methods = getOption("future.avail
} else if (method == "PBS") {
## Number of cores assigned by TORQUE/PBS
n <- getenv("PBS_NUM_PPN")
} else if (method == "PBSPro") {
## Number of cores assigned by PBSPro
n <- getenv("NCPUS")
} else if (method == "SGE") {
## Number of cores assigned by Sun/Oracle Grid Engine (SGE)
n <- getenv("NSLOTS")
Expand Down
8 changes: 5 additions & 3 deletions man/availableCores.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 501978c

Please sign in to comment.