Skip to contents

The parallel parts of the package run on a thread pool owned by it. shoal_threads(n) rebuilds that pool with n threads; shoal_threads() reports the current size. The setting takes effect immediately and lasts for the session.

Usage

shoal_threads(n)

Arguments

n

Number of threads, a positive whole number. Omit to query.

Value

The number of threads in the pool, invisibly when setting.

Details

Parallel work covers shoal_evoc()'s neighbour search, spanning tree and node embedding; shoal_dbscan()'s neighbour queries and shoal_hdbscan()'s core distances and spanning tree; shoal_kmeans()'s assignment step and initialisation, which the Gaussian mixture shares through its k-means start; shoal_dist(); and shoal_silhouette(). Hierarchical clustering and the mixture's EM iterations are single-threaded. Results never depend on the thread count.

Default

On load the pool takes, in order of precedence, the shoal.threads option, the RAYON_NUM_THREADS environment variable, or one thread per logical core. When _R_CHECK_LIMIT_CORES_ is set, as it is by R CMD check --as-cran, the automatic default is capped at 2 to respect the CRAN policy for checks; an explicit option or variable is still honoured.

Examples

old <- shoal_threads()
shoal_threads(2)
shoal_threads()
#> [1] 2
shoal_threads(old)