How to generate random numbers in parallel?

后端 未结 6 768
慢半拍i
慢半拍i 2020-11-30 07:04

I want to generate pseudorandom numbers in parallel using openMP, something like this:

int i;
#pragma omp parallel for
for (i=0;i<100;i++)
{
    printf(\"         


        
6条回答
  •  迷失自我
    2020-11-30 07:21

    Random numbers can be generated very fast,so usually the memory would be the bottleneck. By dividing this task between several threads you create additional communication and syncronization overheads (and sinchronization of caches of different cores is not cheap).

    It would be better to use a single thread with a better random() function.

提交回复
热议问题