* Final kick at the "Merced Guessing Game"
@ 1997-09-30 4:00 Paul DeMone
1997-09-30 4:00 ` Guy Harris
` (3 more replies)
0 siblings, 4 replies; 48+ messages in thread
From: Paul DeMone @ 1997-09-30 4:00 UTC (permalink / raw)
While reading through an old (Dec 1995) issue of Proceedings of the IEEE the
other day while waiting for an HSPICE run to finish I came across a remarkable
paper entitled "Compiler Technology for Future Microprocessors". The authors
(W. Hwu, R. Hank, D. Gallagher, S. Mahlke, D. Lavery, G. Haab, J. Gyllenhaal,
and D. August) are associated with the University of Illinois but the research
seems to have strong ties with HP.
The primary thrust of the paper was to describe compiler algorithms and hardware
mechanisms that could be used to get around the problem of branches and false
dependencies in gathering enough instruction level parallelism for an eight issue
RISC-like machine. The paper showed how predication (kind of like condition codes
that can be used to permit conditional execute any instruction, a generalization of
what ARM does) can be used in conjunction with loop unrolling and basic block
oalesing to dramatically decrease the number of conditional branches that need to
be predicted/executed (in one example mispredicted branches using the 2-bit branch
prediction model were reduced by almost three orders of magnitude within a complex
inner loop).
The authors give examples of how an eight issue processor with full predication
could give a remarkable improvement (1.2x to 4.5x) over an eight issue design with a
non-predicated ISA. Their description of their architecture strikes me as eerily
similar to some predictions about the Intel IA-64 Merced design so I will repeat it:
"The processor model used for these experiments is an eight-issue extension of
the HP PA-RISC[TM] architecture. The processor may issue eight instructions
of any type each cycle except branches, which are restricted to one per cycle.
The processor has 64 integer, 64 floating-point, and 64 predicate registers."
The design would seem to effectively avoid the complexity and cycle time impact of
the paraphenalia of aggressive out-of-order designs such as register renaming and
in-order completion unit. The paper gives brief descriptions of advanced compiler
techniques to transform around loops (essentially static compile time register re-
naming) and also discusses how to incorporate memory data dependence analysis (used
by the Multiflow Trace scheduling compiler for the TRACE series of VLIW computers)
for another significant speedup.
HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
weeks but if they exploit the advances described in this paper it could really be
something with the potential for dramatically raising the bar of microprocessor
performance and not just typical Intel hype and FUD. Comments?
All opinions strictly my own.
--
Paul W. DeMone The 801 experiment SPARCed an ARMs race
Kanata, Ontario to put more PRECISION and POWER into
demone@mosaid.com architectures with MIPSed results but
PaulDeMone@EasyInternet.net ALPHA's well that ends well.
^ permalink raw reply [flat|nested] 48+ messages in thread* Re: Final kick at the "Merced Guessing Game" 1997-09-30 4:00 Final kick at the "Merced Guessing Game" Paul DeMone @ 1997-09-30 4:00 ` Guy Harris 1997-10-01 4:00 ` Tom Thornhill 1997-10-01 4:00 ` Nick Maclaren ` (2 subsequent siblings) 3 siblings, 1 reply; 48+ messages in thread From: Guy Harris @ 1997-09-30 4:00 UTC (permalink / raw) Paul DeMone <PaulDeMone@EasyInternet.net> wrote: >While reading through an old (Dec 1995) issue of Proceedings of the IEEE the >other day while waiting for an HSPICE run to finish I came across a remarkable >paper entitled "Compiler Technology for Future Microprocessors". A Web search for that title found a page at http://www.cs.colorado.edu/~klauser/ilp/ilp.html which is a reading list of papers in instruction-level parallelism. It has a link to a PostScript version of a paper with that title, at: ftp://ftp.crhc.uiuc.edu/pub/IMPACT/journal/ieeepro.future.95.ps although in a quick look I didn't see the comment you quoted aabout the processor model they used, so maybe this is an earlier version of the paper. The page cited above does have a number of papers from HP Labs.... > The design would seem to effectively avoid the complexity and cycle time > impact of the paraphenalia of aggressive out-of-order designs such as > register renaming and in-order completion unit. So are they going to blow off making Merced run IA32 code really really really fast, leaving that up to future IA32 implementations (perhaps on the theory that Merced will be used mainly in machines that don't have to run IA32 stuff really really really fast, just "fast enough"), and maybe require software to do binary-to-binary translation of IA32 programs if you want them to run really really really fast? (I.e., it doesn't have to run Windows 98 or Office 97 really really really fast, as a P6-generation or next-generation-after-P6 machine can handle that job, it just has to run big database XXX or big server YYY or big number-crunching program ZZZ really really really fast, and those will be compiled into native code?) -- Reply, or follow up, but don't do both, please. postmaster@localhost postmaster@[127.0.0.1] ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-09-30 4:00 ` Guy Harris @ 1997-10-01 4:00 ` Tom Thornhill 0 siblings, 0 replies; 48+ messages in thread From: Tom Thornhill @ 1997-10-01 4:00 UTC (permalink / raw) Guy Harris <guy@netapp.com> wrote in article <60slvu$3pr@tooting.netapp.com>... > > So are they going to blow off making Merced run IA32 code really really > really fast, leaving that up to future IA32 implementations (perhaps on > the theory that Merced will be used mainly in machines that don't have > to run IA32 stuff really really really fast, just "fast enough"), and > maybe require software to do binary-to-binary translation of IA32 > programs if you want them to run really really really fast? (I.e., it > doesn't have to run Windows 98 or Office 97 really really really fast, > as a P6-generation or next-generation-after-P6 machine can handle that > job, it just has to run big database XXX or big server YYY or big > number-crunching program ZZZ really really really fast, and those will > be compiled into native code?) Surely for IA32 code it would be possible to do on the fly translation a la the PPro from instructions fetched from memory to the instructions executed by the pipeline(s). I suppose that moving complexity out of the pipeline just means that you have to do more work on the translation, but that work will already have been done for Willamette (sp?), assuming that uses PPro-style decoupled architecture. I suppose you could have a kind of modular design with the same pipeline design in both chips but with a highly optimised ( and big ) translation unit in Willamette feeding a few pipelines, but a less optimised and smaller translation unit feeding more pipelines in Merced. That way you could have a modular design that could be tuned for executing translated IA32 or native IA64. Eventually you can lose the translation unit completely and move to an IA64 only architecture at a higher clock speed. You could then scale this by adding superscalar execution for the VLIW instructions ( is this possible ) Hmm, maybe I should learn VHDL and find out how practical all this stuff is. > -- > Reply, or follow up, but don't do both, please. > > postmaster@localhost > postmaster@[127.0.0.1] > -- ***If you can understand this then your brain needs servicing URGENTLY*** Mailto: tthornhi@best.ms.philips.com-nospam ( remove the -nospam before replying ) Talkto: Tom Thornhill, Philips Medical Systems Nederland BV Tel +31 4027 64080 (Work), +31 499 338211 (Hotel - after 5pm UK time) ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-09-30 4:00 Final kick at the "Merced Guessing Game" Paul DeMone 1997-09-30 4:00 ` Guy Harris @ 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Paul DeMone 1997-10-01 4:00 ` J. Corbally 1997-10-01 4:00 ` Tom Thornhill 1997-10-01 4:00 ` Richard A. Schumacher 3 siblings, 2 replies; 48+ messages in thread From: Nick Maclaren @ 1997-10-01 4:00 UTC (permalink / raw) In article <3431A2DB.4273@EasyInternet.net>, Paul DeMone <PaulDeMone@EasyInternet.net> writes: |> |> HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of |> weeks but if they exploit the advances described in this paper it could really be |> something with the potential for dramatically raising the bar of microprocessor |> performance and not just typical Intel hype and FUD. Comments? It will have little or no practical effect, because the dominating languages and programming styles have one unpredictable branch or data indirection every few instructions. Until and unless C, C++, most windowing systems and similar tripe are scrapped, almost all systems will run at a miniscule fraction of their potential CPU performance. A quick look at Java implies that it probably has the same problems, but I cannot swear to it. 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren @ 1997-10-01 4:00 ` Paul DeMone 1997-10-01 4:00 ` J. Corbally 1 sibling, 0 replies; 48+ messages in thread From: Paul DeMone @ 1997-10-01 4:00 UTC (permalink / raw) Nick Maclaren wrote: > > In article <3431A2DB.4273@EasyInternet.net>, Paul DeMone <PaulDeMone@EasyInternet.net> writes: > |> > |> HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of > |> weeks but if they exploit the advances described in this paper it could really be > |> something with the potential for dramatically raising the bar of microprocessor > |> performance and not just typical Intel hype and FUD. Comments? > > It will have little or no practical effect, because the dominating > languages and programming styles have one unpredictable branch or > data indirection every few instructions. Until and unless C, C++, > most windowing systems and similar tripe are scrapped, almost all > systems will run at a miniscule fraction of their potential CPU > performance. A quick look at Java implies that it probably has the > same problems, but I cannot swear to it. I thought much along the same line until I read this paper. some sample code is the inner loop from Unix utilities. These are really twisty C programs chosen for their branch-ugliness, i.e. the poor way conventional compilers and machines can handle them. The job their compiler does on the inner loop of the wc (word count) program is amazing. It eliminates most branches by replicating basic blocks and using predication to coalesce around branches and form larger basic blocks. The combination of loop unrolling and formation of hyperblocks allows a good deal of instruction level parallelism to be extracted. In the case of wc the use of pred- ication reduced dynamic branch execution from 572K to 315K while reducing branch misprediction using the 2-bit scheme from 52K to 56. On the eight issue target CPU wc was sped up by 5.5x versus a single issue RISC CPU while grep was sped up 4x. The SPEC92 programs espresso, eqntott, alvinn, ear, and sc were sped up 3.3x, 5.5x, 7.7x, and 5.8x respectively versus a single issue RISC. Considering that the three issue P6/Pentium II and quad issue RISCs like R10K and Alpha 21164 probably average only about 2.5x (or less) speed up versus a single issue RISC the performance of this new architecture with its advanced compiler is damn impressive! Don't forget that this new design likely can be implemented without all the overhead of out-of-order machines like P6 and R10K and so can be clocked much, much faster (maybe even faster than Alpha in the same process). Granted some of the apparent speedup of the new design will be lost from main memory latency and bandwidth limitations or icache inefficiency from code bloat but it still could be a significant step forward. > > 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 -- Paul W. DeMone The 801 experiment SPARCed an ARMs race Kanata, Ontario to put more PRECISION and POWER into demone@mosaid.com architectures with MIPSed results but PaulDeMone@EasyInternet.net ALPHA's well that ends well. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Paul DeMone @ 1997-10-01 4:00 ` J. Corbally 1997-10-01 4:00 ` Nick Maclaren 1 sibling, 1 reply; 48+ messages in thread From: J. Corbally @ 1997-10-01 4:00 UTC (permalink / raw) > It will have little or no practical effect, because the dominating > languages and programming styles have one unpredictable branch or > data indirection every few instructions. Until and unless C, C++, > most windowing systems and similar tripe are scrapped, almost all > systems will run at a miniscule fraction of their potential CPU > performance. A quick look at Java implies that it probably has the > same problems, but I cannot swear to it. > > 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 I'm sure you have some new hyper-advanced programming language in the waiting that will realise this "potential CPU performance", and obsolete all other languages. Yeah, right..... Please explain yourself.... Regards, James..... -- All opinions expressed herein are my own personal observations and DO NOT represent the views of my past, current, or future employers. All opinions included herein due to quoting are the personal opinions of their respective posters, and no implication of agreement or endorsement on my part shall be inferred in them. Remove *NO_SPAM* to enable mailing ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` J. Corbally @ 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Ketil Z Malde 0 siblings, 1 reply; 48+ messages in thread From: Nick Maclaren @ 1997-10-01 4:00 UTC (permalink / raw) In article <60t42r$4pd@scnews.sc.intel.com>, "J. Corbally" <icorb*NO_SPAM*@*NO_SPAM*indigo.ie> writes: |> > It will have little or no practical effect, because the dominating |> > languages and programming styles have one unpredictable branch or |> > data indirection every few instructions. Until and unless C, C++, |> > most windowing systems and similar tripe are scrapped, almost all |> > systems will run at a miniscule fraction of their potential CPU |> > performance. A quick look at Java implies that it probably has the |> > same problems, but I cannot swear to it. |> |> I'm sure you have some new hyper-advanced programming language in the |> waiting that will realise this "potential CPU performance", and obsolete |> all other languages. Yeah, right..... |> |> Please explain yourself.... Whether I do or not is irrelevant, as all of the Fortrans, Cobols, Algols, Pascals, Modulas etc. are streets better. So, interestingly enough, are 'object oriented' systems like Smalltalk and (I believe) Eiffel - but they have other problems. If you take a close look at C++, the X Windowing System, the various IBM and Microsoft windowing systems etc., you will see that an 'object' is implemented as a data structure and you invoke a method by picking an address up from that structure and branching to it. Furthermore, most of the important data is indirected through multiple levels of data structure. When I first described this to a hardware designer, back in the early days of the latest RISC hype, he said "But nobody writes code like that!" When I said that the C++ and X Windowing System did little else, he said "Well, people won't use them then." 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren @ 1997-10-01 4:00 ` Ketil Z Malde 1997-10-01 4:00 ` Michael D. Nahas 0 siblings, 1 reply; 48+ messages in thread From: Ketil Z Malde @ 1997-10-01 4:00 UTC (permalink / raw) nmm1@cus.cam.ac.uk (Nick Maclaren) writes: > If you take a close look at C++, the X Windowing System, the various > IBM and Microsoft windowing systems etc., you will see that an > 'object' is implemented as a data structure and you invoke a method > by picking an address up from that structure and branching to it. Right - and in Pascal, Algol, Cobol, and all those other superior languages, function calls are made without branching? Which is why Pascal and Cobol is commonly used when performance is important? Right? And since programs written in C runs at a ``miniscule fraction of their potential CPU performance'', could you please inform me which Pascal, Algol, Cobol or Modula-[23] compiler that create such vastly improved speed of execution? And - how much faster can I expect applications to run? HIBT? ~kzm -- If I haven't seen further, it is by standing in the footprints of giants ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Ketil Z Malde @ 1997-10-01 4:00 ` Michael D. Nahas 1997-10-01 4:00 ` brianh ` (2 more replies) 0 siblings, 3 replies; 48+ messages in thread From: Michael D. Nahas @ 1997-10-01 4:00 UTC (permalink / raw) Ketil Z Malde wrote: > nmm1@cus.cam.ac.uk (Nick Maclaren) writes: > > > If you take a close look at C++, the X Windowing System, the various > > IBM and Microsoft windowing systems etc., you will see that an > > 'object' is implemented as a data structure and you invoke a method > > by picking an address up from that structure and branching to it. > > Right - and in Pascal, Algol, Cobol, and all those other superior > languages, function calls are made without branching? Which is why > Pascal and Cobol is commonly used when performance is important? Right? > > And since programs written in C runs at a ``miniscule fraction of their > potential CPU performance'', could you please inform me which Pascal, > Algol, Cobol or Modula-[23] compiler that create such vastly improved > speed of execution? And - how much faster can I expect applications to > run? 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. For a standard function, you just branch to the address. With C++'s virtual functions you either follow a pointer or perform an indexed lookup to a jump table, which will load the address you will jump to, and then branch to that address. Why is indirection bad? When the destination address of a jump is known, the processor can begin fetching from the new address and continue executing. When the destination address of the jump is unknown, the processor usually stalls until the address comes in from memory. Some processors do have hardware to speed up indirect jumps, but the hardware was developed using C benchmarks, where 90% of indirect jumps are just returns from functions. The truely evil part of indirection is not in function calls, but in the non-array data structures of most programs. Think of traversing a linked list. To load the first node in the list, it takes as much time as the memory latency. To load the second node, you must first load the first node, and then pay the cost of the memory latency time again. So to traverse a N node linked list, it takes N times the memory latency. For most cases, the nodes are contiguous in memory and most programs run inside the L1 and L2 cache, so these latencies are not too bad for most programs. However, programs which do not fit in large L2 caches, such as sparse matrix programs and the X Windows system, pay heavily. The latency time of going to main memory is growing exponentially in terms of CPU cycles. So, is this a problem, and if so, how do we fix it. Yes, it is a problem, because any stall to the pipeline which prevents speculative execution is bad. How do we solve it? The first thing to do is to make programs which have this problem part of the SPEC Benchmarks. This will make it the focus of everyone's attention. The other thing that can be done is to look at Compiler optimizations - many of the indirect function calls can be eliminated, especially if all the source is compiled together. Separate compilation of object files requires general interfaces which prevent many optimizations. Also, a note on Java. All Java functions are virtual and all require a general interface on a class level. Lastly, all objects are referenced indirectly, so even an array of Java objects is two levels of indirection to get the object you want! So, Java is even worse than C++. Mike As always, comments and criticism welcome. -- /********************************************************\ * Michael David Nahas nahas@virginia.edu * * Graduate Student in CS University of Virginia * \********************************************************/ ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Michael D. Nahas @ 1997-10-01 4:00 ` brianh 1997-10-01 4:00 ` Stefan Monnier 1997-10-02 4:00 ` Eric Hildum 2 siblings, 0 replies; 48+ messages in thread From: brianh @ 1997-10-01 4:00 UTC (permalink / raw) In article <34326556.2216DC70@virginia.edu>, Michael D. Nahas <nahas@virginia.edu> wrote: >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. > >For a standard function, you just branch to the address. With C++'s >virtual >functions you either follow a pointer or perform an indexed lookup to a >jump >table, which will load the address you will jump to, and then branch to >that >address. > >Why is indirection bad? When the destination address of a jump is known, >the processor >can begin fetching from the new address and continue executing. When the >destination address of the jump is unknown, the processor usually stalls >until >the address comes in from memory. Some processors do have hardware to >speed up indirect jumps, but the hardware was developed using C benchmarks, > >where 90% of indirect jumps are just returns from functions. The problem is not the double indirection- which can be handled if the CPU prefetchs data as well as instructions- but the fact that you are doing two memory accesses now instead of one, and usually widely seperate memory accesses (most implementations don't AFAIK actually keep the virtual function tables with the class data, but in a seperate structure shared by all objects of the same type- which is usually somewhere far away from where the data ends up). This is a symptom of the fact that memory has not increased in speed the same way CPUs have (I put 70ns memory into my 386- granted, no FPM or EDO, but still... And the 386 still needed cache). The only thing more painfull on performance than leaving cache and waiting on main memory is leaving main memory and swapping pages into disk. Compilers (and programmers!) should worry more about locality of reference. If you are going to blow cache, the question arises "is it worth it?". For sparse matricies, the answer is obviously yes (the alternative is to swap like mad)- although the matrix solving programs should be written to be cache aware, and keep locality of reference up. For virtual functions, I think the benefits outweigh the gains, although it depends critically on what you're doing. I note the Fortran is still one of the two best languages for doing numeric computation in- only recently have there been C compilers as good as Fortran compilers (and even in these cases you often find they share an optimizer with a Fortran compiler- examples include SGI's MipsPro compilers, and HP's compilers). > >The truely evil part of indirection is not in function calls, but in the >non-array >data structures of most programs. Think of traversing a linked list. To >load the >first node in the list, it takes as much time as the memory latency. To >load the >second node, you must first load the first node, and then pay the cost of >the >memory latency time again. So to traverse a N node linked list, it takes N >times >the memory latency. > >For most cases, the nodes are contiguous in memory and most programs run >inside the L1 and L2 cache, so these latencies are not too bad for most >programs. >However, programs which do not fit in large L2 caches, such as sparse >matrix >programs and the X Windows system, pay heavily. The latency time of going >to >main memory is growing exponentially in terms of CPU cycles. > >So, is this a problem, and if so, how do we fix it. Yes, it is a problem, >because any >stall to the pipeline which prevents speculative execution is bad. How do >we >solve it? The first thing to do is to make programs which have this >problem part >of the SPEC Benchmarks. This will make it the focus of everyone's >attention. >The other thing that can be done is to look at Compiler optimizations - >many of >the indirect function calls can be eliminated, especially if all the source >is compiled >together. Separate compilation of object files requires general interfaces >which >prevent many optimizations. > >Also, a note on Java. All Java functions are virtual and all require a >general >interface on a class level. Lastly, all objects are referenced indirectly, >so even an >array of Java objects is two levels of indirection to get the object you >want! So, >Java is even worse than C++. > > Mike > >As always, comments and criticism welcome. > >-- >/********************************************************\ >* Michael David Nahas nahas@virginia.edu * >* Graduate Student in CS University of Virginia * >\********************************************************/ > I don't speak for Bit 3. Brian -- "NT and security should never be used in the same breath." - Winn Schwartau, EETimes #972, 22 September 1997 pp.96 -Brian ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Michael D. Nahas 1997-10-01 4:00 ` brianh @ 1997-10-01 4:00 ` Stefan Monnier 1997-10-01 4:00 ` Nick Maclaren 1997-10-02 4:00 ` Eric Hildum 2 siblings, 1 reply; 48+ messages in thread From: Stefan Monnier @ 1997-10-01 4:00 UTC (permalink / raw) "Michael D. Nahas" <nahas@virginia.edu> 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, ... ?" Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Stefan Monnier @ 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Allen Kim ` (5 more replies) 0 siblings, 6 replies; 48+ messages in thread From: Nick Maclaren @ 1997-10-01 4:00 UTC (permalink / raw) In article <5l90wd2sbj.fsf@tequila.systemsz.cs.yale.edu>, Stefan Monnier <monnier+comp/arch/news/@tequila.cs.yale.edu> wrote: >"Michael D. Nahas" <nahas@virginia.edu> 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren @ 1997-10-01 4:00 ` Allen Kim 1997-10-01 4:00 ` John Wilson ` (4 subsequent siblings) 5 siblings, 0 replies; 48+ messages in thread From: Allen Kim @ 1997-10-01 4:00 UTC (permalink / raw) Nick Maclaren wrote: > > 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. Despite the fact that you guys are coming pretty close to speaking pure "Greek" here (or is it "geek"?), I'll try and add a little to the discussion. My impression with Merced and VLIW-like architectures which move branch optimization out to the compiler is that instructions like the one above can be solved by very advanced techniques which effectively turn pieces of code into "trees" which each calculate a number of possible outcomes at once. Now I know that with that statement, I probably distorted the actual concept, but I'm hoping you'll understand. Anyway, trees like this would involve multiple memory accesses at once, which could be the potential bottleneck unless some very sophisticated caching and bus transaction mechanisms are developed. See this link for more info: http://www.research.ibm.com/vliw/home.html Disclaimer: I don't speak officially for Intel, and I don't work on the Merced processor itself. I *do* work on the chipset which will support Merced, but that doesn't mean I know the intricate details of the processor. -- Allen Kim allenkim@scic.intel.com ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Allen Kim @ 1997-10-01 4:00 ` John Wilson 1997-10-01 4:00 ` P Murray ` (3 subsequent siblings) 5 siblings, 0 replies; 48+ messages in thread From: John Wilson @ 1997-10-01 4:00 UTC (permalink / raw) In article <60uek7$fon$1@lyra.csx.cam.ac.uk>, Nick Maclaren <nmm1@cus.cam.ac.uk> wrote: >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. Luckily we still have good ol' assembly language! Sorry, couldn't resist -- the paragraph above nicely supports my personal prejudices though. :-) John Wilson D Bit ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Allen Kim 1997-10-01 4:00 ` John Wilson @ 1997-10-01 4:00 ` P Murray 1997-10-01 4:00 ` Nick Maclaren 1997-10-02 4:00 ` Torben AEgidius Mogensen 1997-10-02 4:00 ` Stefan Monnier ` (2 subsequent siblings) 5 siblings, 2 replies; 48+ messages in thread From: P Murray @ 1997-10-01 4:00 UTC (permalink / raw) Nick Maclaren (nmm1@cus.cam.ac.uk) wrote: : 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. Any suggestions on what such a language would look like? Hopefully it will not look like ASM. Would it be possible to modify C/C++ in such a way as to allow this? And finally, could anyone recommend ways to code in C/C++ that avoid these problems and allow the optimiser to produce the most efficient code? I assume virtual function calls would be out, as well as all forms of aliasing. Cheers, - Peter. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` P Murray @ 1997-10-01 4:00 ` Nick Maclaren 1997-10-02 4:00 ` Andrew Glew 1997-10-02 4:00 ` Vesa Karvonen 1997-10-02 4:00 ` Torben AEgidius Mogensen 1 sibling, 2 replies; 48+ messages in thread From: Nick Maclaren @ 1997-10-01 4:00 UTC (permalink / raw) In article <60ui2q$33a$1@cdn-news.telecom.com.au>, P Murray <pcm@vus002.telecom.com.au> wrote: >Nick Maclaren (nmm1@cus.cam.ac.uk) wrote: > >: 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. > >Any suggestions on what such a language would look like? Hopefully >it will not look like ASM. Would it be possible to modify C/C++ in >such a way as to allow this? Well, I would favour something using the more successful ideas of Algol 68 :-) But it would have to include some of the concepts of the stricter functional languages. >And finally, could anyone recommend ways to code in C/C++ that >avoid these problems and allow the optimiser to produce the >most efficient code? I assume virtual function calls would >be out, as well as all forms of aliasing. Yes. And, if you can code C without implying aliasing, I take my hat off to you! The biggest problem with attempting this is that you can only 'const qualify' at the top level and, for efficient code-generation, you need to do it at other levels. I believe that the new 'restrict' in C9X is a sort of recursive 'const', but have not seen a specification. 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren @ 1997-10-02 4:00 ` Andrew Glew 1997-10-02 4:00 ` Vesa Karvonen 1 sibling, 0 replies; 48+ messages in thread From: Andrew Glew @ 1997-10-02 4:00 UTC (permalink / raw) To: Nick Maclaren > Well, I would favour something using the more successful ideas of > Algol 68 :-) But it would have to include some of the concepts of the > stricter functional languages. Nick: you and I both love Algol68! But when I have looked at Algol68 compiler produced assembly code, it looks remarkably like C++. The best thing that Algol68 had going for it is that it allowed many of the virtual function decisions to be made lexically, at compile time. But only, I believe, in the absence of separate compilation (or in the presence of a smart linker). ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren 1997-10-02 4:00 ` Andrew Glew @ 1997-10-02 4:00 ` Vesa Karvonen 1997-10-02 4:00 ` Joseph H Allen 1 sibling, 1 reply; 48+ messages in thread From: Vesa Karvonen @ 1997-10-02 4:00 UTC (permalink / raw) Nick Maclaren wrote: > In article <60ui2q$33a$1@cdn-news.telecom.com.au>, > P Murray <pcm@vus002.telecom.com.au> wrote: > >Nick Maclaren (nmm1@cus.cam.ac.uk) wrote: > > > >: 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. > > > >Any suggestions on what such a language would look like? Hopefully > >it will not look like ASM. Would it be possible to modify C/C++ in > >such a way as to allow this? > > Well, I would favour something using the more successful ideas of > Algol 68 :-) But it would have to include some of the concepts of the > stricter functional languages. > > >And finally, could anyone recommend ways to code in C/C++ that > >avoid these problems and allow the optimiser to produce the > >most efficient code? I assume virtual function calls would > >be out, as well as all forms of aliasing. > > Yes. And, if you can code C without implying aliasing, I take my hat > off to you! The biggest problem with attempting this is that you can > only 'const qualify' at the top level and, for efficient code-generation, > you need to do it at other levels. I believe that the new 'restrict' in > C9X is a sort of recursive 'const', but have not seen a specification. Being an assembly language programmer before learning C, I used to think a bit like you are thinking after seeing the bad code produced by aliasing problems and the like in C. However, after reading "The C++ Programming Language" (second edition) by Bjarne Stroustrup, and seeing that he actually tells you which language constructs generate extra overhead, I have to disagree about leaving language features out simply because they are "bad for the optimizer/processor"; you can always tell the programmers what is bad for the optimizer and the processor. Leaving out useful language constructs, like virtual functions, will only make the language hard to use, by modern standards, and restricts the useability of the language by making certain applications too difficult to implement in the language. With the exception of aliasing problems and problems with restructuring floating point expressions, I see very little room for defining a "faster" C (for single processor systems anyway). The "restrict" qualifier would/will fix the aliasing problem in C. Of course, the problem is that a lot of old code has to be modified, which is usually rather costly. It might not even be necessary to have "restrict", since some of the worse aliasing problems could also be fixed by specifying some kind of syntax for parallel execution of statements/expressions. Such a syntax could come very handy in vector code, for instance. Most optimizing C compilers have optimization switches that can be used to fix both the aliasing and the floating point expression restructuring problems. -- <--> Vesa Karvonen | If I were speaking for my Housemarque Games, Inc. | employer, you would not be http://www.housemarque.com | reading this... ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Vesa Karvonen @ 1997-10-02 4:00 ` Joseph H Allen 1997-10-02 4:00 ` Wilco Dijkstra 1997-10-03 4:00 ` Stefan Monnier 0 siblings, 2 replies; 48+ messages in thread From: Joseph H Allen @ 1997-10-02 4:00 UTC (permalink / raw) In article <3432F896.7FD2@HousemarqueREM.fi>, Vesa Karvonen <Vesa.Karvonen@HousemarqueREM.fi> wrote: >Nick Maclaren wrote: >> Yes. And, if you can code C without implying aliasing, I take my hat >> off to you! The biggest problem with attempting this is that you can >> only 'const qualify' at the top level and, for efficient code-generation, >> you need to do it at other levels. I believe that the new 'restrict' in >> C9X is a sort of recursive 'const', but have not seen a specification. More complicated key words. Yuck, that's just what C needs. >Being an assembly language programmer before learning C, I used >to think a bit like you are thinking after seeing the bad code >produced by aliasing problems and the like in C. I'm still waiting for someone to try a hardware fix for the aliasing problem. One way is to make the internal registers more like a cache than they are now. Then when you load a word into a register, you also load the memory address where the word came from into some auxiliary part of the register. The register snoops the bus at this point: if a subroutine modifies the memory at that address, a bit in the register is set. If the caller then accesses that register you get a trap or delay and a reload occurs. Using this, you can have your compiler safely assume that there are no aliases, and avoid doing tons of reloads after every subroutine call. Of course this only solves the problem of aliases which depend on a single memory location as their source, not complicated values which depend on multiple memory locations. But in a language like C++, I would guess that most of the aliases are like this anyway (like the base addresses of objects, or whatever). I suppose you could even have more general alias detection hardware which would allow you to detect if any of the sources of a derived value were modified- it would just cost more. Other hardware could conceivably solve more general alias and dependancy problems than those caused by non-local subroutine calls. For example: if a==z then x=5 y=x+3 causes a pipeline stall of some sort, because y is an alias for x, but 'y=x+3' can not occur until it is known whether the previous conditional is going to modify x. The compiler can't do this because a and z could be arbitrary non-constant values. But with extra hardware, there are possibilities. Maybe you do y=x+3 at the same time that you do the if(a==z), but also have a 'y=8' on standby, in case the x=5 ended up happening. A branchless version of the above code could be done with a few extra interesting flag bits, instructions which occur only conditionally as on the ARM and a compiler which is aware of the processor's pipeline structure. -- /* jhallen@world.std.com (192.74.137.5) */ /* Joseph H. Allen */ int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0) +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2 ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);} ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Joseph H Allen @ 1997-10-02 4:00 ` Wilco Dijkstra 1997-10-03 4:00 ` Stefan Monnier 1997-10-03 4:00 ` Jason.Ozolins 1997-10-03 4:00 ` Stefan Monnier 1 sibling, 2 replies; 48+ messages in thread From: Wilco Dijkstra @ 1997-10-02 4:00 UTC (permalink / raw) Joseph H Allen wrote: > I'm still waiting for someone to try a hardware fix for the aliasing > problem. One way is to make the internal registers more like a cache than > they are now. Then when you load a word into a register, you also load the > memory address where the word came from into some auxiliary part of the > register. The register snoops the bus at this point: if a subroutine > modifies the memory at that address, a bit in the register is set. If the > caller then accesses that register you get a trap or delay and a reload > occurs. Using this, you can have your compiler safely assume that there are > no aliases, and avoid doing tons of reloads after every subroutine call. I don't think it's a good idea to try to create expensive hardware solutions to the aliasing problem - it's software that created it in the first place! You just need to find the cases where aliasing is appropriate and ban all other uses. This is similar to gotos. It's my belief that almost all aliasing is avoidable at low cost during compilation. For example most aliasing is due to function calls. With global aliasing analysis the complete set of aliases can be calculated. Of course a good language which avoids most of the aliasing problems (eg. the ADA parameter passing mechanism) would help! ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Wilco Dijkstra @ 1997-10-03 4:00 ` Stefan Monnier 1997-10-03 4:00 ` Jason.Ozolins 1 sibling, 0 replies; 48+ messages in thread From: Stefan Monnier @ 1997-10-03 4:00 UTC (permalink / raw) Wilco Dijkstra <Wilco.Dijkstra@NOSPAMarm.com> writes: > With global aliasing analysis the complete set of aliases can be > calculated. A problem that requires global analysis to be solved is a BIG problem that should be gotten rid of instead of "solved". Especially because global analysis is not possible in some settings (that I consider as desirable, by the way). Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Wilco Dijkstra 1997-10-03 4:00 ` Stefan Monnier @ 1997-10-03 4:00 ` Jason.Ozolins 1997-10-03 4:00 ` Alex Colvin 1 sibling, 1 reply; 48+ messages in thread From: Jason.Ozolins @ 1997-10-03 4:00 UTC (permalink / raw) In <3433AAC0.10C4@NOSPAMarm.com> Wilco Dijkstra <Wilco.Dijkstra@NOSPAMarm.com> writes: >It's my belief that almost all aliasing is avoidable at low cost during >compilation. For example most aliasing is due to function calls. With >global >aliasing analysis the complete set of aliases can be calculated. Of >course >a good language which avoids most of the aliasing problems (eg. the ADA >parameter >passing mechanism) would help! Hmmm... I think Pascal had the right approach when it came to reference parameters: the effects of passing the same variable into a function via more than one VAR parameter were "undefined", which left the language implementor more scope for optimization. The mechanism was perhaps less important than the simple fact that there was no guarantee that reference parameters would work correctly in the presence of aliasing, so you didn't do it. Conclusion: C/C++ would be nicer languages if they had much more undefined behaviour. :-) :-) (Not having any C++ standards around, I ought to ask: Are C++ references guaranteed to work in the presence of aliasing?) _____________________________________________________________________________ Jason Ozolins (Jason.Ozolins@anu.edu.au) | Put your hands over your eyes. Teaching and Learning Technology Support Unit| Jump out of the plane. Australian National University | There is no pilot. My opinions, not ANU's. | You are not alone. -- ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Jason.Ozolins @ 1997-10-03 4:00 ` Alex Colvin 1997-10-06 4:00 ` Richard A. O'Keefe 0 siblings, 1 reply; 48+ messages in thread From: Alex Colvin @ 1997-10-03 4:00 UTC (permalink / raw) >Hmmm... I think Pascal had the right approach when it came to reference >parameters: the effects of passing the same variable into a function >via more than one VAR parameter were "undefined", which left the >language implementor more scope for optimization. Last time I mentioned this, I was informed that this restrictition had been dropped. Support for aliasing may be a good thing. Undefining the effect of aliasing looks likely to lead to seriously obscure bugs, unless you can check this behavior at compile time. -- Alex Colvin alex.colvin@dartmouth.edu ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Alex Colvin @ 1997-10-06 4:00 ` Richard A. O'Keefe 1997-10-08 4:00 ` Zalman Stern 0 siblings, 1 reply; 48+ messages in thread From: Richard A. O'Keefe @ 1997-10-06 4:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2604 bytes --] mac@coos.dartmouth.edu (Alex Colvin) writes: >>Hmmm... I think Pascal had the right approach when it came to reference >>parameters: the effects of passing the same variable into a function >>via more than one VAR parameter were "undefined", which left the >>language implementor more scope for optimization. >Last time I mentioned this, I was informed that this restrictition had >been dropped. ISO 10206:1990, Extended Pascal has four kinds of parameters: a: integer; pass by copy-in, modifiable var b: integer; pass by reference, modifiable protected c: integer; pass by copy-in, not modifiable protected var d: integer; pass by reference, not modifiable The confusing thing (Note 2, p55) is that a protected variable parameter (protected var) may not be changed, but it may change. This is the only mention of 'aliasing' that I can find in that standard. Of course this kind of thing is very upsetting to optimisers. It means that in the sequence of statements x := d; <FOO!> x := d; where <FOO!> contains no other assignments to x, if <FOO!> contains any assignments to non-local integer variables or procedure calls, x will have to be reloaded, even tough _this_ procedure isn't allowed to modify d directly. This is even more upsetting to human reasoning than to optimisers. >Support for aliasing may be a good thing. Undefining the effect of >aliasing looks likely to lead to seriously obscure bugs, unless you can >check this behavior at compile time. Consider this: C If this were F90, I'd have INTENT OUT stated explicitly SUBROUTINE BREAK(X, Y) REAL X, Y X = 1.0 Y = 2.0 END PROGRAM MAIN REAL A(10) INTEGER I, J READ * I, J CALL BREAK(A(I), A(J)) PRINT *, A(I), A(J) END What is the output of this program? How is the compiler to check at compile time that I.NE.J? It is important to distinguish between case where you WANT to support aliasing (which is the expensive option) and cases where you DON'T (which is the high performance option). Ada 95 did the right thing here, requiring you to explicitly declare any potentially aliased variables. Aliasing is very confusing for people to deal with. Of course, as soon as you have objects as in Smalltalk or Common Lisp or Java, you have precisely the same kind of problem when the same object reference can be passed (the _reference_ is passed by copy-in) to a procedure. -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-06 4:00 ` Richard A. O'Keefe @ 1997-10-08 4:00 ` Zalman Stern 0 siblings, 0 replies; 48+ messages in thread From: Zalman Stern @ 1997-10-08 4:00 UTC (permalink / raw) Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au) wrote: : Aliasing is very confusing for people to deal with. : Of course, as soon as you have objects as in Smalltalk or Common Lisp or : Java, you have precisely the same kind of problem when the same object : reference can be passed (the _reference_ is passed by copy-in) to a : procedure. See for example item 17 in Scott Meyers' _Effective_C++_ titled "Check for assignment to self in operator=." The item explains that the statement: a = a; in C++ may not be a "nop" for an improperly implemented assignment operator. (I wonder if the C++ draft standard allows the compiler to punt on calling the assignment operator in that case. I doubt it...) -Z- ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Joseph H Allen 1997-10-02 4:00 ` Wilco Dijkstra @ 1997-10-03 4:00 ` Stefan Monnier 1 sibling, 0 replies; 48+ messages in thread From: Stefan Monnier @ 1997-10-03 4:00 UTC (permalink / raw) jhallen@world.std.com (Joseph H Allen) writes: > I'm still waiting for someone to try a hardware fix for the aliasing > problem. It's not so simple: knowledge of "no-aliasing" is not used just to spare a reload at each use of some value, it's used for dependency analysis to allow code reordering. Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` P Murray 1997-10-01 4:00 ` Nick Maclaren @ 1997-10-02 4:00 ` Torben AEgidius Mogensen 1997-10-02 4:00 ` Patrick F. McGehearty 1 sibling, 1 reply; 48+ messages in thread From: Torben AEgidius Mogensen @ 1997-10-02 4:00 UTC (permalink / raw) pcm@vus002.telecom.com.au (P Murray) writes: >Nick Maclaren (nmm1@cus.cam.ac.uk) wrote: >: 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. >Any suggestions on what such a language would look like? Hopefully >it will not look like ASM. Would it be possible to modify C/C++ in >such a way as to allow this? A possibility is SML using the region-based memory model. You would still do pointer cahsing, but the regions model keep a fairly good locality (elements of the same list stay close, even when other data is allocated in-between). In SML you also avoid most of the aliasing problems of C/C++. The technology still needs a few years to be competitive with C. One problem is that the polymorphic type system in SML introduces extra indirections (boxing). This can be solved if you compile the entire program in one job, as the polymorphism can be eliminated when all uses are known. Though, theoretically, this can give an exponetial blow-up in code size, experiments show that the code expansion is usually small. You can use the regions model on C-like languages, but you would have to give up on a lot of the 'dirty' features of C, such as type casting and varargs. >And finally, could anyone recommend ways to code in C/C++ that >avoid these problems and allow the optimiser to produce the >most efficient code? I assume virtual function calls would >be out, as well as all forms of aliasing. It is not enough that you avoid aliasing. The compiler must be able to recognize that there is none. And this is not often possible, especially if you use separate compilation. If a language is designed such that aliasing doesn't occur or only does so in easily identifiable contexts (e.g. array lookups), the compiler can use this assumption safely, even without complex and inaccurate analysis. Torben Mogensen (torbenm@diku.dk) ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Torben AEgidius Mogensen @ 1997-10-02 4:00 ` Patrick F. McGehearty 1997-10-02 4:00 ` brianh ` (2 more replies) 0 siblings, 3 replies; 48+ messages in thread From: Patrick F. McGehearty @ 1997-10-02 4:00 UTC (permalink / raw) In article <60vj9p$7mg@vidar.diku.dk>, Torben AEgidius Mogensen <torbenm@diku.dk> wrote: >pcm@vus002.telecom.com.au (P Murray) writes: > >>Nick Maclaren (nmm1@cus.cam.ac.uk) wrote: > >>: 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. > >>Any suggestions on what such a language would look like? Hopefully >>it will not look like ASM. Would it be possible to modify C/C++ in >>such a way as to allow this? > >A possibility is SML using the region-based memory model. You would >still do pointer cahsing, but the regions model keep a fairly good >locality (elements of the same list stay close, even when other data >is allocated in-between). In SML you also avoid most of the aliasing >problems of C/C++. The technology still needs a few years to be >competitive with C. One problem is that the polymorphic type system in >SML introduces extra indirections (boxing). This can be solved if you >compile the entire program in one job, as the polymorphism can be >eliminated when all uses are known. Though, theoretically, this can >give an exponetial blow-up in code size, experiments show that the >code expansion is usually small. > Code expansion is not the problem. Compile time is. Large development projects involve 100's of modules of code in the 100,000 to 1,000,000 lines of code range. It only takes one unbounded non-linear optimization algorithm to cause full-program compiles to take so long that you start worrying about the halting problem. That is, after a couple of days of computing, you don't know if the compiler is in an infinite loop or still computing. The "couple of days" is not an exaggeration. I've seen a 1000 line program take over a day due to a single unbounded non-linear optimization algorithm. As someone working professionally in compiler performance for the last few years, I'll take any help I can get from language definition to bound the amount of code that must be examined to determine if an optimization is safe. Since I've been in graduate school (over 20 years ago), I've been hearing about how this language feature or that can be optimized, but I've seldom seen these optimizations actually be performed. It takes a lot of work to cover all the cases, and rarely used language features are often ignored when it comes time to enhance optimizers. Nick is absolutely dead-on when he identifies the aliasing problem as one of the most troubling in C. Fortran avoids that problem by defining it away. Users are seldom aware of the compiler switches which say "ignore aliasing". In addition, the switches are different for different platforms, so standard make files for multiplatform products don't use them. A plausible compromise for future languages would be to have a default that assumes Fortran aliasing rules and to require a declaration to allow aliasing when it is needed. Then most of the time, the compiler can generate fast code and only when aliasing is strictly needed will optimization be degraded. On the C++ virtual function issue, what is needed is more training of C++ programmers to avoid inefficient constructs except when they are really necessary, and to provide whatever language advisories possible to help the compiler along. While processor speeds continue to increase at exponential rates, memory latencies are improving much more slowly. Ten years ago, the cost of a non-cache memory access was less than 10 instructions. Four years ago, it was less than 40 instructions. Now it is well over 100 instructions on super-scalar architectures. The exact numbers will vary depending on which architectural family you look at, but the trend line is clear. And everything I'm aware of indicates that it will only get worse in the future. Virtual functions that cannot be optimized to static addresses at compile or link time are the enemy of performance, and future processor speed improvements will only make situation more extreme. - Patrick McGehearty patrick@convex.hp.com ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Patrick F. McGehearty @ 1997-10-02 4:00 ` brianh 1997-10-03 4:00 ` Virtual functions (was Re: Final kick at the "Merced Guessing Game") Steven Correll 1997-10-03 4:00 ` Final kick at the "Merced Guessing Game" Michael Williams 2 siblings, 0 replies; 48+ messages in thread From: brianh @ 1997-10-02 4:00 UTC (permalink / raw) >On the C++ virtual function issue, what is needed is more training of C++ >programmers to avoid inefficient constructs except when they are really >necessary, and to provide whatever language advisories possible to help the >compiler along. While processor speeds continue to increase at exponential >rates, memory latencies are improving much more slowly. Ten years ago, the >cost of a non-cache memory access was less than 10 instructions. Four years >ago, it was less than 40 instructions. Now it is well over 100 instructions >on super-scalar architectures. The exact numbers will vary depending on >which architectural family you look at, but the trend line is clear. And >everything I'm aware of indicates that it will only get worse in the future. >Virtual functions that cannot be optimized to static addresses at compile or >link time are the enemy of performance, and future processor speed >improvements will only make situation more extreme. There's a reason Java defined all methods as virtual methods- and why it was bad that C++ didn't. One of the big advantages of OO programming is code reuse- the problem with this is that you never know, when you write an object, what uses you may put that object to months or years from now. In fact, it is the mark of a good object design when it's used in ways the original author never thought of. The cost of this is (currently) an extra memory reference, which is almost certainly not cached, and possibly even swapped out. We're trying to get away from the model where "this code will only be used in this way in this program" is the norm. Two technologies that may make the situation better, as I see it: 1) Just in time compliation, which can say "In the general case, this needs to be a virtual function, but in this specific case I know it will always be this function." 2) Large, native system libraries, which should be written and compiled by people who really know the system, and only for that system, probably with -no-aliasing flags set (among others). But, in the end, we still have the basic problem: CPUs are way faster than main memory and getting faster. _This_ is the problem, not "bad programming". There is a solution to it (faster memory), but wether or not it's worth it will be determined by the market. And we are seeing, at least in the workstations, more attention being paid to the memory architectures to help allieviate this problem. You're also seeing bigger caches, the other way to allieviate the problem. I don't speak for Bit 3. Brian. > >- Patrick McGehearty >patrick@convex.hp.com -- "NT and security should never be used in the same breath." - Winn Schwartau, EETimes #972, 22 September 1997 pp.96 -Brian ^ permalink raw reply [flat|nested] 48+ messages in thread
* Virtual functions (was Re: Final kick at the "Merced Guessing Game") 1997-10-02 4:00 ` Patrick F. McGehearty 1997-10-02 4:00 ` brianh @ 1997-10-03 4:00 ` Steven Correll 1997-10-03 4:00 ` Final kick at the "Merced Guessing Game" Michael Williams 2 siblings, 0 replies; 48+ messages in thread From: Steven Correll @ 1997-10-03 4:00 UTC (permalink / raw) In article <610gbg$k3t@deadzone.rsn.hp.com>, Patrick F. McGehearty <patrick@convex.COM> wrote: >On the C++ virtual function issue, what is needed is more training of C++ >programmers to avoid inefficient constructs except when they are really >necessary, and to provide whatever language advisories possible to help the >compiler along... >Virtual functions that cannot be optimized to static addresses at compile or >link time are the enemy of performance, and future processor speed >improvements will only make situation more extreme. Telling C++ programmers in 1997 to avoid virtual functions because they make the program run slower is a lot like telling Fortran programmers in 1970 to avoid subroutine calls for that same reason. They are all too likely to follow your advice, and given the choice of maintaining a ten-year-old C++ program with "virtual" missing from most but not all of its functions, versus a twenty-year-old Fortran program which was written as a single 100000 line subroutine, I might choose the Fortran program--at least it's provably possible to restructure it based solely on static information. But probably I'd just look for a new line of work, like clearing stuck toilets. -- Steven Correll == PO Box 66625, Scotts Valley, CA 95067 == sjc@netcom.com ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Patrick F. McGehearty 1997-10-02 4:00 ` brianh 1997-10-03 4:00 ` Virtual functions (was Re: Final kick at the "Merced Guessing Game") Steven Correll @ 1997-10-03 4:00 ` Michael Williams 2 siblings, 0 replies; 48+ messages in thread From: Michael Williams @ 1997-10-03 4:00 UTC (permalink / raw) In article <610gbg$k3t@deadzone.rsn.hp.com>, Patrick F. McGehearty <patrick@convex.COM> wrote: > That is, >after a couple of days of computing, you don't know if the compiler is >in an infinite loop or still computing. The "couple of days" is not an >exaggeration. I've seen a 1000 line program take over a day due to a >single unbounded non-linear optimization algorithm. I once discovered a case where our compiler's CSE would take O(e^N) to compile code, where N was the number of variables in the expression. (The code was x5=x1+x2+x3+x4; x6=x2+x3+x4+x5; ... x4=xN+x1+x2+x3.) I calculated that a simple 52 line program would take order of 250 years per line to compile. Needless to say, it got fixed. Mike. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren ` (2 preceding siblings ...) 1997-10-01 4:00 ` P Murray @ 1997-10-02 4:00 ` Stefan Monnier 1997-10-03 4:00 ` Richard A. O'Keefe 1997-10-02 4:00 ` Jon Leech 1997-10-03 4:00 ` Mike Smith 5 siblings, 1 reply; 48+ messages in thread From: Stefan Monnier @ 1997-10-02 4:00 UTC (permalink / raw) nmm1@cus.cam.ac.uk (Nick Maclaren) writes: > In article <5l90wd2sbj.fsf@tequila.systemsz.cs.yale.edu>, > Stefan Monnier <monnier+comp/arch/news/@tequila.cs.yale.edu> wrote: > >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 I'm sorry, but I can't seem to remember that Pascal disallows aliasing (I honestly don't know about Algol). Furthermore, do you really believe that aliasing information would help for GUI-like code ? Do you really think the problem is due to coding style (like the Xwin code) and to programming languages (like C) rather than to what is being coded (like a user interface rather than a numerical simulation) ? > 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. Because the trend is to say "CPUs are fast enough, let's care about programmer's convenience". You seem to care about Fortran code, so probably more numerical-oriented, in which case convenience is still a secondary concern whereas speed is paramount. I can only agree to the fact that languages should be developped to better take advantage of current (and future) technology, but programmer's convenience cannot be sacrificed so easily so it's a very hard design problem and I still haven't heard of any convincing proposition (the best I've heard is in the NA area where Sisal sounds pretty interesting). Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-02 4:00 ` Stefan Monnier @ 1997-10-03 4:00 ` Richard A. O'Keefe 0 siblings, 0 replies; 48+ messages in thread From: Richard A. O'Keefe @ 1997-10-03 4:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 3514 bytes --] Stefan Monnier <monnier+comp/arch/news/@tequila.cs.yale.edu> writes: >I'm sorry, but I can't seem to remember that Pascal disallows aliasing (I >honestly don't know about Algol). Furthermore, do you really believe that >aliasing information would help for GUI-like code ? Do you mean "code like that which USES a GUI" or "code like that which IMPLEMENTS a GUI"? I note that one of my favourite languages (Clean) has an elegant GUI *using* interface which has complete freedom from aliasing. Clean is a *pure* lazy functional language, there are no assignments at all. The intention is that the compiler will _implement_ "make a record/array just like this one except for these few differences" destructively, _but_ only when it is safe, and the type system tells the compiler at compile time which references are the only reference to such a datum. Let me offer an example: :: Complex = { re :: Real, im :: Real } conj_in_place : *Complex -> *Complex conj_in_place c=:{im=i} = {c & im= ~i} The * here in front of the type before the arrow means that a call to this function is legal only if the compiler can prove that this is the _only_ reference remaining to that record. The * in front of the type after the arrow means that there will be no other references to the result. Because the argument is 'dead' after the call, the compiler is allowed to update it in place. The uniqueness type system in Clean is surprisingly easy to use, and it means that the compiler can be *certain* that aliasing is not taking place. (To be fair, since Clean is a higher order language with Haskell-ish type classes, it has its own fair share of calling functions via pointers.) As for code that *implements* a GUI, the bit-shuffling stuff that gets done in the server would indeed benefit from a language that allows more and better optimisation. >Do you really think the problem is due to coding style (like the Xwin >code) and to programming languages (like C) rather than to what is being >coded (like a user interface rather than a numerical simulation) ? Yep. I keep on pointing out to students here (with examples) that the *really* big speedups come from high level reasoning that eliminates operations completely, rather than from *manual* low-level fiddling. Computer hardware has changed *immensely* in my lifetime. My intuition about what is fast and what is slow keeps needing dramatic revision. The one guideline that still works after 20 years is "keep your code as clean as possible so that the compiler has a chance of figuring out what's supposed to happen". (Well, there's another one: keep your working set small; avoid going to slow memory if you can; if you can't avoid that, avoid the disc; if you can't avoid disc, avoid tape; and whatever you do, don't use paper tape.) >> 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. >Because the trend is to say "CPUs are fast enough, let's care about >programmer's convenience". Hmm. Current trends include C, C++, and Java, which are all of them remarkably opposed to the programmer's convenience. (I have a hard time believing how clumsy and verbose Java is.) -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren ` (3 preceding siblings ...) 1997-10-02 4:00 ` Stefan Monnier @ 1997-10-02 4:00 ` Jon Leech 1997-10-03 4:00 ` Mike Smith 5 siblings, 0 replies; 48+ messages in thread From: Jon Leech @ 1997-10-02 4:00 UTC (permalink / raw) In article <60uek7$fon$1@lyra.csx.cam.ac.uk>, Nick Maclaren <nmm1@cus.cam.ac.uk> wrote: >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. Perhaps language designers are more concerned with efficient use of programmers than efficient use of hardware. What we need to do on today's hardware may be completely inappropriate 10 years down the road, while fundamental data structures remain pretty much the same. Jon __@/ ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Nick Maclaren ` (4 preceding siblings ...) 1997-10-02 4:00 ` Jon Leech @ 1997-10-03 4:00 ` Mike Smith 1997-10-03 4:00 ` Nick Maclaren 5 siblings, 1 reply; 48+ messages in thread From: Mike Smith @ 1997-10-03 4:00 UTC (permalink / raw) Nick Maclaren <nmm1@cus.cam.ac.uk> wrote in article <60uek7$fon$1@lyra.csx.cam.ac.uk>... > > 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 Eh? Somebody better tell this to the people at Intel, AMD, and Cyrix, all of which have processors that perform specul- ative execution, IIRC. --Mike Smith ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Mike Smith @ 1997-10-03 4:00 ` Nick Maclaren 1997-10-03 4:00 ` Rob Barris 0 siblings, 1 reply; 48+ messages in thread From: Nick Maclaren @ 1997-10-03 4:00 UTC (permalink / raw) In article <01bcd02b$58e67280$0200000a@kld_mcs>, Mike Smith <kld_msmith@earthlink.nospam.net> wrote: >Nick Maclaren <nmm1@cus.cam.ac.uk> wrote in article ><60uek7$fon$1@lyra.csx.cam.ac.uk>... >> >> 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 > >Eh? Somebody better tell this to the people at Intel, AMD, >and Cyrix, all of which have processors that perform specul- >ative execution, IIRC. Please don't confuse preloading and branch prediction with speculative execution. I gave a very simple example, which could be done solely by preexecuting address calculation instructions but, in general, that is not the case. I am pretty sure that none of the processors you mention do any significant amount of speculative execution. 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Nick Maclaren @ 1997-10-03 4:00 ` Rob Barris 1997-10-03 4:00 ` Andrew Glew 1997-10-04 4:00 ` Nick Maclaren 0 siblings, 2 replies; 48+ messages in thread From: Rob Barris @ 1997-10-03 4:00 UTC (permalink / raw) In article <613p2b$g1r$1@lyra.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk (Nick Maclaren) wrote: > In article <01bcd02b$58e67280$0200000a@kld_mcs>, > Mike Smith <kld_msmith@earthlink.nospam.net> wrote: > >Nick Maclaren <nmm1@cus.cam.ac.uk> wrote in article > ><60uek7$fon$1@lyra.csx.cam.ac.uk>... > >> > >> 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 > > > >Eh? Somebody better tell this to the people at Intel, AMD, > >and Cyrix, all of which have processors that perform specul- > >ative execution, IIRC. > > Please don't confuse preloading and branch prediction with speculative > execution. I gave a very simple example, which could be done solely by > preexecuting address calculation instructions but, in general, that is > not the case. I am pretty sure that none of the processors you mention > do any significant amount of speculative execution. I think what goes on inside processors such as PentiumPro / Pentium-II as well as PowerPC-604 (and several others, Alpha included? dunno) very much qualifies as "speculative execution", perhaps it would help if you shared your definitions of "speculative" and "significant". The fact that these processors employ register renaming and are able to generate results speculatively and later choose whether or not to make those results part of the visible state certainly sounds like "speculative execution" to me. Rob Barris Quicksilver Software Inc. rbarris@quicksilver.com * Opinions expressed not necessarily those of my employer * ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Rob Barris @ 1997-10-03 4:00 ` Andrew Glew 1997-10-05 4:00 ` Gianni Mariani 1997-10-04 4:00 ` Nick Maclaren 1 sibling, 1 reply; 48+ messages in thread From: Andrew Glew @ 1997-10-03 4:00 UTC (permalink / raw) Y'all may be in a terminology battle: Current usage: Speculative execution = executing instructions before you know for certain that you need to execute them, usually as a result of branch prediction (but also assuming cache hit, no fault, etc., etc.) Usually speculative execution implies only one predicted path. Eager execution = executing both sides of some flakey branches. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Andrew Glew @ 1997-10-05 4:00 ` Gianni Mariani 0 siblings, 0 replies; 48+ messages in thread From: Gianni Mariani @ 1997-10-05 4:00 UTC (permalink / raw) Andrew Glew wrote: > > Y'all may be in a terminology battle: > > Current usage: > > Speculative execution = executing instructions before you know for certain that > you need to execute them, usually as a result of branch prediction (but also > assuming cache hit, no fault, etc., etc.) Usually speculative execution implies > only one predicted path. > > Eager execution = executing both sides of some flakey branches. By this definition the MIPS R10K and the HP PA8XXX do speculative execution. To some extent however, the MIPS compilers will emit "eager" code in the sense that in some cases, both sides of an if () statement are computed if scheduling of instructions that way are an advantage. -- _ ` _ ` Webtv Service Globalization / \ / / \ /-- /-- / / // / / / / / / / We mean to be understood \_/ \ \_ \/ /_/ /_/ o / / \_/ (415) 614 6043 Opinions mine etc ... ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-03 4:00 ` Rob Barris 1997-10-03 4:00 ` Andrew Glew @ 1997-10-04 4:00 ` Nick Maclaren 1997-10-04 4:00 ` H. Eckert 1997-10-05 4:00 ` Andy "Krazy" Glew 1 sibling, 2 replies; 48+ messages in thread From: Nick Maclaren @ 1997-10-04 4:00 UTC (permalink / raw) In article <rbarris-ya023280000310971555540001@206.82.216.1>, Rob Barris <rbarris@quicksilver.com> wrote: > > I think what goes on inside processors such as PentiumPro / Pentium-II >as well as PowerPC-604 (and several others, Alpha included? dunno) very >much qualifies as "speculative execution", perhaps it would help if you >shared your definitions of "speculative" and "significant". Yes, I think that Andrew Glew and you are right, and there is considerable terminological confusion. A paragraph that I left out of my previous posting said that there was no clear boundary between simple operand pre-loading and speculative/eager/etc/ execution in their fullest sense. However, I was referring to actions like the following: Preloading operands based on, address calculations based on, both paths of a conditional branch based on, some tests based on, preloaded operands based on, address calculations based on, both paths of a conditional branch based on, a test that has not yet been evaluated. I am, unfortunately, not joking when I say that there are critical paths in the X Windowing System etc. that need that sort of optimisation for efficiency. And remember that the address calculations will, in general, need both addition and multiplication units. Most foully, the paths can run ahead at different rates, and you STILL have to get interruption and recovery right :-( Naturally, I could be wrong, but I understood the Pentium XXX designs to include only very limited speculative execution facilities. If I am wrong, I am pretty certain of the following: 1) Interrupt handling has been broken again (though this is getting be an Intel tradition, and they have got it codified in standards). 2) EITHER Intel have reinvented the "Model 91 pipe-line drain" instruction under another name OR I could write a valid C program that would execute incorrectly. My point about languages is that it becomes possible to implement reliable speculative execution relatively easily, IF you can assume that certain constraints are met. In particular, you know that the operands may be invalid, but they will not change between the preloading and the final use. And that is PRECISELY what you do not get with C or any of its derivatives. 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-04 4:00 ` Nick Maclaren @ 1997-10-04 4:00 ` H. Eckert 1997-10-05 4:00 ` Andy "Krazy" Glew 1 sibling, 0 replies; 48+ messages in thread From: H. Eckert @ 1997-10-04 4:00 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2366 bytes --] nmm1@cus.cam.ac.uk (Nick Maclaren): > I am, unfortunately, not joking when I say that there are critical paths > in the X Windowing System etc. that need that sort of optimisation for > efficiency. If you define "efficiency" as getting the maximum possible data throughput from a given machine, you're probably right since a general purpose machine cannot suit every task equally well. But what does "efficiency" mean to a GUI ? It is certainly nice to have a machine that does every graphics operation faster than you can visibly follow but that alone doesn't help a lot... > Most foully, the paths can run ahead at different rates, and you > STILL have to get interruption and recovery right :-( So you need some synchronisation points where you lose some possible CPU cycles in NOPs. Some friction is always present; the task for optimization is to reduce them as much as possible... > 2) EITHER Intel have reinvented the "Model 91 pipe-line drain" > instruction under another name OR I could write a valid C program that > would execute incorrectly. Do you care to elaborate ? IMHO this would be a sign for a broken compile which produces incorrect code. > My point about languages is that it becomes possible to implement reliable > speculative execution relatively easily, IF you can assume that certain > constraints are met. In particular, you know that the operands may be > invalid, but they will not change between the preloading and the final use. > And that is PRECISELY what you do not get with C or any of its derivatives. Ok, so you want to have a language where you can put additional optimization hints into the code. This is fine but pretty useless unless the programmer knows a lot more about performance implications of certain high-level instructions. This is the school of "you need to know how the computer works from inside to produce good code" to which I agree to some extent. This is why assembly language is still a part in a university computer science degree. Greetings, Ripley -- Ach komm, ich denke schon, da� die Raver sehr tolerant sind. Gerade bei dieser Love Parade. Du mu�t dir nur mal ansehen, wer da sein wird: Westbam, Marusha, Bl�mchen, ein Wagen vom Marienhof ... Also, das w�rde meine Toleranzgrenze weit �berschreiten. (M. Friese in bln.termine, <5pq8le$g1s$1@news.cs.tu-berlin.de>) ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-04 4:00 ` Nick Maclaren 1997-10-04 4:00 ` H. Eckert @ 1997-10-05 4:00 ` Andy "Krazy" Glew 1997-10-06 4:00 ` Nick Maclaren 1 sibling, 1 reply; 48+ messages in thread From: Andy "Krazy" Glew @ 1997-10-05 4:00 UTC (permalink / raw) To: Nick Maclaren > I am, unfortunately, not joking when I say that there are critical paths > in the X Windowing System etc. that need that sort of optimisation for > efficiency. And remember that the address calculations will, in general, > need both addition and multiplication units. Most foully, the paths can > run ahead at different rates, and you STILL have to get interruption > and recovery right :-( Actually, precise interrupts seem to be a solved problem. There is some residual advantage to imprecise interrupts and exceptions, as in Alpha, but it mainly relates to buffer sizes. Further applications of the exception hierarchy (see the earlier thread on out-of-order retirement) narrow it further, and, in fact, seem to surpass exposed imprecise interrupts. > Naturally, I could be wrong, but I understood the Pentium XXX designs to > include only very limited speculative execution facilities. If I am > wrong, I am pretty certain of the following: Depends on what you mean by limited: The Pentium Pro and Pentium II have a ReOrder Buffer of 40 instructions, a load buffer of 16 (?), and a store buffer of 12. The reservation station size is 20. Thus, 20 instructions can be waiting to execute at any time. At least an additional 20 may have executed, and be waiting for the oldest to execute. In addition, there are many more pipestages of instructions in the process of being fetched. There is no limit on how many predicted branches may be speculated past. I.e. every entry in the reorder buffer, and all the instructions in earlier pipestages, may be correctly predicted branches. Cache misses can be performed speculatively: L1 I and D, L2. TLB misses can be performed speculatively. Stores are not performed speculatively. Nor are accesses to memory mapped I/O and ordinary I/O spaces. Is this "significant" speculative execution? I think that it is under any reasonable definition of significant. It is not, of course, eager execution. What's left is increasing the size of buffers, and tuning the algorithms to be more efficient of resources. The only significant restrictions on speculative execution are (1) I/O not being done speculatively - which, by the way, I think can now be done away with. (2) The single Instruction Pointer (Program Counter) for instruction fetch. and maybe (3) The Pentium Pro family's mispredicted branch recovery is not so efficient. If code is divided into segments between mispredicted branches, P6 can only have one such segment under execution at any time (mo9dulo a limited amount of overlap). This wasn't a limitation in our pipeline because the latencies worked out right, and it should be obvious how it can be fixed. > 1) Interrupt handling has been broken again (though this is getting > be an Intel tradition, and they have got it codified in standards). Depends. The APIC did break some interrupt code, but this was an APIC(Advanced Programmable Interrupt Controller) issue, introduced in the i486 generation and standardized in the Pentium (P54C) generation. Not an issue with the dynamic execution model of the P6 (out-of-order, speculative). > 2) EITHER Intel have reinvented the "Model 91 pipe-line drain" > instruction under another name OR I could write a valid C program that > would execute incorrectly. Nope. "Serializing instructions" do exist. But almost nobody uses them. I don't think that you can write a valid uniprocessor C program that will break. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-05 4:00 ` Andy "Krazy" Glew @ 1997-10-06 4:00 ` Nick Maclaren 0 siblings, 0 replies; 48+ messages in thread From: Nick Maclaren @ 1997-10-06 4:00 UTC (permalink / raw) In article <3437F16A.C21B0159@cs.wisc.edu>, "Andy \"Krazy\" Glew" <glew@cs.wisc.edu> writes: |> |> The Pentium Pro and Pentium II have a ReOrder Buffer of 40 instructions, a load |> buffer of 16 (?), and a store buffer of 12. The reservation station size is 20. |> |> There is no limit on how many predicted branches may be speculated past. I.e. |> every entry in the reorder buffer, and all the instructions in earlier |> pipestages, may be correctly predicted branches. |> |> Is this "significant" speculative execution? I think that it is under any |> reasonable definition of significant. It is not, of course, eager execution. |> What's left is increasing the size of buffers, and tuning the algorithms to be |> more efficient of resources. The traditional meaning of "speculative" included what people have now separated off as "eager" (assuming that usage is now standard), and is what I was referring to. In the cases that I was referring to, it is essential to execute ahead of BOTH branches, and I was therefore referring to what you call "eager execution". I made this quite clear in the example immediately preceding the first paragraph you quoted. The reason is that the same code is used for two objects, which are likely to need different branch predictions. To get this "right" for single-path speculative execution, you need to do branch prediction on the basis of the DATA location as well as the CODE location. To sidetrack a little, ripley@nostromo.in-berlin.de (H. Eckert) writes: |> If you define "efficiency" as getting the maximum possible data |> throughput from a given machine, you're probably right since a general |> purpose machine cannot suit every task equally well. But what does |> "efficiency" mean to a GUI ? It is certainly nice to have a machine |> that does every graphics operation faster than you can visibly follow |> but that alone doesn't help a lot... Unfortunately, most GUIs (and definitely including anything based on X) make timing assumptions about the responses. There are a very large number of X applications where a 0.01 second delay will cause them to behave incorrectly - and, in fact, I am using one right now (xrn)! These may be bugs in the application, but are actually almost unfixable, as they are really due to design errors in X. I have had similar effects in OS/2, Windows 3.1 and MacOS. I have never used Microsoft's latest utterings, but have reason to believe that the same would apply. |> Is this "significant" speculative execution? I think that it is under any |> reasonable definition of significant. It is not, of course, eager execution. |> What's left is increasing the size of buffers, and tuning the algorithms to be |> more efficient of resources. Yes, it is. But not under any reasonable definition of "speculative"! Using your terminology, consider my posting to refer to "significant eager execution". 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Michael D. Nahas 1997-10-01 4:00 ` brianh 1997-10-01 4:00 ` Stefan Monnier @ 1997-10-02 4:00 ` Eric Hildum 2 siblings, 0 replies; 48+ messages in thread From: Eric Hildum @ 1997-10-02 4:00 UTC (permalink / raw) Michael D. Nahas wrote: > > Ketil Z Malde wrote: > > So, is this a problem, and if so, how do we fix it. Yes, it is a problem, > because any > stall to the pipeline which prevents speculative execution is bad. How do > we > solve it? The first thing to do is to make programs which have this > problem part > of the SPEC Benchmarks. This will make it the focus of everyone's > attention. > The other thing that can be done is to look at Compiler optimizations - > many of > the indirect function calls can be eliminated, especially if all the source > is compiled > together. Separate compilation of object files requires general interfaces > which > prevent many optimizations. > No, it only only requires a reasonable object code format and linker. That is, it requires a link editor such as exists under VMS which is capable of selecting the branch or call instruction and addressing, not the trival symbol table lookup and drop the bytes in the slot that Unix linkers perform. -- "The idea that Bill Gates has appeared like a knight in shining armour to lead all customers out of a mire of technological chaos neatly ignores the fact that it was he who, by peddling second-rate technology, led them into it in the first place."-Douglas Adams Eric Hildum Eric.Hildum@Japan.NCR.COM ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-09-30 4:00 Final kick at the "Merced Guessing Game" Paul DeMone 1997-09-30 4:00 ` Guy Harris 1997-10-01 4:00 ` Nick Maclaren @ 1997-10-01 4:00 ` Tom Thornhill 1997-10-01 4:00 ` Paul DeMone 1997-10-01 4:00 ` Jim Hull 1997-10-01 4:00 ` Richard A. Schumacher 3 siblings, 2 replies; 48+ messages in thread From: Tom Thornhill @ 1997-10-01 4:00 UTC (permalink / raw) Paul DeMone <PaulDeMone@EasyInternet.net> wrote in article <3431A2DB.4273@EasyInternet.net>... > While reading through an old (Dec 1995) issue of Proceedings of the IEEE the > other day while waiting for an HSPICE run to finish I came across a remarkable > paper entitled "Compiler Technology for Future Microprocessors". The authors > (W. Hwu, R. Hank, D. Gallagher, S. Mahlke, D. Lavery, G. Haab, J. Gyllenhaal, > and D. August) are associated with the University of Illinois but the research > seems to have strong ties with HP. > > The primary thrust of the paper was to describe compiler algorithms and hardware > mechanisms that could be used to get around the problem of branches and false > dependencies in gathering enough instruction level parallelism for an eight issue > RISC-like machine. The paper showed how predication (kind of like condition codes > that can be used to permit conditional execute any instruction, a generalization of > what ARM does) can be used in conjunction with loop unrolling and basic block > oalesing to dramatically decrease the number of conditional branches that need to > be predicted/executed (in one example mispredicted branches using the 2-bit branch > prediction model were reduced by almost three orders of magnitude within a complex > inner loop). > > The authors give examples of how an eight issue processor with full predication > could give a remarkable improvement (1.2x to 4.5x) over an eight issue design with a > non-predicated ISA. Their description of their architecture strikes me as eerily > similar to some predictions about the Intel IA-64 Merced design so I will repeat it: > > "The processor model used for these experiments is an eight-issue extension of > the HP PA-RISC[TM] architecture. The processor may issue eight instructions > of any type each cycle except branches, which are restricted to one per cycle. > The processor has 64 integer, 64 floating-point, and 64 predicate registers." > > The design would seem to effectively avoid the complexity and cycle time impact of > the paraphenalia of aggressive out-of-order designs such as register renaming and > in-order completion unit. The paper gives brief descriptions of advanced compiler > techniques to transform around loops (essentially static compile time register re- > naming) and also discusses how to incorporate memory data dependence analysis (used > by the Multiflow Trace scheduling compiler for the TRACE series of VLIW computers) > for another significant speedup. > > HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of > weeks but if they exploit the advances described in this paper it could really be Do you have a date? > something with the potential for dramatically raising the bar of microprocessor > performance and not just typical Intel hype and FUD. Comments? > > > All opinions strictly my own. > > -- > Paul W. DeMone The 801 experiment SPARCed an ARMs race > Kanata, Ontario to put more PRECISION and POWER into > demone@mosaid.com architectures with MIPSed results but > PaulDeMone@EasyInternet.net ALPHA's well that ends well. > > I think you're onto something here - I would expect that if Intel introduce a new architecture they'd try to ensure that relatively simple implementations of it ( ie those without renaming and out of order execution ), outperform agressive implementaions of Alpha AXP ( 21264 ? ). This gives them something to scale towards. Also since they've waited for so long before replacing IA32, you'd expect them to come up with something other than an Alpha clone. -- Mailto: tthornhi@best.ms.philips.com-nospam ( remove the -nospam before replying ) Talkto: Tom Thornhill, Philips Medical Systems Nederland BV Tel +31 4027 64080 (Work), +31 499 338211 (Hotel - after 5pm UK time) ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Tom Thornhill @ 1997-10-01 4:00 ` Paul DeMone 1997-10-01 4:00 ` Jim Hull 1 sibling, 0 replies; 48+ messages in thread From: Paul DeMone @ 1997-10-01 4:00 UTC (permalink / raw) Tom Thornhill wrote: [snip] > > HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of > > weeks but if they exploit the advances described in this paper it could really be > > Do you have a date? Approximately 1:00 pm Tuesday Oct 14 (at the 1997 Microprocessor Forum, Fairmont Hotel in San Jose). [snip] > I think you're onto something here - I would expect that if Intel introduce > a new architecture they'd try to ensure that relatively simple implementations > of it ( ie those without renaming and out of order execution ), outperform > agressive implementaions of Alpha AXP ( 21264 ? ). This gives them something > to scale towards. > > Also since they've waited for so long before replacing IA32, you'd expect > them to come up with something other than an Alpha clone. Compiler technology and architecture seems to have advanced significantly since Alpha was designed (itself essentially a classic RISC but streamlined for superscalar and out-of-order implementations) so Intel would have to stumble badly not to be able to get some degree of advantage. > > -- > Mailto: tthornhi@best.ms.philips.com-nospam ( remove the -nospam before replying ) > Talkto: Tom Thornhill, Philips Medical Systems Nederland BV > Tel +31 4027 64080 (Work), +31 499 338211 (Hotel - after 5pm UK time) -- Paul W. DeMone The 801 experiment SPARCed an ARMs race Kanata, Ontario to put more PRECISION and POWER into demone@mosaid.com architectures with MIPSed results but PaulDeMone@EasyInternet.net ALPHA's well that ends well. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-10-01 4:00 ` Tom Thornhill 1997-10-01 4:00 ` Paul DeMone @ 1997-10-01 4:00 ` Jim Hull 1 sibling, 0 replies; 48+ messages in thread From: Jim Hull @ 1997-10-01 4:00 UTC (permalink / raw) > is Tom Thornhill > > is Paul DeMone > > HP and Intel will disclose the native Merced instruction set (IA-64) > > in a couple of weeks ... > Do you have a date? October 14, at Microprocessor Forum. For details, check: http://www.MDRonline.com/mpf -- Jim Hull "If so strong the force in Yoda is, construct a sentence with words in the proper order then why can't he?" -- Teng-Kiat Lee ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Final kick at the "Merced Guessing Game" 1997-09-30 4:00 Final kick at the "Merced Guessing Game" Paul DeMone ` (2 preceding siblings ...) 1997-10-01 4:00 ` Tom Thornhill @ 1997-10-01 4:00 ` Richard A. Schumacher 3 siblings, 0 replies; 48+ messages in thread From: Richard A. Schumacher @ 1997-10-01 4:00 UTC (permalink / raw) [...] >The authors give examples of how an eight issue processor with full predication >could give a remarkable improvement (1.2x to 4.5x) over an eight issue design with a >non-predicated ISA. Their description of their architecture strikes me as eerily >similar to some predictions about the Intel IA-64 Merced design so I will repeat it: [...] >HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of >weeks but if they exploit the advances described in this paper it could really be >something with the potential for dramatically raising the bar of microprocessor >performance and not just typical Intel hype and FUD. Comments? Yes. The label reads "Intel", but it's HP inside. -- ----------------------------------------------- I do not speak in any capacity for the Convex Division of the Hewlett Packard Company. ^ permalink raw reply [flat|nested] 48+ messages in thread
end of thread, other threads:[~1997-10-08 4:00 UTC | newest] Thread overview: 48+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1997-09-30 4:00 Final kick at the "Merced Guessing Game" Paul DeMone 1997-09-30 4:00 ` Guy Harris 1997-10-01 4:00 ` Tom Thornhill 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Paul DeMone 1997-10-01 4:00 ` J. Corbally 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Ketil Z Malde 1997-10-01 4:00 ` Michael D. Nahas 1997-10-01 4:00 ` brianh 1997-10-01 4:00 ` Stefan Monnier 1997-10-01 4:00 ` Nick Maclaren 1997-10-01 4:00 ` Allen Kim 1997-10-01 4:00 ` John Wilson 1997-10-01 4:00 ` P Murray 1997-10-01 4:00 ` Nick Maclaren 1997-10-02 4:00 ` Andrew Glew 1997-10-02 4:00 ` Vesa Karvonen 1997-10-02 4:00 ` Joseph H Allen 1997-10-02 4:00 ` Wilco Dijkstra 1997-10-03 4:00 ` Stefan Monnier 1997-10-03 4:00 ` Jason.Ozolins 1997-10-03 4:00 ` Alex Colvin 1997-10-06 4:00 ` Richard A. O'Keefe 1997-10-08 4:00 ` Zalman Stern 1997-10-03 4:00 ` Stefan Monnier 1997-10-02 4:00 ` Torben AEgidius Mogensen 1997-10-02 4:00 ` Patrick F. McGehearty 1997-10-02 4:00 ` brianh 1997-10-03 4:00 ` Virtual functions (was Re: Final kick at the "Merced Guessing Game") Steven Correll 1997-10-03 4:00 ` Final kick at the "Merced Guessing Game" Michael Williams 1997-10-02 4:00 ` Stefan Monnier 1997-10-03 4:00 ` Richard A. O'Keefe 1997-10-02 4:00 ` Jon Leech 1997-10-03 4:00 ` Mike Smith 1997-10-03 4:00 ` Nick Maclaren 1997-10-03 4:00 ` Rob Barris 1997-10-03 4:00 ` Andrew Glew 1997-10-05 4:00 ` Gianni Mariani 1997-10-04 4:00 ` Nick Maclaren 1997-10-04 4:00 ` H. Eckert 1997-10-05 4:00 ` Andy "Krazy" Glew 1997-10-06 4:00 ` Nick Maclaren 1997-10-02 4:00 ` Eric Hildum 1997-10-01 4:00 ` Tom Thornhill 1997-10-01 4:00 ` Paul DeMone 1997-10-01 4:00 ` Jim Hull 1997-10-01 4:00 ` Richard A. Schumacher
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox