From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,e489d6e4973d889f X-Google-Attributes: gid1164f8,public X-Google-Thread: 115614,e489d6e4973d889f X-Google-Attributes: gid115614,public X-Google-Thread: 102b75,e489d6e4973d889f X-Google-Attributes: gid102b75,public X-Google-ArrivalTime: 2001-08-29 14:55:02 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!forum.apple.com!news.apple.com!handma2.apple.com!user From: name99@mac.com (Maynard Handley) Newsgroups: comp.arch,comp.sys.dec,comp.unix.aix Subject: Re: Can POWER4, 5 etc continue where Alpha was stopped? Date: Wed, 29 Aug 2001 14:45:22 -0700 Organization: None Message-ID: References: <88525dde.0108260914.7c63d8c3@posting.google.com> <9mgps0$12ee$1@ausnews.austin.ibm.com> <9mhbh0$pbq$1@ausnews.austin.ibm.com> <3B8C8AC4.59ED22CB@hda.hydro.com> NNTP-Posting-Host: handma2.apple.com X-Trace: news.apple.com 999121586 19810 17.202.32.152 (29 Aug 2001 21:46:26 GMT) X-Complaints-To: usenet@news.apple.com NNTP-Posting-Date: 29 Aug 2001 21:46:26 GMT X-Newsreader: MT-NewsWatcher 2.3.1 Xref: archiver1.google.com comp.arch:15949 comp.sys.dec:6797 comp.unix.aix:22768 In article <3B8C8AC4.59ED22CB@hda.hydro.com>, Terje Mathisen wrote: > McCalpin wrote: > > > > In article , > > Bruce Hoult wrote: > > >In article <9mgps0$12ee$1@ausnews.austin.ibm.com>, > > >mccalpin@austin.ibm.com wrote: > > > > > >> , and [I] have only found > > >> one use for [pop count] in my own experience..... (It is a very easy way > > >> to determine if an integer is a power of two -- though I don't > > >> usually care about how long it takes to make this determination.) > > > > > >It's not needed for that -- (x & (x-1)) is zero IFF x is a power of two > > >(or zero). It works by clearing the least significant set bit. > > > > Ouch -- that sort of bit twiddling makes my poor Fortran brain > > hurt. I hate it when I run across coding like this. > > > > >I'm sure you knew this. > > > > I did not know it, but I am trying to forget it as fast as I can! > > Why??? > > Optimized code can indeed make use of a fast way to determine if a > number is a power of two, I've used that particular idiom several times. I think the main thing is to ensure that things like this are wrapped in a macro rather than directly in the code. Not only does that make the code much easier to read but it allows one to restructure the macro if appropriate to a new platform. (Unlikely for this example, but can be likely in other situations eg when one moves from big to little-endian.) Maynard > popcount() is also useful, mostly when working with bitmaps. > > A possible use would be for SQL runtime optimization, when joining > bitmaps to determine the best evaluation order. > > I suspect that NSA could use it as a quick way to detect patterns that > significantly differ from purely random bitstreams? > > Terje > > -- > - > Using self-discipline, see http://www.eiffel.com/discipline > "almost all programming can be viewed as an exercise in caching"