Please forget my sample code!! As I realized, the different threads do not hold the initializsation of the random number generators but do it each time anew, thus each thread generates the same random number again and again.
I am sorry!! Best wishes, -- Klaus. > Dear Rhys, > > sorry, but I do not get your point. Could you elaborate on it in more > detail? > > Furthermore, I do not fully get what Altro is doing. I have the impression > that he is calculating the random numbers in advance. > > That is what I do 'not' suggest with my C++11 wrapper but simply make the > random number generator available to each thread seeded differently. > > So, finally, if the main part of the calculating in Altros code happens in > the for lopp, why not directly initialize the random number generator > there, see the appended minimal example 'me-altro.c' > > Best wishes and keep uns informed, > -- Klaus. > > > > > >>> I would simply use a wrapper around a C++ std::vector who holds as many >>> C++11 random number generators (engines) as you use threads in your >>> code. >>> By calling a random number, the engine in the ith index of the vector >>> is >>> used, where i is the thread id. >> >> If your threads aren't doing much work beyond random number >> generation, you might see a less-than-ideal speedup due to contention >> on the contiguous std::vector memory. >> >> Not that you will see such a thing, but suspect it if you run into a >> wall. >> >> - Rhys >> >