CppBugs icon indicating copy to clipboard operation
CppBugs copied to clipboard

multicore utilization

Open 20csummer opened this issue 12 years ago • 5 comments

Hi all,

I'm new to CppBugs. First I want to say this project is truly awesome and thanks for the excellent work.

As a statistician and C++ amateur, I'm wondering does CppBugs support multithread/core utilization? If yes, how do I code and compile with such option?

My current compiling option is -mavx -g -O3 -std=c++0x -larmadillo

and it seems cppbugs is only using one core, so my program runs pretty slow. I tried adding in -lboost_thread-mt, but it doesn't help.

Thanks in advance for any help!

20csummer avatar Mar 26 '13 12:03 20csummer

Thanks for the support.

The way to use multicore is to use a multithreaded lapack/blas. you will then benefit from the speed up directly in the matrix ops.

It's very hard to multi-thread the sampler itself. I think you'll find some research in that area if you search online. One other possibility is to do a simple parallel loop to sum of the logp's of each node. Since, most models only have a few nodes (single digits typically), I'm not sure how much benefit one would get out of this change.

Feel free to email me the model if you want some help trying to speed it up.

-Whit

armstrtw avatar Mar 26 '13 12:03 armstrtw

Hi Whit,

Thanks for the fast reply. For some reason, the R wrapped version of cppbugs can utilize four cores so it runs much faster than pure C++. I'll investigate the differences.

Thanks again

20csummer avatar Mar 26 '13 15:03 20csummer

Yeah, there's a whole art to getting this configured correctly. Which version of lapack/blas you pick up will depend on how your armadillo was set up when it was installed.

Dirk has done a lot of work on the R packages to make sure they point to R's lapcack and blas.

you might try re-installing http://packages.debian.org/source/sid/openblas and then doing a reconfig on lapack.

There is also 'GOTO_NUM_THREADS' assuming you are using goto blas.

http://www.mathworks.com/matlabcentral/newsreader/view_thread/174211

-Whit

armstrtw avatar Mar 26 '13 15:03 armstrtw

I realized the problem of my code is that I used loops instead of vectors/matrices in the major part of deterministic functions. After vectoring everything, now it runs blazingly fast!

Thanks again!

20csummer avatar Mar 28 '13 16:03 20csummer

Great.

That's good to hear. Good luck!

-Whit

On Thu, Mar 28, 2013 at 12:04 PM, 20csummer [email protected]:

I realized the problem of my code is that I used loops instead of vectors/matrices in the major part of deterministic functions. After vectoring everything, now it runs blazingly fast!

Thanks again!

— Reply to this email directly or view it on GitHubhttps://github.com/armstrtw/CppBugs/issues/12#issuecomment-15596989 .

armstrtw avatar Mar 29 '13 00:03 armstrtw