Random Number to each Process in MPI

前端 未结 2 567
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 05:54

I\'m using MPICH2 to implement an \"Odd-Even\" Sort. I did the implementation but when I randomize to each process his value, the same number is randomized to all processe

2条回答
  •  萌比男神i
    2020-12-19 06:15

    It's because your seed does not change enough and the randomness depends on your seed.

    From the srand docs:

    For every different seed value used in a call to srand, the pseudo-random number generator can be expected to generate a different succession of results in the subsequent calls to rand.

    EDIT: Try generating the seed beforehand or change the seed by hand for every srand call.

提交回复
热议问题