|
Boost Users : |
Subject: [Boost-users] [Thread] (Newb) shared memory in multithread process
From: gabe_rosser (gabriel.rosser_at_[hidden])
Date: 2009-07-09 12:37:11
Dear All,
Apologies for my ignorance but I would be extremely grateful if someone
would kindly point me in the right direction.
I am trying to parallelize my Monte Carlo simulation. The bottleneck in the
process is the generation of Normally distributed random numbers (using
boost.random libraries), so I was hoping to substantially improve the
efficiency of the process by setting 2 or 3 cores of my quad core processor
to the the task of generating these numbers while one core gets on with the
rest of the algorithm.
The simplest way I can envisage doing this is by allocating shared memory
that is simultaneously written (by rand number generating threads) and read
(by main thread), with some method of ensuring that the main thread doesn't
read too far ahead (perhaps locking or just a simple while loop?).
Boost.thread alone doesn't seem to be enough - an attempt to do exactly this
resulted in a substantial slow down (with or without locking - without may
result in undefined behaviour but I tried it anyway to see if it was causing
the slowdown). Do I need to investigate shared pointers? I really need
some large container in shared memory which I can fill in any order, much as
would be the case if I were appending to and reading from a file, but
hopefully faster!
Any suggestions please? Sorry for the lack of understanding!
Thanks,
Gabe
-- View this message in context: http://www.nabble.com/-Thread--%28Newb%29-shared-memory-in-multithread-process-tp24409906p24409906.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net