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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,103803355c3db607 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.241.162 with SMTP id wj2mr1732303pbc.2.1340968489363; Fri, 29 Jun 2012 04:14:49 -0700 (PDT) Path: l9ni33053pbj.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Keean Schupke Newsgroups: comp.lang.ada Subject: Re: GNAT (GCC) Profile Guided Compilation Date: Fri, 29 Jun 2012 04:14:48 -0700 (PDT) Organization: http://groups.google.com Message-ID: <609b9a6d-ec5b-48e4-9d31-342d80700dc7@googlegroups.com> References: NNTP-Posting-Host: 82.44.19.199 Mime-Version: 1.0 X-Trace: posting.google.com 1340968489 27808 127.0.0.1 (29 Jun 2012 11:14:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 29 Jun 2012 11:14:49 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.44.19.199; posting-account=T5Z2vAoAAAB8ExE3yV3f56dVATtEMNcM User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-06-29T04:14:48-07:00 List-Id: On Friday, 29 June 2012 11:48:10 UTC+1, Simon Wright wrote: > Keean Schupke: > > > I am developing a Monte-Carlo simulation engine, and I have > > implementations in C++ and Ada. All performance figures come from the > > same reference hardware. Both are built using GCC, and similar > > optimisation is applied to each (same optimisation level, cpu arch, > > inlining etc). > > > > My C++ implementation achieves 40,000 simulations per second. > > > > My Ada port initially achieves 32,000 iterations per second. > > > > I refactored the Ada port to use System.Address to access the main > > data structure (as in the 'C++' version benchmarking showed a clear > > performance benefit to *ptr_x compared to array[x]) > > > > The Ada port using System.Address achieves 40,000 simulations per > > second - so this is looking good. > > Did you try -gnatp (suppress all checks)? (only to be used when you're > sure the code is correct!) > > You could also use pragma Suppress at the hot spots. Here are the build scripts for the C++ and Ada versions: For normal compilation I am using: gnatmake -march=native -O3 -gnatp -gnatN xxx g++ -o yyy -std=gnu++0x -march=native -O3 yyy.cpp The performance compiled like this of the Ada and C++ versions is virtually identical (if anything Ada is slightly faster) at about 40k simulations per second. For profile guided compilation I am using: xxx: xxx.adb rm -f *.gcda gnatmake -march=native -O3 -fprofile-generate -gnatp -gnatN xxx ./xxx touch xxx.adb gnatmake -march=native -O3 -fprofile-use -gnatp -gnatN xxx yyy : yyy.cpp rm -f *.gcda g++ -o yyy -std=gnu++0x -march=native -O3 -fprofile-generate yyy.cpp ./yyy touch yyy.cpp g++ -o yyy -std=gnu++0x -march=native -O3 -fprofile-use yyy.cpp With profile guided compilation, Ada is getting 44.5k simulations per second, to C++ at ~55k per second which makes the C++ 25% faster. Cheers, Keean.