Hello,
Thanks for the response (and the awesome library). I am somewhat new to the ThreadLocal class and so was great to hear about this.
So I have a step in an MCMC routine that runs parallel across multiple threads (in theory they are completely independent). Right now I am using ThreadLocal<Mersenne> on each one and running that through. It seems to be reasonably fast in the sense that I don’t see any memory contentions at present. I think this might be ideal because the parameter for the poisson change on each call, so I can’t preallocate the poisson (but could the uniforms).
I think prefilling an array would be involve a lot more contention if all threads were using it relative to the threadlocal RNGs, but I may be mistaken.
Thanks again for the help!
Nigel
PS As a random factoid I recently found out that the .NET System.Random class has been coded incorrectly and so does not represent the actual algorithm they state in the documentation (see http://connect.microsoft.com/VisualStudio/feedback/details/634761/system-random-serious-bug, apparently they copied it wrong from numeric recipes). Not sure how big of an issue this is though.
Thanks for the response (and the awesome library). I am somewhat new to the ThreadLocal class and so was great to hear about this.
So I have a step in an MCMC routine that runs parallel across multiple threads (in theory they are completely independent). Right now I am using ThreadLocal<Mersenne> on each one and running that through. It seems to be reasonably fast in the sense that I don’t see any memory contentions at present. I think this might be ideal because the parameter for the poisson change on each call, so I can’t preallocate the poisson (but could the uniforms).
I think prefilling an array would be involve a lot more contention if all threads were using it relative to the threadlocal RNGs, but I may be mistaken.
Thanks again for the help!
Nigel
PS As a random factoid I recently found out that the .NET System.Random class has been coded incorrectly and so does not represent the actual algorithm they state in the documentation (see http://connect.microsoft.com/VisualStudio/feedback/details/634761/system-random-serious-bug, apparently they copied it wrong from numeric recipes). Not sure how big of an issue this is though.