4
« on: November 25, 2008, 05:57:39 PM »
well, I have done it. I have a bench mark on using concurrency with how just::thread can effect how the Mersienne Twister psuedorandom number generator can benefit from multi threading.
the the application is running in debug on vista ultimate x64 on a AMD Athlon 64 x2 Dual core 4200+ clocked at 2.21 ghz with 4 GB Ram.
the first concurrency test runs using 4 threads to simulate the ~performance of an x4 processor though I expect the results to be better. then I disable concurrency which shuts down the extra threads and only leaves the main thread of execution. then I re-enable the threaded execution which creates threads of execution based on hardware concurrency which is 2 on my computer.
here are the results:
generating 20,000,000 random numbers using hardware concurrency!
plus two threads simulate x4 core processor.
2.23366 seconds
generating 20,000,000 random numbers using main thread of execution!
2.45851 seconds
generating 20,000,000 random numbers using hardware concurrency!
2.42844 seconds
generating 20,000,000 random numbers using main thread of execution!
2.42402 seconds
generating 20,000,000 random numbers using hardware concurrency!
2.30001 seconds
generating 20,000,000 random numbers using main thread of execution!
2.43711 seconds
generating 20,000,000 random numbers using hardware concurrency!
2.35871 seconds
as you notice in the above sample the main thread of execution out performed the threaded only once out of all the iterations of generating 20 million random numbers. the majority of the time the threaded implementation of the random number generator out performed the syncronous version of the algorithm.
Kenneth
P.S. Anthony your advice on how to handle the thread control was key in getting this performance. though I am not using a while loop to control the wait. I use an if statement because the only time the threads will ever wake up is when a call is made to generate();