comp.lang.ada
 help / color / mirror / Atom feed
From: Olivier Scalbert <olivier.scalbert@algosyn.com>
Subject: Re: Problem with optimizations
Date: Tue, 28 Apr 2009 22:05:40 +0200
Date: 2009-04-28T22:05:40+02:00	[thread overview]
Message-ID: <49f76191$0$2861$ba620e4c@news.skynet.be> (raw)
In-Reply-To: <49f75d09$1_5@news.bluewin.ch>

Gautier wrote:
> For your short-cut version of Is_Solved you might want to write:
> 
>         for i in Face_Index_T'range loop
>           for c in Column_T loop
>             for r in Row_T loop
>               if Cube(i)(c,r) /= Final_Position(i)(c,r) then
>                 return False;
>               end if;
> ...
> 
> Just nicer looking, probably as fast as the "unrolled" version you have. 
> Anyway, I strongly recommend adding -funroll-loops along with your -O2 
> switch. Also -fpeel-loops, -ftracer, -funswitch-loops might help.
> _________________________________________________________
> Gautier's Ada programming -- http://sf.net/users/gdemont/
> NB: For a direct answer, e-mail address on the Web site!

Thanks for your help.

Your version, which is nicer and more generic (4*4, 5*5 cube) on my machine:
gnatmake -f -O3 -W -gnatp -fpeel-loops -ftracer -funswitch-loops rubikmain
real    0m3.057s
user    0m2.988s
sys     0m0.004s

Mine (manually unrolled):
real    0m2.935s
user    0m2.876s
sys     0m0.004s

So, nearly the same. So I'll go for the nice one!

But with:
  function Is_Solved1(Cube: Cube_T) return Boolean is
     begin
         return Cube = Final_position;
     end Is_Solved1;

I have:
real    0m4.775s
user    0m4.660s
sys     0m0.004s

That is much longer !

Does it have the same semantic ?

Olivier



  reply	other threads:[~2009-04-28 20:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 17:04 Problem with optimizations Olivier Scalbert
2009-04-28 17:34 ` Albrecht Käfer
2009-04-28 17:54   ` Olivier Scalbert
2009-04-28 18:32     ` Albrecht Käfer
2009-04-28 19:15     ` John B. Matthews
2009-04-28 18:40 ` (see below)
2009-04-28 19:05   ` Albrecht Käfer
2009-04-28 19:15     ` Olivier Scalbert
2009-04-28 19:17       ` Olivier Scalbert
2009-04-28 19:26         ` Gautier
2009-04-28 21:33       ` sjw
2009-04-29 10:36       ` johnscpg
2009-04-29 10:45       ` johnscpg
2009-04-29 13:51       ` johnscpg
2009-04-28 19:06   ` Olivier Scalbert
2009-04-28 19:12     ` (see below)
2009-04-29  2:35       ` Gene
2009-04-29  3:28         ` (see below)
2009-04-29  7:05           ` Georg Bauhaus
2009-04-28 19:46 ` Gautier
2009-04-28 20:05   ` Olivier Scalbert [this message]
2009-04-28 20:21   ` Olivier Scalbert
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox