[R-pkg-devel] RFC: an interface to manage use of parallelism in packages

Andrew Robbins @ndrew @end|ng |rom robb|n@@@me
Tue Nov 21 03:34:55 CET 2023


Hi all,

While we're on the topic of BLAS thread handling, there's also the 
matter of OpenBLAS's two threading implementations. Depending on how the 
library is built, it can either use OpenMP or it can use POSIX threading.

This can cause issues in packages that call into BLAS functions in an 
OpenMP block as the POSIX threading variant will attempt to spawn N 
threads for each OpenMP thread (where N is the system-configured 
OpenBLAS thread count). This explosion of threads causes a pretty severe 
performance degradation. In my (pending) package, I currently have a 
compile-time check for POSIX-threaded OpenBLAS which calls 
openblas_set_num_threads before and after OpenMP blocks to stop this 
behavior from occurring. If R were to implement some kind of internal 
FlexiBLAS, this would need to be taken into account.


Best,

-- 
Andrew Robbins
Systems Analyst, Welch Lab<https://welch-lab.github.io>
University of Michigan
Department of Computational Medicine and Bioinformatics


-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20231120/c5dd8b5d/attachment.sig>


More information about the R-package-devel mailing list