? Mon, 30 Dec 2024 19:16:11 -0800
Ivo Welch <ivo.welch at gmail.com> ?????:
> useless.function <- function( ) {
> y <- rnorm(3); x <- rnorm(3)
> summary( lm( y ~ x )) ## useless
> NULL
> }
>
> run30 <- function(i) {
> message("run30=", i)
> useless.function()
> }
>
> run30( 0 )
> message("many mc")
> simsl <- mclapply( 1:30, run30 )
Thank you for telling us which code you're running that eventually
hangs mclapply()! I see that your example involves running lm(), which
in turn involves BLAS and LAPACK operations. It could be that when you
first run lm() in the parent process, it starts threads that take
locks. Later, when mclapply() starts child processes, those threads
don't exist there (they stay in the parent process), but the locks
remain taken, with no-one to release them - a deadlock.
Ironically, using a parallel "socket cluster" (but not "fork
cluster")
would have avoided the problem by starting a fresh process from
scratch, without any inherited locks.
It may also be possible to disable the use of parallel threads in your
BLAS/LAPACK, but the exact procedure depends on the BLAS. What's your
sessionInfo()? If you don't get a good answer here, try
R-SIG-Mac at R-project.org.
--
Best regards,
Ivan