线程安全的统一随机数生成器 [英] Thread-safe uniform random number generator

查看:351
本文介绍了线程安全的统一随机数生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些平行的Fortran90代码,其中每个线程需要生成相同的随机数序列。

我有一个随机数生成器,似乎是线程不安全的,因为对于给定的种子,我完全无法在每次运行时重复相同的结果该程序。

我在整个网络上都没有成功(几乎)浏览一些线程安全的RNG代码。任何人都可以向我提供(链接到)其中一个代码?



预先感谢!

解决方案

Fortran90的一个很好的伪随机数生成器可以在英特尔数学核心矢量统计库。他们是线程安全的。另外,它为什么需要线程安全?如果您希望每个线程都获得相同的列表,请为具有相同种子的每个线程实例化一个新的PRNG。


I have some parallel Fortran90 code in which each thread needs to generate the same sequence of random numbers.

I have a random number generator that seems to be thread-unsafe, since, for a given seed, I'm completely unable to repeat the same results each time I run the program.

I surfed unsuccessfully (almost) the entire web looking for some code of a thread-safe RNG. Could anyone provide me with (the link to) the code of one?

Thanks in advance!

解决方案

A good Pseudorandom number generator for Fortran90 can be found in the Intel Math Kernel Vector Statistical Library. They are thread safe. Also, why does it need to be threadsafe? If you want each thread to get the same list, instantiate a new PRNG for each thread with the same seed.

这篇关于线程安全的统一随机数生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆