From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49100 invoked by alias); 8 Aug 2016 11:01:47 -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 49076 invoked by uid 89); 8 Aug 2016 11:01:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Seed, synthetic, kargl, sk:random_ X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 08 Aug 2016 11:01:36 +0000 Received: by mail-wm0-f53.google.com with SMTP id f65so111172420wmi.0; Mon, 08 Aug 2016 04:01:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=tuF7yUPlq/bD5Usefqy1+aEGh+4/UJN/BCbsweORyn8=; b=GQoGSUvUTbUuZPc6MQUJ/94XKwfqtmbmRa34w9Fu1FkPeTjgrjXpMrik5JjH00/NW3 kxaA8mQZUZKHz+jzHLjCKeDUbg7OAnbkohFgCsxMZTk0l03aian1udbg7hC18MS+EEfx Wb3tw8xWv/Eug4YGzd0Nl5cK+gzlqlyUb/1KaE0Be8s+pcJTy1WzsuJk3WF/kGfsib4e Vjajm9/2D/NT3GY72EBta4uU8VwQEdqbAOoYZoBYR0H/mVVIK/7tewl9iKlLlZ5ubJAh QjBd0zNSdLGTYqYQpwqZQ8iS6xsHSh2OlGINOEfJ9EJLPZjelwj+8Y5q6adFuH4xJLfs 4Y7g== X-Gm-Message-State: AEkoouuR5LR1s0ek9xGBeSYIpDlAFS5aFwb+KqroDBecgGzFjOShImQ6kx8EZA+lGIqZJkJC/tOuOezsGtY6Ug== X-Received: by 10.28.152.5 with SMTP id a5mr15870178wme.76.1470654092534; Mon, 08 Aug 2016 04:01:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.173.40 with HTTP; Mon, 8 Aug 2016 04:01:31 -0700 (PDT) In-Reply-To: References: From: Janne Blomqvist Date: Mon, 08 Aug 2016 11:01:00 -0000 Message-ID: Subject: Re: [Patch, libfortran] Multi-threaded random_number To: Fortran List , GCC Patches Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-08/txt/msg00589.txt.bz2 PING**2 On Sun, Jul 24, 2016 at 4:45 PM, Janne Blomqvist wrote: > Hi, > > the attached patch replaces the current random_number / random_seed > implementations with an implementation that better supports threads. > It's an improved version of the RFC patch I posted earlier at > https://gcc.gnu.org/ml/gcc-patches/2015-12/msg02110.html . Please see > that earlier message for a longer-winded explanation of what's wrong > with the current implementation and how the patch addresses this. > > In short, with the patch the random number generator state is now > per-thread and stored in a per-thread (TLS) variable, enabling a > lockless fast-path. This provides up to 2 orders of magnitude better > performance on a synthetic benchmark using 4 threads, and provides a > more deterministic result as the order that threads are scheduled does > not affect the random number streams for each thread. > > Compared to the RFC patch, a number of minor and not-so-minor bugs > have been fixed, so the patch now passes the testsuite (with a few > modifications to the suite, part of the patch). Also, for REAL kinds > 4, 8, 10 the generated streams are identical (except precision, of > course) (like the current implementation), enabling precision > comparisons, as requested by Steve Kargl. However, this does not > extend to REAL(16) as that would have necessitated doubling the size > of the state, along with potential issues of slower escape from a > low-entropy state, for a feature that I believe is not used by > particularly many users in the end. So if one wants to do precision > comparisons with REAL(16) one must employ a wrapper routine. > > Regtested on x86_64-pc-linux-gnu, Ok for trunk? > > frontend ChangeLog: > > 2016-07-27 Janne Blomqvist > > * check.c (gfc_check_random_seed): Use new seed size in check. > * intrinsic.texi (RANDOM_NUMBER): Updated documentation. > (RANDOM_SEED): Likewise. > > > testsuite: > > 2016-07-27 Janne Blomqvist > > * gfortran.dg/random_7.f90: Take into account that the last seed > value is the special p value. > * gfortran.dg/random_seed_1.f90: Seed size is now constant. > > > libgfortran: > 2016-07-27 Janne Blomqvist > > * intrinsics/random.c: Replace KISS with xorshift1024* with > per-thread (TLS) state. > * runtime/main.c (init): Don't call random_seed_i4. > > > -- > Janne Blomqvist -- Janne Blomqvist