comp.lang.ada
 help / color / mirror / Atom feed
From: jonathan <johnscpg@googlemail.com>
Subject: Re: Ada Shootout program for K-Nucleotide (patches)
Date: Sun, 23 Aug 2009 15:21:53 -0700 (PDT)
Date: 2009-08-23T15:21:53-07:00	[thread overview]
Message-ID: <5103f5a7-8643-4d15-9989-b07fe773e0f3@b15g2000yqd.googlegroups.com> (raw)
In-Reply-To: 4a9072a7$0$32669$9b4e6d93@newsspool2.arcor-online.net

On Aug 22, 11:35 pm, Georg Bauhaus <rm.tsoh.plus-
bug.bauh...@maps.futureapps.de> wrote:
> jonathan wrote:
> >> Or if we are at it, we might experiment with slice renamings
> >> or pointer artihmetic; requires a rewrite, I'd think.
> >> If the rules permit this at all ;-)
>
> > I did make another attempt here.  [...]
> > This essentially removed all the overhead in sliding
> > array Data.
>
> With the help of generics I have been able to further
> reduce string processing load.  Instances will adapt String
> to fragments, as needed.
> The result is another 20% speed-up.  A pleasant surprise,
> and fairly easy.  This allows using simple renames for
> key data. :-)
>


The program now runs in a splendid 23 sec on my
machine. For those who have not been paying
attention, we started some time ago with a program
that ran in > 72 sec.  Its now (I should think) quite
a bit faster than all but one at the benchmarking
site.

The string renaming turned out to be such a neat
trick, I'll write it out:

  Key(1 .. Length) := Buffer(I .. I + Length - 1);

(in its various forms) was replaced by

  Key : String renames Buffer(I .. I + Length - 1);

This combined with the smaller strings did the
trick.  On my machine execution fell from ~32 sec to
~23 sec from these 2 steps alone.

One useful feature of the new design is we can
explicitly "grow the hash table" as the rules
seem to specify, (although they accepted the static
sized table last time).  We now have the option
of changing Table_Size with each instantiation:

--Table_Size : constant Integer := 2 ** 17;
  Table_Size : constant Integer
           := 2 ** Integer'Min (Fragment'Last*4, 17);

  subtype Hash_Type is Integer range 0 .. Table_Size-1;

This is the form used by many other entries.  The new
table size does not change the speed in the slightest.
I prefer the static  2 ** 17 myself.


> I'd like to further merge the programs, following the
> comments so far.  In particular, there doesn't seem to be
> a real loss when using tasks on a single core machine,
> IIUC.  I'll try to confirm this some more.
> We could then submit just one program, if you agree.
>

To fuse single-core and multitasking version I tried
the following:

if Multitasking_Desired then
   Work_On_2.Writer.Set (Nucleotide_Length => 2);
   Work_On_18.Writer.Set (Fragment_18'Length, Fragment_18);
   Work_On_1.Writer.Set (Nucleotide_Length => 1);
   Work_On_12.Writer.Set (Fragment_12'Length, Fragment_12);
   Work_On_6.Writer.Set (Fragment_6'Length, Fragment_6);
   Work_On_4.Writer.Set (Fragment_4'Length, Fragment_4);
   Work_On_3.Writer.Set (Fragment_3'Length, Fragment_3);
else
   Work_On_1.Write (Nucleotide_Length => 1);
   Work_On_2.Write (Nucleotide_Length => 2);
   Work_On_3.Write (Fragment_3'Length, Fragment_3);
   Work_On_4.Write (Fragment_4'Length, Fragment_4);
   Work_On_6.Write (Fragment_6'Length, Fragment_6);
   Work_On_12.Write (Fragment_12'Length, Fragment_12);
   Work_On_18.Write (Fragment_18'Length, Fragment_18);
end if;

With Multitasking_Desired set to False, a typical
(good) timing might look like:

real    0m23.552s
user    0m23.141s
sys     0m0.404s

With Multitasking_Desired set to True, a typical
(good) timing might look like:

real    0m10.373s
user    0m23.625s
sys     0m0.432s

Fluctuations are not tiny; maybe .7 sec.
And remember, Linux in probably putting the 7 Work
tasks on 7 cores of the 8 available on my machine.

And there's a problem I can't solve.  One out of 5 to
20 runs gives this result:

real    0m15.691s
user    0m34.150s
sys     0m0.396s

Always the same ~16 seconds.
I can't tell if its a Linux hiccup, the phase of the
moon, or what, but I can't get rid of it.

That's one reason I am not sure it is a good idea
just yet to fuse the single-core version and the
tasking version. I'ld rather see the cleaner
single-core version polished up and submitted quick.

To make a task-free version I just directly
removed all the tasking from your latest. Works
well .. my versions are obsolete .. just an
option to consider.

Jonathan




  reply	other threads:[~2009-08-23 22:21 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
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 [this message]
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