From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,28b0249f7691568e X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,28b0249f7691568e X-Google-Attributes: gid102b75,public From: Terje Mathisen Subject: Re: Alpha in peril? First Canion, now Pfieffer (I do think so) Date: 1999/05/18 Message-ID: <374110A2.67761C35@hda.hydro.com>#1/1 X-Deja-AN: 479329315 Content-Transfer-Encoding: 7bit References: <371AD875.407C6B83@igs.net> <7g4tng$5ue$1@nnrp1.dejanews.com> <7h7vnn$2ts$15@nntp.Stanford.EDU> <5l4sljqx5d.fsf@tequila.cs.yale.edu> <926495090.942894@haldjas.folklore.ee> <37396C9A.BD7A1D3B@hda.hydro.com> <7hp5if$11co$1@news.doit.wisc.edu> <7hq34t$osi$9@nntp.Stanford.EDU> Organization: Hydro Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.arch,comp.sys.dec Jonathan Stone wrote: > > In article , mike@ducky.net (Mike Haertel) writes: > |> In article <7hp5if$11co$1@news.doit.wisc.edu>, Andy Glew wrote: > |> >Actually, based pointers have absolutely no overhead > |> >on processors with the appropriate addressing modes. > |> > |> You are conveniently overlooking the fact that providing > |> the "appropriate addressing modes" may have circuit impact > |> in a place where you'd rather not. > > and plus extra register pressure, which may cause more spills, more > cache misses, ... ``Absolutely no overhead'' sounds awfully quantitative. > Got numbers to back it up? Andy is correct to a first order approximation, on recent x86 cpus, but as noted the requirement for base+index+offset addressing has been a sore point on many x86 implementations, i.e. it caused an extra pipeline bubble on at least the 486 cpus. The "real" problem with based pointer on x86 though isn't just the register pressure, but the fact that it takes away the most advanced addressing mode from the application itself, i.e. it is no longer possible to directly address something like a specific element in an array of structs, unless the array starts at the bottom of the based segment itself (or at a fixed offset from the bottom). OTOH, as long as we're going to use asm code, based pointers are definitely easier (more natural) to use on x86 (or M68K) than on more modern cpus with simpler (faster?) address arithmetic. It will still be problematical to write stable & portable C code to support the concept. Terje PS. Almost all the really high-performance asm kernels I write tend to use base+index+offset addressing in the innermost loops: ESI -> just past the end of input array EDI -> just past the end of output array ECX = nr of elements (or size in bytes/size in unrolled blocks etc) ; Unrolled 2-8 times: OFFSET = 0 next4: REPT 4 mov eax,[esi + ecx * SCALE_FACTOR + OFFSET] ... Do something mov [edi+ + ecx * SCALE_FACTOR + OFFSET] OFFSET = OFFSET + ELEMENT_SIZE ENDM ; Update loop counter/address index & branch back add esi, BLOCK_SIZE jb next4 The individual iterations are of course mixed together for better pipeling, and the top of the loop will avoid any loop-counter based addressing which would cause AGIs, but otherwise that is the normal logic. With just base or base + offset addresses, I would have needed more instructions to update the source & destination pointers as well. -- - Using self-discipline, see http://www.eiffel.com/discipline "almost all programming can be viewed as an exercise in caching"