From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d541063ff843658f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 X-Received: by 10.180.75.8 with SMTP id y8mr2127279wiv.1.1362421413637; Mon, 04 Mar 2013 10:23:33 -0800 (PST) Path: bp2ni72442wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.131.MISMATCH!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.thorslund.org!news.jacob-sparre.dk!hugin.jacob-sparre.dk!nuzba.szn.dk!pnx.dk!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Parallel_Simulation Date: Mon, 25 Feb 2013 13:30:49 -0500 Organization: The Wasteland Message-ID: References: NNTP-Posting-Host: LQJtZWzu+iKlBROuDg+IUg.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2013-02-25T13:30:49-05:00 List-Id: In article , Vincent LAFAGE wrote: > Le 25/02/2013 13:40, John B. Matthews a écrit : > > In article , > > Vincent LAFAGE wrote: > > > >> I am interested in MonteCarlo simulation and I had translated a > >> former F77 code to Ada with success, with the goal of > >> parallelizing it, but one part in the algorithm still resists > >> parallelization: the random number generator. I need the different > >> worker to rely on independant random number generators. > >> > >> Then I found a precious example in > >> RM-A-5-2 59., 60., 61. > >> that compiles smoothly. > >> > >> I will now attempt to check the independance of the sequence > >> generated by each thread. But this kind of check is always more > >> subtle than expected. > >> > >> I wonder whether there is a statement about the independance of > >> such generator, in particular in the gnat implementation? > > > > You should check your implementation's required documentation and > > any statements on implementation advice. For example, GNAT includes > > a comment in Ada.Numerics.Float_Random.ads, and the GNAT Reference > > Manual says, "The generator period is sufficiently long for the > > first condition here [A.5.2(47)] to hold true." > > Thanks for the advice, but the particular doesn't exactly fit my > question. I understand that the sequence is long enough. But > different seeds will in the end be different starting points along > the same sequence (well, at least for congruential generators, I > still have to confirm it for Mersenne Twister algorithm that is > used). And this would in turn lead to fine correlations between the > sequences. > > The best statement I have found until now is in gnat_rm-4.6.info: > > *67*. The minimum time interval between calls to the time-dependent > Reset procedure that are guaranteed to initiate different random > number sequences. See A.5.2(45). > The minimum period between reset calls to guarantee distinct > series of random numbers is one microsecond. > > So I need to assert the delay between the reset of each worker in > RM-A-5-2 60 to be sure that there is at least one microsecond. IIUC, the example in A.5.2(60) uses the version of Reset that is _not_ time-dependent; it initializes each Worker's generator to "a state denoted by a single integer." As long as you're not using the time-dependent version, I don't see how the minimum period would come into play. > Would you think of another way? If you Reset a single instance of Discrete_Random in a time-dependent way and use it to generate each Worker's Initiator, as suggested in A.5.2(61), I don't see much chance of correlation. -- John B. Matthews trashgod at gmail dot com