开发者

Distributed computing with different random number generators

I have a computation/simulation system with one master server and (potentially) many clients (workers). All of them are working with the same data but need random numbers for the computation.

What would be the best PRNG and the best way to seed it to make sure that 开发者_StackOverflowtwo clients aren't using the same cycle and computing the same results twice.


One of the joys of random numbers is that you can't guarantee the sequences aren't identical. However, you can make it unlikely by xoring the time and something unique to the system -- the MAC address, a hash of the Name, or the IP address come to mind.


The problem with seeding from something machine based (MAC address, name, IP address) is that the seed will always be the same on the same machine.

Usually seeds come from the current time. If all the worker machines start their process at the same time then they will all have the same seed.

Easiest way to deal with this is to combine the two values. Generating a seed from a machine hash and the current time will give you a unique seed per machine that changes after each run.

Another option to create a random number generator on the master, and have each worker get its seed from the master.


Couple of ideas, seed it from something unique on the client such as the MAC address of the client.

Or, have the master generate a random number and pass that as the seed to use with the work item to the client.


How random do you need them to be?

boost-random has some PRNGs that I believe have some good theoretical background on them if you need it. You can make sure to use different seeds by having your server hand out the seeds together with the work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜