jonlachmann / GMJMCMC

1 stars 1 forks source link

open blas threaring feature, not a bug #28

Open aliaksah opened 5 months ago

aliaksah commented 5 months ago

When the "normal" gmjmcmc function is running, calculating this one run will start a single process that accesses 11 threads (unfortunately I don't know why there are exactly 11) (see screenshot #1 for the corresponding display) However, if the gmjmcmc.parallel function is called with a certain number of runs and cores, min(#runs, #cores) processes are started, but only access ONE thread at a time. (see screenshot #2 for the display after calling gmjmcmc.parallel with cores=8 and runs=20).

What I conclude from this: When calling the "normal" gmjmcmc function, my Macbook automatically accesses multiple threads to calculate a single run. However, when the gmjmcmc.parallel function is called, only a single thread is assigned to each run. It is therefore not surprising that on my Macbook, for example, the gmjmcmc.parallel with Runs = Cores takes significantly longer than the "normal" gmjmcmc function with otherwise the same arguments.

I don't think the internal functionality of gmjmcmc.parallel is intended to work that way, but unfortunately I can't say more about it due to my lack of knowledge about the connection between R and the CPU. It's also quite possible that this behavior is due to some specific setting on my Macbook, but I thought you might still be interested in this because (at least on my Macbook) it shows the advantages of using gmjmcmc.parallel over the "normal " gmjmcmc function significantly reduced.

Screenshot 2024-03-25 at 19 52 13

aliaksah commented 5 months ago

will the following be helpful for fixing the issue

library(RhpcBLASctl) blas_set_num_threads(1) omp_set_num_threads(1)