From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public From: nmm1@cus.cam.ac.uk (Nick Maclaren) Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/01 Message-ID: <60uek7$fon$1@lyra.csx.cam.ac.uk>#1/1 X-Deja-AN: 277136389 References: <3431A2DB.4273@EasyInternet.net> <34326556.2216DC70@virginia.edu> <5l90wd2sbj.fsf@tequila.systemsz.cs.yale.edu> Organization: University of Cambridge, England Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec In article <5l90wd2sbj.fsf@tequila.systemsz.cs.yale.edu>, Stefan Monnier wrote: >"Michael D. Nahas" writes: >> I'm afraid that I must admit that Maclaren, even with his outrageous >> claim, is correct. Malde has missed the problem - it is not branching, >> but indirection, A.K.A. pointer chasing. > >I believe everyone here is aware of the fact that indirection is *the* >problem. The question was "why should indirection be more of an issue with >C/C++ than with Pascal, Algol, ... ?" In a word - "aliasing". With multiple levels of indirection, a conforming C compiler has to assume that almost every location can be aliased, and therefore must make a store reference every time. Almost all fancy optimisations that are possible in those languages will cause at least some legal C programs to fail. "const" helps a little, and "restrict" (in C9X) will help a bit more, but at best will bring C up to the very low level of Fortran. And I am not optimistic about even that. Michael Nahas also correctly points out that C++, X, Java etc. have MORE indirections than the equivalent Fortran or 'ordinary' C. This is a matter of interface style as much as the underlying language, but that doesn't help at all. We are stuck with both of them. To respond to the previous posting by brianh@bit3.com, the reason that the multiple indirection is nasty is precisely because it causes trouble with data prefetching! Consider A->B->C->D->E. At each stage, the CPU has to perform the address calculation before it can start prefetching the next address. Now, this very simple case CAN be done by using a multi-threaded architecture, with prefetching threads running ahead to preload the next operands. But what about (P = A->B ? (Q = P->C ? Q->D : P->E) : A->F)? To handle THAT, you need speculative pre-execution, which was dabbled with in the 1960s and 1970s, and quite rightly dropped as an abomination. And, if you look at the source of the X Windowing System, you will see code that is pretty well equivalent :-( For efficient use of modern architectures, we need languages in which we programmers can express what we want to say in a fashion that can be converted to the sort of instruction stream that executes fast. And the current trends are in exactly the opposite direction. Nick Maclaren, University of Cambridge Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB2 3QG, England. Email: nmm1@cam.ac.uk Tel.: +44 1223 334761 Fax: +44 1223 334679