From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33504 invoked by alias); 4 Sep 2019 21:02:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 33487 invoked by uid 89); 4 Sep 2019 21:02:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 spammy= X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Sep 2019 21:02:20 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x84L2IXD089907 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 4 Sep 2019 14:02:18 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x84L2IVO089906; Wed, 4 Sep 2019 14:02:18 -0700 (PDT) (envelope-from sgk) Date: Wed, 04 Sep 2019 21:02:00 -0000 From: Steve Kargl To: Janne Blomqvist Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH,Fortran] Improve PRNG jumping when using threads Message-ID: <20190904210218.GA89799@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20190904120926.16851-1-blomqvist.janne@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190904120926.16851-1-blomqvist.janne@gmail.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-SW-Source: 2019-09/txt/msg00220.txt.bz2 On Wed, Sep 04, 2019 at 03:09:26PM +0300, Janne Blomqvist wrote: > Currently, when a new thread needs to use the RANDOM_NUMBER intrinsic, > the per-thread PRNG state is initialized by copying the master state > and then jumping forwards N*2**128 entries in the stream so that the > PRNG streams for different threads don't alias each other, where N is > the number of threads that have so far initialized the PRNG. > > With this patch the master state itself is jumped forwards once each > time a new thread initializes the PRNG, thus obviating the need to > jump through all the N-1 previous streams. Effectively turning an O(N) > algorithm into an O(1) one. > > Regtested on x86_64-pc-linux-gnu, Ok for trunk? > Ok. -- Steve