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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8309f2bc055237c4 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Bit manipulation Date: 2000/11/12 Message-ID: <8um7q9$rds$1@nnrp1.deja.com>#1/1 X-Deja-AN: 692693840 References: <8u8v6n$b7o$1@nnrp1.deja.com> <2WTH$pdrCfOd@eisner.decus.org> <8ub6kt$6nd$1@nnrp1.deja.com> <8ubeq8$cgm$1@nnrp1.deja.com> <3A0D38E9.BB87D8CD@mindspring.com> <3A0D86EB.4FAFA2EF@acm.org> <3A0DF35D.729DDE15@mindspring.com> <3A0E3116.83AEC906@acm.org> X-Http-Proxy: 1.0 x51.deja.com:80 (Squid/1.1.22) for client 205.232.38.240 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sun Nov 12 14:00:41 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-11-12T00:00:00+00:00 List-Id: In article <3A0E3116.83AEC906@acm.org>, Jeff Carter wrote: > The fastest but most space-consuming solution would use a > look-up table. Few implementations will support an array of > the required size. You obviously cannot afford a loop through 32 bits, that's a gruesomely inefficient implementation. The proper thing is to establish a look up table of 256 entries (that takes up only 256 bytes and easily fits into primary cache). Then program the byte swap (if you are on a machine with a byte swap instruction like the Power PC, it can be used directly). If you have a bit more space, you can make a table of 64K 16-bit entries and do 16-bit swaps by table lookup. That still takes only 128K bytes, which can easily fit in secondary cache. Even if you could afford a table of 16 gigabytes for the full lookup, you would not want to use such an approach, since you would get cache misses, and probably TLB misses as well on every access, and it would be horribly slow. You just HAVE to be sensitive to cache and TLB-miss issues in modern programming if performance is an issue. Far too many people have not adjusted their thinking and are still programming for non-pipelined non-cached machines in their minds :-) Sent via Deja.com http://www.deja.com/ Before you buy.