平行蒙特卡洛:可重现性还是真正的随机性? [英] Parallel MonteCarlo: reproducibility or real randomness?

查看:81
本文介绍了平行蒙特卡洛:可重现性还是真正的随机性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在准备并行计算的大学考试. 主要目的是尽可能加快关于地球磁场中电子漂移的蒙特卡洛模拟. 我已经用两层并行化开发了一些东西:

  • MPI用于使代码在多台计算机上运行
  • OpenMP在单台计算机内运行并行模拟

现在出现了一个问题:我想按需执行任务. 最快的计算机必须能够执行较慢的计算机更多的工作. 问题划分是通过主-工人周期完成的,因此,要实现此结果没有实际的困难.

由于工人的任务数量(要模拟的n个电子块)没有事先定义,因此我有两条路要走:

  1. 每个工作线程中的每个线程都有自己的RNG,并使用随机生成的种子(不同的生成方法)初始化了RNG.群集的不平衡会改变结果,但是这种方法的结果是尽可能随意的.

  2. 每个电子都有自己的种子,尽管模拟工作由哪个工人完成,但仍可实现模拟的可重复性.必须具有更好的RNG.

就此进行民意调查.你有什么建议?

玩得开心

gf

解决方案

在这里要调查什么?

显然,只有方法2是可行的.每个源粒子都以其自身的稳定种子开始.这样可以使结果具有可重现性和可调试性(因为缺少更好的用词).

著名的蒙特卡洛代码MCNP5 +很好地使用了该方案,并在多核和MPI上运行.要实现它,您将需要具有快速跳过功能(又称跳过或丢弃)的RNG.其中有很多.它们基于快速指数计算,由F. Brown发表,任意步幅生成随机数",Trans.是.核仁Soc. (1994年11月).基本上,向前跳过是使用Brown方法的log(N).

最简单的版本与MCNP5相同,在这里 https://github.com/Iwan-Zotow/LCG-PLE63

更复杂(且速度较慢,但​​质量更高)的RNG在此处 http://www.pcg-random. org/

I'm preparing a college exam in parallel computing. The main purpose is to speedup as much as possible a Montecarlo simulation about electron drift in earth magnetic field. I've already developed something with two layers of parallelization:

  • MPI used to make te code run on several machines
  • OpenMP to run parallel simulation inside the single computer

Now comes the question: I would like to keep on-demand the task execution. The fastest computer must be able to execute more work the the slower ones. The problem partition is done via master-worker cycle, so there is no actual struggle about achieving this result.

Since the number of tasks (a block of n electrons to simulate) executed by a worker is not prior defined I have two roads to follow:

  1. every thread in every worker has is own RNG initialized with random generated seed (different generation method). The unbalancing of the cluster will change results, but in this approach the result is as casual as possible.

  2. every electron has his own seed, granting reproducibility of the simulation despite of which worker runs the single task. Must have a better RNG.

Lets's poll about this. What's your suggestion?

Have fun

gf

解决方案

What to poll about here?

Clearly, only approach #2 is a feasible one. Each source particle starts with it's own and stable seed. It makes result reproducible AND debuggable (for a lack of better word).

Well-known Monte Carlo code MCNP5+ used this scheme for good, runs on multi-cores and MPI. To implement it you'll need RNG with fast skip-ahead (a.k.a. leapfrog or discard) feature. And there are quite a few of them. They are based upon fast exponent computation, paper by F. Brown, "Random Number Generation with Arbitrary Stride", Trans. Am. Nucl. Soc. (Nov. 1994). Basically, skip-ahead is log(N) with Brown approach.

Simplest version which is about the same as MCNP5 one is here https://github.com/Iwan-Zotow/LCG-PLE63

More complicated (and slower, but higher quality) RNG is here http://www.pcg-random.org/

这篇关于平行蒙特卡洛:可重现性还是真正的随机性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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