if you're using gcc of a recent enough version, you can use the <random> header, and follow the information in the C++ reference
Thanks, but as far as I have read online, they are not thread safe either? Or have I misunderstood something? It was not entirely clear from the discussion, there are varying opinions.
Last edited by Niels_M; 04-09-2013 at 03:20 PM.
but if you create one per thread, in conjunction with std::thread or boost::thread, then you wouldn't need to worry about thread safety, because each thread owns its RNG. since you said you have 6 cores, you could theoretically start 6 threads to generate n/6 numbers, and then merge them all together into one vector at the end.
Ah, I see what you mean. That seems like a good approach. It is not stated 100% explicitly, but is this an example of how to achieve your suggestion? If yes, then it is not clear to me, where in that example a unique RNG is assigned to each thread.
I'm very happy for your contribution so far. Hopefully I can nail this thing very soon and finally see some progress.
I'm not really very familiar with openmp, so I can't really say if that's what I was talking about. personally, I would do it explicitly with std::thread or boost::thread, but that's just what I'm most comfortable with.
OK, I'll have to keep working on this.. thanks to everyone for participating and helping me advance.
Locking kills. Find an algorithm that doesn't require locking.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}