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

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

问题描述

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

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 用于使代码在多台机器上运行
  • OpenMP 在单台计算机内运行并行模拟

现在问题来了:我想保持按需执行任务.最快的计算机必须能够执行更多的工作,而速度较慢的计算机必须能够执行更多的工作.问题划分是通过 master-worker 循环完成的,因此实现这个结果并没有实际的困难.

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.

由于工作人员执行的任务数量(要模拟的 n 个电子块)不是预先定义的,我有两条路要走:

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. 每个worker中的每个线程都有自己的RNG,用随机生成的种子(不同的生成方法)初始化.集群的不平衡会改变结果,但在这种方法中,结果尽可能随意.

  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.

每个电子都有自己的种子,无论哪个工人运行单个任务,都可以保证模拟的可重复性.必须有更好的 RNG.

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?

玩得开心

女朋友

推荐答案

在这里投票什么?

显然,只有方法#2 是可行的.每个源粒子都从它自己的稳定种子开始.它使结果可重现和可调试(因为缺少更好的词).

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).

著名的蒙特卡罗代码 MCNP5+ 很好地使用了这个方案,在多核和 MPI 上运行.要实现它,您需要具有快速跳过(又名越级或丢弃)功能的 RNG.其中有不少.它们基于快速指数计算,F. Brown 的论文,具有任意步幅的随机数生成",Trans.是.核.社会.(1994 年 11 月).基本上,使用 Brown 方法跳过是 log(N).

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.

与 MCNP5 大致相同的最简单版本在这里 https://github.com/伊万-佐托/LCG-PLE63

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

更复杂(更慢,但质量更高)的 RNG 在这里http://www.pcg-random.组织/

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

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

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