setMesaParallel() enables/disables parallelisation (and may register a backend); getMesaParallel() returns the current setting.

setMesaParallel(nCores = NULL, useParallel = FALSE, verbose = TRUE)

getMesaParallel(verbose = FALSE)

Arguments

nCores

integer(1) or NULL. If > 1 on Unix/macOS, registers BiocParallel::MulticoreParam(workers = nCores) and enables parallel mode. Ignored on Windows (see Details). Default: NULL.

useParallel

logical(1). Explicitly turn mesa parallelisation on/off (sets the "mesa_parallel" option). If nCores > 1, this is treated as TRUE. Default: FALSE.

verbose

Boolean to determine whether to print messages or not.

Value

  • setMesaParallel() — logical scalar (TRUE/FALSE), returned invisibly; primarily used for its side effects (setting the option and possibly registering a backend).

  • getMesaParallel() — logical scalar indicating whether mesa parallelisation is currently enabled; with verbose = TRUE, also prints a status message.

Details

  • This function stores the flag in options(mesa_parallel = <TRUE/FALSE>).

  • On Unix/macOS, supplying nCores > 1 will register a MulticoreParam backend via BiocParallel::register() and enable parallelisation.

  • On Windows, forked backends are unavailable; you should manually register a compatible backend (e.g., SnowParam) and then call setMesaParallel(useParallel = TRUE).

  • You can always inspect the active backend with BiocParallel::bpparam() and the worker count with BiocParallel::bpworkers().

Functions

  • getMesaParallel(): Get whether mesa is using parallelisation.

Examples

# Turn parallelisation OFF (serial evaluation)
setMesaParallel(useParallel = FALSE, verbose = FALSE)
getMesaParallel() # FALSE
#> [1] FALSE

# --- Unix/mac (MulticoreParam): enable and use 2 cores ---
if (FALSE) { # \dontrun{
if (.Platform$OS.type != "windows") {
    old <- BiocParallel::bpparam() # save current backend
    setMesaParallel(nCores = 2, verbose = FALSE)
    # registers MulticoreParam(2)
    BiocParallel::bpworkers() # e.g. 2
    getMesaParallel() # TRUE
    BiocParallel::register(old) # restore previous backend
    setMesaParallel(useParallel = FALSE, verbose = FALSE) # back to serial
}
} # }

# --- Windows: register SnowParam yourself, then enable ---
if (FALSE) { # \dontrun{
if (.Platform$OS.type == "windows") {
    old <- BiocParallel::bpparam()
    BiocParallel::register(BiocParallel::SnowParam(workers = 2))
    setMesaParallel(useParallel = TRUE, verbose = FALSE)
    BiocParallel::bpworkers() # e.g. 2
    getMesaParallel() # TRUE
    BiocParallel::register(old)
    setMesaParallel(useParallel = FALSE, verbose = FALSE)
}
} # }