From: jonathan <johnscpg@googlemail.com>
Subject: Re: Ada Shootout program for K-Nucleotide (patches)
Date: Sun, 16 Aug 2009 08:20:16 -0700 (PDT)
Date: 2009-08-16T08:20:16-07:00 [thread overview]
Message-ID: <4bc4b12d-40f8-4140-8ef6-326d9e6b8adf@k30g2000yqf.googlegroups.com> (raw)
In-Reply-To: 4a743343$0$32674$9b4e6d93@newsspool2.arcor-online.net
On Aug 1, 1:21 pm, Georg Bauhaus <rm.tsoh.plus-
bug.bauh...@maps.futureapps.de> wrote:
> This is about the K-Nucleotide program at the
> Computer Language Benchmark Game,http://shootout.alioth.debian.org/u32/benchmark.php?test=knucleotide&...
> 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=native
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 := 0;
pragma Assert (Hash_Type'First = 0);
begin
for J in 1 .. Key.Last loop
H := 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
next prev parent reply other threads:[~2009-08-16 15:20 UTC|newest]
Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-01 12:21 Ada Shootout program for K-Nucleotide (patches) Georg Bauhaus
2009-08-01 12:59 ` Ludovic Brenta
2009-08-01 13:59 ` Georg Bauhaus
2009-08-01 13:50 ` Gautier write-only
2009-08-01 15:21 ` Ludovic Brenta
2009-08-01 15:37 ` Gautier write-only
2009-08-02 12:55 ` Georg Bauhaus
2009-08-27 11:17 ` Ole-Hjalmar Kristensen
2009-08-27 12:25 ` Georg Bauhaus
2009-09-01 8:06 ` Ole-Hjalmar Kristensen
2009-09-01 9:29 ` Georg Bauhaus
2009-09-01 10:48 ` Ole-Hjalmar Kristensen
2009-09-01 10:16 ` Ole-Hjalmar Kristensen
2009-09-01 11:34 ` Georg Bauhaus
2009-09-01 12:11 ` Ole-Hjalmar Kristensen
2009-09-01 14:36 ` Georg Bauhaus
2009-09-03 8:49 ` Ole-Hjalmar Kristensen
2009-09-02 8:44 ` Georg Bauhaus
2009-09-02 11:07 ` Ole-Hjalmar Kristensen
2009-09-03 8:13 ` Ole-Hjalmar Kristensen
2009-09-03 10:39 ` Georg Bauhaus
2009-08-03 8:56 ` Jacob Sparre Andersen
2009-08-03 11:43 ` Georg Bauhaus
2009-08-03 12:36 ` Jacob Sparre Andersen
2009-08-03 18:31 ` Isaac Gouy
2009-08-03 20:29 ` Robert A Duff
2009-08-04 15:43 ` Isaac Gouy
2009-08-04 16:06 ` Isaac Gouy
2009-08-04 17:08 ` Georg Bauhaus
2009-08-05 15:58 ` Isaac Gouy
2009-08-05 21:18 ` Georg Bauhaus
2009-08-05 22:04 ` Ludovic Brenta
2009-08-05 22:31 ` Georg Bauhaus
2009-08-05 23:44 ` Jeffrey R. Carter
2009-08-06 8:38 ` Georg Bauhaus
2009-08-06 21:39 ` Georg Bauhaus
2009-08-06 22:42 ` Jeffrey R. Carter
2009-08-07 8:53 ` Georg Bauhaus
2009-08-07 9:21 ` Jacob Sparre Andersen
2009-08-07 9:23 ` Jacob Sparre Andersen
2009-08-09 19:17 ` Georg Bauhaus
2009-08-13 20:56 ` jonathan
2009-08-13 21:30 ` jonathan
2009-08-13 22:08 ` Georg Bauhaus
2009-08-14 15:31 ` jonathan
2009-08-06 7:51 ` Dmitry A. Kazakov
2009-08-06 0:07 ` Isaac Gouy
2009-08-06 8:36 ` Georg Bauhaus
2009-08-06 9:09 ` Dmitry A. Kazakov
2009-08-06 10:34 ` Georg Bauhaus
2009-08-06 10:49 ` Dmitry A. Kazakov
2009-08-06 15:21 ` Isaac Gouy
2009-08-03 20:47 ` Ludovic Brenta
2009-08-01 17:07 ` jonathan
2009-08-01 17:59 ` jonathan
2009-08-02 11:39 ` Georg Bauhaus
2009-08-02 16:00 ` jonathan
2009-08-02 16:42 ` jonathan
2009-09-03 13:44 ` Olivier Scalbert
2009-09-03 14:08 ` Ludovic Brenta
2009-09-03 15:13 ` Olivier Scalbert
2009-09-03 19:11 ` sjw
2009-09-04 6:11 ` Olivier Scalbert
2009-09-04 8:18 ` Ludovic Brenta
2009-09-04 10:17 ` Olivier Scalbert
2009-09-04 12:37 ` Ludovic Brenta
2009-09-04 13:50 ` Olivier Scalbert
2009-09-04 12:50 ` Ludovic Brenta
2009-09-04 16:22 ` Georg Bauhaus
2009-09-04 16:29 ` Georg Bauhaus
2009-09-04 16:38 ` Ludovic Brenta
2009-09-04 17:58 ` Georg Bauhaus
2009-09-04 18:12 ` Georg Bauhaus
2009-09-05 20:16 ` Georg Bauhaus
2009-09-07 7:45 ` Olivier Scalbert
2009-09-07 9:19 ` Georg Bauhaus
2009-09-07 13:31 ` Olivier Scalbert
2009-09-07 14:38 ` jonathan
2009-09-07 15:03 ` Olivier Scalbert
2009-09-07 17:31 ` jonathan
2009-09-07 17:54 ` Olivier Scalbert
2009-09-07 18:07 ` Georg Bauhaus
2009-09-08 0:22 ` Georg Bauhaus
2009-09-04 17:56 ` Martin
2009-09-04 18:26 ` Georg Bauhaus
2009-09-04 21:51 ` Robert A Duff
2009-09-04 18:51 ` Ludovic Brenta
2009-09-04 9:27 ` Georg Bauhaus
2009-09-03 15:28 ` Georg Bauhaus
2009-09-04 1:24 ` Georg Bauhaus
2009-08-04 8:23 ` Martin
2009-08-16 15:20 ` jonathan [this message]
2009-08-17 15:46 ` Georg Bauhaus
2009-08-18 16:59 ` jonathan
2009-08-19 14:52 ` Georg Bauhaus
2009-08-19 16:40 ` Martin
2009-08-19 18:24 ` Robert A Duff
2009-08-19 22:15 ` jonathan
2009-08-19 23:50 ` Georg Bauhaus
2009-08-20 19:47 ` jonathan
2009-08-20 22:15 ` Georg Bauhaus
2009-08-21 21:43 ` jonathan
2009-08-22 22:35 ` Georg Bauhaus
2009-08-23 22:21 ` jonathan
2009-08-20 19:55 ` jonathan
2009-08-19 21:37 ` Georg Bauhaus
2009-08-19 19:22 ` jonathan
2009-08-19 19:27 ` jonathan
2009-08-27 9:05 ` Martin
2009-08-27 9:08 ` Martin
2009-08-27 10:01 ` Georg Bauhaus
2009-10-07 11:44 ` Olivier Scalbert
2009-10-07 12:04 ` Georg Bauhaus
2009-10-07 13:22 ` Martin
2009-10-07 14:15 ` Olivier Scalbert
2009-10-08 9:54 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox