Search code examples
c++randomdistributed-computingsrand

Cross-OS distributed computing in C++, rand() issue


I'm working on a small distributed computing project. The server can't handle the calculations without crashing Apache in the process, so I'm giving these calculations to the users.

The basic idea is that I run the calculations 3 times, and the results need to be exactly the same. However, the application will need to run on Mac, Linux and Windows. Basically this means that I can't use rand().

I'm probably looking for a replacement generator which accepts a seed value (provided by the server) and gives the same results on every platform.

My question is: is that indeed what I am looking for and do you have a good recommendation, or should I be doing this in a different way?


Solution

  • Take a look at the Boost.Random facilities. They give you a broad choice of algorithms that are guaranteed to give the same results, always.