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,3a6a9f1d654285ba X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!k30g2000yqf.googlegroups.com!not-for-mail From: jonathan Newsgroups: comp.lang.ada Subject: Re: Ada Shootout program for K-Nucleotide (patches) Date: Sun, 16 Aug 2009 08:20:16 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4bc4b12d-40f8-4140-8ef6-326d9e6b8adf@k30g2000yqf.googlegroups.com> References: <4a743343$0$32674$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: 143.117.23.235 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1250436025 7930 127.0.0.1 (16 Aug 2009 15:20:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 16 Aug 2009 15:20:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k30g2000yqf.googlegroups.com; posting-host=143.117.23.235; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; 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:7831 Date: 2009-08-16T08:20:16-07:00 List-Id: On Aug 1, 1:21=A0pm, Georg Bauhaus wrote: > This is about the K-Nucleotide program at the > Computer Language Benchmark Game,http://shootout.alioth.debian.org/u32/be= nchmark.php?test=3Dknucleotide&... > where some Ada programs have started to fail. I took a 2nd look at your single core knucleotide.adb. http://home.arcor.de/bauhaus/Ada/knucleotide.gnat I was able to speed it up by 40% to 50% with one change: I inlined the hashing function by hand. Its not the prettiest code, but this is after all an optimization exercise. Running time under GNAT 4.3.2 went from 79 sec to to 53 sec. Running time under GNAT 4.3.4 went from 70 sec to 50 sec. On both GNAT 4.3.2, and GNAT 4.3.4 (GPL 2009) the best compiler switches I could find were: gnatmake -O3 -gnatp -march=3Dnative Here is the original Hash function: -- function Hash (Key : Fragment) return Hash_Type is -- begin -- return Hash_Function (Fragments_1.To_String (Key)); -- end Hash; and here is the replacement: function Hash (Key : Fragment) return Hash_Type is type Uns_32 is mod 2**32; H : Uns_32 :=3D 0; pragma Assert (Hash_Type'First =3D 0); begin for J in 1 .. Key.Last loop H :=3D Character'Pos(Key.Data(J)) + H * 2**6 + H * 2**16 - H; end loop; return Hash_Type'Base (H mod Uns_32 (Hash_Type'Last + 1)); end Hash; A few more changes: 1. REMOVE: pragma Restrictions (No_Finalization); Won't compile under GNAT 4.3.4, with mysterious error message. Could this be a problem on GNAT 4.3.3 used at the shootout site? In any case, -gnatu says we're linking to storage pool routines, so this is probably an error. 2. I replaced: type Hash_Type is range 0 .. 2**16; with type Hash_Type is range 0 .. 2**17 - 1; Both work, but latter is a few % faster. 3. I moved type Bounded_String out of the private part and made it public so that function Hash could see it. (Just for convenience.) type Bounded_String is record Data : String(Frequencies); Last : Natural; end record; 4. The knucleotide.adb version that uses Ada.Containers is 3 times slower than this new one, and seems to fail on the 250 Meg fasta text file used in the benchmark. Final comment: According to the shootout site, they're using GNAT 4.3.3. I wonder if this is the source of our misery. I can get GNAT 4.3.2 and GNAT 4.3.4 (GPL) the work very nicely on all machines I have access to. The best optimation switches are often very different on these 2 compilers, so I have no idea what GNAT 4.3.3 likes. Jonathan