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: a07f3367d7,da39df064d0b18d7 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!w6g2000yqw.googlegroups.com!not-for-mail From: jonathan Newsgroups: comp.lang.ada Subject: Re: GNAT's stack checking in Ubuntu 9.04 (and Shootout regex-dna) Date: Tue, 11 Aug 2009 12:05:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1aec6b98-6c73-43cf-a54f-0b0bc844aeee@w6g2000yqw.googlegroups.com> References: <4a776a94$0$31878$9b4e6d93@newsspool3.arcor-online.net> <4a7f1fc5$0$31344$9b4e6d93@newsspool4.arcor-online.net> <9adb4985-582c-4cbf-906c-3afa7dcd31f6@g1g2000vbr.googlegroups.com> <4a80bae9$0$31866$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: 143.117.23.126 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1250017557 9542 127.0.0.1 (11 Aug 2009 19:05:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 11 Aug 2009 19:05:57 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w6g2000yqw.googlegroups.com; posting-host=143.117.23.126; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.0.12) Gecko/2009072220 Iceweasel/3.0.6 (Debian-3.0.6-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7680 Date: 2009-08-11T12:05:56-07:00 List-Id: On Aug 11, 1:27=A0am, Georg Bauhaus wrote: > > Another way of using modified copies of GNAT library > units seems to be to use -a ; GNAT then considers > the library unit in my source directory. =A0(There is > probably some risk when the options change from those > used for compiling the library, though.) Thanks, -a is right way to go here. Final report (for now): The following remarks apply to single-core runs using the GNAT 4.3.2 that comes with Debian Lenny (based on gcc 4.3.2). I've been saying that GNAT 4.3.2 produces less well optimized executables, but I was not quite right in this case as I explain below. Step 1. Compile without the -a switch: -O3 -gnatnp -funroll-all-loops -march=3Dnative regexdna.adb Running time of ./regexdna: 63 seconds. Comment: compilation near instanteous; I suppose it is linking to precompiled Gnat.Spitbol.Pattern packages. Step 2. Compile with the -a switch: -O3 -a -gnatnp -funroll-all-loops -march=3Dnative regexdna.adb Running time of ./regexdna: 51 seconds. Comment: Compilation is slow. Looks like it is recompiling the Gnat.Spitbol.Pattern packages. So it looks like the performance problem I was complaining about was due to the suboptimal precompiled Spitbol.Pattern. In fact it was almost *entirely* due to the sub-optimal Spitbol.Pattern, because running time is now close to the running time I get from the GNAT GPL compilation. (The GNAT GPL I downloaded was for 64-bit machines. I would speculate that the precompiled Spitbol.Pattern used by the Debian Lenny GNAT was for more general architectures.) Step 3. Copy source code of the spec of Gnat.Spitbol.Pattern into working directory. (I found the source directory by using the -gnatu switch during compilation.) You don't need to change its name (g-spipat.ads). Then edit the g-spipat.ads in working directory and change Stack_Size from 2000 to (say) 37. cp /usr/lib/gcc/x86_64-linux-gnu/4.3.2/adainclude/g-spipat.ads g- spipat.ads Compile with the -a switch: -O3 -a -gnatnp -funroll-all-loops -march=3Dnative regexdna.adb Running time of ./regexdna: 32 seconds. Comment: Now the compiler uses the g-spipat.ads (Gnat.Spitbol.Pattern) in the working directory, ignores the one in adainclude, and recompiles the Spitbol packages. The 32 seconds is almost the same as the running time of the GNAT GPL compilation. (Actually, the GNAT GPL compilation runs in 30.5 sec if Stack_Size is 37 instead of 129. So it is a bit better, but not nearly as much as I thought.) > >While changing the library is not part of the game, >this is useful in general, I'd think, since the >comment next to Stack_Size invites us to adjust it to >fit a program's needs. > Well, I do advocate using a modified g-spipat.ads. Just append the modified g-spipat.ads to regexdna.adb, give the usual gnatchop instruction, and the -a switch for gnatmake. It seems to me that this is completely kosher. Looking (quickly) through the other submissions, I see several common practices: writing your own library modules, linking to language standard library modules, and linking to various to 3rd party library modules that have nothing to do with a particular language standard. I notice for example that fortran and pascal submissions will simply append their own source code versions of hashing modules. The language doesn't provide them. Another practice is to link with the boost library for regex or for threads. Some link to OpenMP for multiprocessing IIUC. The Ada pidigits.adb even links to GMP using interfaces.C. Jonathan