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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3737542e2ed2b8e1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!news.skynet.be!195.238.0.222.MISMATCH!newsspl501.isp.belgacom.be!tjb!not-for-mail Date: Tue, 28 Apr 2009 22:05:40 +0200 From: Olivier Scalbert User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Problem with optimizations References: <49f73730$0$2850$ba620e4c@news.skynet.be> <49f75d09$1_5@news.bluewin.ch> In-Reply-To: <49f75d09$1_5@news.bluewin.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <49f76191$0$2861$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: 1e5fbb02.news.skynet.be X-Trace: 1240949137 news.skynet.be 2861 87.65.130.237:48185 X-Complaints-To: usenet-abuse@skynet.be Xref: g2news2.google.com comp.lang.ada:5596 Date: 2009-04-28T22:05:40+02:00 List-Id: 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