Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!uwvax!oddjob!uxc!uxc.cso.uiuc.edu!urbsdc!aglew From: aglew@urbsdc.Urbana.Gould.COM Newsgroups: comp.arch Subject: Re: Explanation, please! Message-ID: <28200192@urbsdc> Date: 28 Aug 88 03:32:00 GMT References: Lines: 37 Nf-ID: #R::-30:urbsdc:28200192:000:1735 Nf-From: urbsdc.Urbana.Gould.COM!aglew Aug 27 22:32:00 1988 >..> Duff's device > >Yeah. That's the most hackish way of trying to write a portable optimized >copy routine I've ever seen. I gather the whole point of the shenanigans >is to get all the *from++ -> *to++ instructions in the generated code to be >adjacent. Well, that's a start. Duff's device does better on some machines (like, mine) that don't have autoincrement addressing modes, and even on some that do, if you use indexing instead of incrementing. Unfortunately, that tends to make you run the copy backwards, which louses up some caches. >This only makes if the author knows he's got a hardware instruction pipeline >or cache that's no less than 8 and no more than 9 byte-copy instruction widths >long, and stuff executing out of the pipeline is a lot faster than if the >copies are interleaved with control transfers. Dollars to doughnuts this code >was written on a RISC machine. > > Eric S. Raymond (the mad mastermind of TMN-Netnews) No doughnuts. The canonical example of the Duff device originated on a VAX - it's that stuff in the BSD source that produces diagnostics every time you recompile a kernel. Or did it originate on a PDP-11, or early? Gosh darn it, we don't have version 7 reference source on line any more. Andy "Krazy" Glew. Gould CSD-Urbana. 1101 E. University, Urbana, IL 61801 aglew@gould.com - preferred, if you have MX records aglew@xenurus.gould.com - if you don't ...!ihnp4!uiucuxc!ccvaxa!aglew - paths may still be the only way My opinions are my own, and are not the opinions of my employer, or any other organisation. I indicate my company only so that the reader may account for any possible bias I may have towards our products.