From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5730 invoked by alias); 14 Nov 2017 08:40:01 -0000 Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org Received: (qmail 119091 invoked by uid 89); 14 Nov 2017 08:39:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=BAYES_05,FREEMAIL_FROM,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=sums, H*r:sk:gsl-dis, genuine, substantial X-HELO: shout01.mail.de Received: from shout01.mail.de (HELO shout01.mail.de) (213.128.151.216) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Nov 2017 08:39:24 +0000 Received: from postfix02.mail.de (postfix02.bt.mail.de [10.0.121.126]) by shout01.mail.de (Postfix) with ESMTP id B7A3940010 for ; Tue, 14 Nov 2017 09:39:22 +0100 (CET) Received: from smtp04.mail.de (smtp04.bt.mail.de [10.0.121.214]) by postfix02.mail.de (Postfix) with ESMTP id 9E082C013F for ; Tue, 14 Nov 2017 09:39:22 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp04.mail.de (Postfix) with ESMTPSA id 3165F8000A for ; Tue, 14 Nov 2017 09:39:22 +0100 (CET) From: Heiko Bauke Subject: random number generation algorithms To: gsl-discuss@sourceware.org Message-ID: Date: Tue, 14 Nov 2017 08:40:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 2788 X-purgate-ID: 154282::1510648762-000070F2-06D52594/0/0 X-SW-Source: 2017-q4/txt/msg00001.txt.bz2 Hi, quite some time ago (in 2003) I provided some fixes for some random number generation algorithms to the GSL. My implementation was mainly focused on correctness and portability. Thus it was implemented in C89, which is portable but does not guarantee to have a 64 bit integer type. The performance of some random number generation algorithms, however, can benefit a lot from an implementation that uses 64 integers for intermediate values. This holds often not only for genuine 64 bit architectures but also for 32 bit CPUs where the compiler emits more complex code to emulate 64 bit arithmetics. Thus I reimplemented these generators in C99 and 64 bit arithmetics and wrote a simple benchmark that generates a few million random floating point numbers, sums them up, prints this sum and the elapsed time. For some generators the performance difference is substantial. How can I submit my revised code? The code is backward compatible to C89 via preprocessor switches. Here my results to give you an idea of the performance impact of the new implementation: (Note that a substantial amount of time is actually spent in making just the function call to the generator's get routine, performing the loop and so on. An empty get function, yields a running time of 0.6 sec. on my computer.) Current code: generator type: cmrg time = 3.13553 sec. sum = 67102809.40374 generator type: mrg time = 1.85819 sec. sum = 67103626.29699 generator type: minstd time = 0.87232 sec. sum = 67112858.69032 generator type: knuthran2 time = 4.21356 sec. sum = 67111295.37067 generator type: fishman18 time = 2.28581 sec. sum = 67112445.93199 generator type: fishman20 time = 0.90139 sec. sum = 67104902.87940 generator type: lecuyer21 time = 1.05779 sec. sum = 67107194.15891 generator type: fishman2x time = 1.14781 sec. sum = 67118684.47031 New code: generator type: cmrg time = 1.03106 sec. sum = 67102809.40374 generator type: mrg time = 0.72681 sec. sum = 67103626.29699 generator type: minstd time = 0.66231 sec. sum = 67112858.69032 generator type: knuthran2 time = 0.70982 sec. sum = 67111295.37067 generator type: fishman18 time = 0.66595 sec. sum = 67112445.93199 generator type: fishman20 time = 0.66089 sec. sum = 67104902.87940 generator type: lecuyer21 time = 0.80597 sec. sum = 67107194.15891 generator type: fishman2x time = 0.90818 sec. sum = 67118684.47031 Regards, Heiko -- -- Number Crunch Blog @ https://www.numbercrunch.de -- Cluster Computing @ http://www.clustercomputing.de -- Professional @ https://www.mpi-hd.mpg.de/personalhomes/bauke -- Social Networking @ https://www.researchgate.net/profile/Heiko_Bauke