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

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Nov 21 17:17:51 CET 2023


В Mon, 20 Nov 2023 21:34:55 -0500
Andrew Robbins via R-package-devel <r-package-devel using r-project.org>
пишет:

> 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.

This may be not enough. In distributions like Debian, it's possible (if
not common) to install multiple BLAS implementations and switch them
between program runs using update-alternatives, so it's possible to
compile and link a package using one BLAS then run it using another
BLAS.

May I suggest using dlsym() to check whether openblas_get_parallel()
is present in the current process and perform the check during run-time?

(Sorry about not returning to this topic earlier. I do think that a
semaphore is the right choice and I do intend to implement this
interface using semaphores within a few weeks if not a few days.)

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list