Skip to content

Commit

Permalink
availableCores() gained support for the Fujitsu Technical Computing S…
Browse files Browse the repository at this point in the history
…uite [#82]
  • Loading branch information
HenrikBengtsson committed May 28, 2022
1 parent 06174bf commit 1704996
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: parallelly
Version: 1.31.1-9002
Version: 1.31.1-9003
Title: Enhancing the 'parallel' Package
Imports:
parallel,
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Version 1.31.1-9002 [2022-05-19]
# Version (development version)

## New Features

* `availableCores()` gained support for the
Fujitsu Technical Computing Suite. Specifically, it acknowledges
environment variables `PJM_VNODE_CORE` and `PJM_PROC_BY_NODE`.

## Bug Fixes

Expand Down
23 changes: 22 additions & 1 deletion R/availableCores.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
#' \env{LSB_DJOB_NUMPROC}.
#' Jobs with multiple (CPU) slots can be submitted on LSF using
#' `bsub -n 2 -R "span[hosts=1]" < hello.sh`.
#' \item `"PJM"` -
#' Query Fujitsu Technical Computing Suite (that we choose to shorten
#' as "PJM") environment variables \env{PJM_VNODE_CORE} and
#' \env{PJM_PROC_BY_NODE}.
#' The first is set when submitted with `pjsub -L vnode-core=8 hello.sh`.
#' \item `"custom"` -
#' If option \option{parallelly.availableCores.custom} is set and a function,
#' then this function will be called (without arguments) and it's value
Expand Down Expand Up @@ -165,7 +170,7 @@
#'
#' @importFrom parallel detectCores
#' @export
availableCores <- function(constraints = NULL, methods = getOption2("parallelly.availableCores.methods", c("system", "cgroups.cpuset", "cgroups.cpuquota", "nproc", "mc.cores", "BiocParallel", "_R_CHECK_LIMIT_CORES_", "PBS", "SGE", "Slurm", "LSF", "fallback", "custom")), na.rm = TRUE, logical = getOption2("parallelly.availableCores.logical", TRUE), default = c(current = 1L), which = c("min", "max", "all"), omit = getOption2("parallelly.availableCores.omit", 0L)) {
availableCores <- function(constraints = NULL, methods = getOption2("parallelly.availableCores.methods", c("system", "cgroups.cpuset", "cgroups.cpuquota", "nproc", "mc.cores", "BiocParallel", "_R_CHECK_LIMIT_CORES_", "PBS", "SGE", "Slurm", "LSF", "PJM", "fallback", "custom")), na.rm = TRUE, logical = getOption2("parallelly.availableCores.logical", TRUE), default = c(current = 1L), which = c("min", "max", "all"), omit = getOption2("parallelly.availableCores.omit", 0L)) {
## Local functions
getenv <- function(name, mode = "integer") {
value <- trim(getEnvVar2(name, default = NA_character_))
Expand Down Expand Up @@ -257,6 +262,22 @@ availableCores <- function(constraints = NULL, methods = getOption2("parallelly.
} else if (method == "LSF") {
## Number of slots assigned by LSF
n <- getenv("LSB_DJOB_NUMPROC")
} else if (method == "PJM") {
## Number of slots assigned by Fujitsu Technical Computing Suite
## We choose to call this job scheduler "PJM" based on the prefix
## it's environment variables use.
## PJM_VNODE_CORE: e.g. pjsub -L vnode-core=8
## "This environment variable is set only when virtual nodes
## are allocated, and it is not set when nodes are allocated."
n <- getenv("PJM_VNODE_CORE")
if (is.na(n)) {
## PJM_PROC_BY_NODE: e.g. pjsub -L vnode-core=8
## "Maximum number of processes that are generated per node by
## an MPI program. However, if a single node (node=1) or virtual
## node (vnode=1) is allocated and the mpi option of the pjsub
## command is not specified, this environment variable is not set."
n <- getenv("PJM_PROC_BY_NODE")
}
} else if (method == "mc.cores") {
## Number of cores by option defined by 'parallel' package
n <- getopt("mc.cores")
Expand Down
7 changes: 6 additions & 1 deletion man/availableCores.Rd

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

0 comments on commit 1704996

Please sign in to comment.