stringdist-parallelization: Multithreading and parallelization in stringdist
Description
Multithreading and parallelization in stringdistMultithreading and parallelization in <pkg>stringdist</pkg>
The core
functions of stringdist are implemented in C. On systems where
openMP is available, stringdist will automatically take
advantage of multiple cores. The
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#OpenMP-support{section
on OpenMP} of the
https://cran.r-project.org/doc/manuals/r-release/R-exts.html{Writing
R Extensions} manual discusses on what systems OpenMP is available (at the time of writing more or
less, anywhere except on OSX).By default, the number of threads to use is taken from options('sd_num_thread').
When the package is loaded, the value for this option is determined as follows:
- The number of available cores is determined with
parallel::detectCores()
- If available, the environment variable
OMP_THREAD_LIMIT is determined
- The number of threads is set to the lesser of
OMP_THREAD_LIMIT and the number of detected cores.
- If the number of threads larger then or equal to $4$, and
OMP_THREAD_LIMIT is not set, it is set to 'sd_num_thread'-1 .eqn
$n-1$code
'nthread'href
http://cran.r-project.org/package=microbenchmarkDetails
This page describes how stringdist uses parallel processing.