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.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Attributes: gid103376,gid115aec,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!news.glorb.com!newsfeeder.wxs.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Aslan Kral" Newsgroups: comp.lang.ada,comp.realtime Subject: Re: 10 rules for benchmarking (was Re: Teaching new tricks to an old dog (C++ -->Ada)) Date: Sat, 12 Mar 2005 15:29:24 +0200 Message-ID: <39g92iF62e0j3U1@individual.net> References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <112rs0bdr2aftdf@corp.supernews.com> <1inxxr988rxgg$.1w9dedak41k89.dlg@40tude.net> <112s1r0rf0o8nca@corp.supernews.com> <112sonip5v4dca6@corp.supernews.com> <112t3de6fu04f38@corp.supernews.com> <1110396477.596174.285520@o13g2000cwo.googlegroups.com> <112vb2t8eonuhed@corp.supernews.com> <1110422108.925127.54110@o13g2000cwo.googlegroups.com> <11329cb96h2p19f@corp.supernews.com> <1134l90ja5sqm73@corp.supernews.com> <39fr2iF5uq3mvU1@individual.net> <39g6jbF62g4qjU1@individual.net> X-Trace: individual.net aSgbk/ljCssMoCGLaqPTcQgkFKfy3VHkQX6ALamVdRM+6D9OxC X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Xref: g2news1.google.com comp.lang.ada:9230 comp.realtime:1362 Date: 2005-03-12T15:29:24+02:00 List-Id: "Jim Rogers" , haber iletisinde �unlar� yazd�:DYBYd.373707$w62.141894@bgtnsc05-news.ops.worldnet.att.net... > "Aslan Kral" wrote in > news:39g6jbF62g4qjU1@individual.net: > > > > > "Aslan Kral" , haber iletisinde �unlar� > > yazd�:39fr2iF5uq3mvU1@individual.net... > >> > IIRC, the C codes that were posted to find the highest bit set > >> > thread were about 1/10th of that number. Just to double check, I > >> > wrote and measured some C code. On my 3GHz Xeon running with cygwin > >> > on WinXP, when compiled with gcc3.3.3 using -mpcu=i686 -O0, I got a > >> > total run-time of 2.3s, for about 69 cycles/iteration, and with -O2 > >> > I get 0.94s for about 28 cycles/iteration. > >> > > >> > > > > Oops! I failed to read the -O2 part. It makes sense now. And your code > > doesn't use any lookup table that is why it is slower than Willem's. > > Anyway the version with lookup table is quite close to "bsr" version. > > So yours also can get faster with the addition of lookup table. It > > would be interesting to see how much Ada can get close to "bsr" > > version below! (By adding a lookup table, I mean.) > > > > __inline unsigned FindHighestBit(unsigned n) > > { > > __asm > > { > > bsr eax, n > > } > > } > > . > > > > I sems to have lost the C version of the lookup table. > Could you please repost that or send me the version. > > Thanks. > > Jim Rogers > OK. static unsigned highBitSmall[256] = { 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 }; __inline unsigned FindHighestBit( unsigned n ) { unsigned bits = 0; if (n >> 16) { n = n >> 16; bits = 16; } if (n >> 8) { n = n >> 8; bits += 8; } return bits + highBitSmall[n]; }