From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <277617ec9099ebd35c7fce93ed0ec880.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199712161342.IAA26043@clove.com> Date: Tue, 16 Dec 1997 15:39:15 +0000 From: David Alan Gilbert Subject: Re: Seasons Greetings from a new platform :-) Przemek Klosowski wrote: > However, when there is a branch or a conditional operation, > i.e. instruction N+1 executes differently based on the result of > instruction N, this pipeline has to stop and wait for the result of > N. Since on average there is a branch/conditional every 10 or so > instructions, a simple pipeline might be stalled 10-20% of the time. > > Speculative execution means that the CPU executes code for either > outcome for the test, but stores the results in temporary hidden > registers, keeping track of what data comes from such speculation. > When the actual predicate becomes known, the CPU picks up the data > calculated for the correct value of the predicate, and discards the > alternative computation. No - you don't have to execute both possibilities to qualify for saying a processor does speculative execution - and I doubt that the 21264 does do both possibilities. All that speculative execution means is executing an instruction when your not sure if its going to execute or not. So consider a little loop: set x 1000 loop some-work decr x <- I mean x=x-1 if x>0 goback to loop something-else When we get to the 'if' we could stop there and wait for the decrement to finish and then go back to the loop. But thats slow. With speculative execution we make a guess; in this case 'hmm a backward branch - thats probably a loop, lets guess thats done'. So we make a note of the current state (not quite..) and start executing some-work. If the branch happened thats fine, we don't do anything else. If the branch didn't happen then we restore the state from the note we made and then carry on at something else. (The not quite is the fact that we have to include the state of the not finished stuff before the branch). Now this is fairly efficient - if we are good at guessing we rarely throw any work away - although we do need that hardware to hold the state just in case we are wrong. If we're desperate for more speed we go and execute both sides - so we always execute some-work and something-else and then choose the appropriate result. But thats hopelessly unefficent - you waste 50% of your work. OK if your desperate for all out speed - but its complex, and its a waste of 50% of your work. This is still a form of speculative execution - but its a more aggressive one. So how does the superscalar help - well say the loop bodies were REALLY simple; you could execute an instruction of one loop on one functional unit and an instruction of the next loop on another functuional unit. So we might be able to do the some-work on one functiuonal unit while doing the decr of the previous loop on another functional unit (probably while working out the branch at the same time). If the loop bodies are interdependent then you still have to wait for results - so in the example above you couldn't run two decr's in parallel because one needs the result of the other With superscalar you really need some speculative execution otherwise you wait around for branches most of the time and never actually have any instructions to feed your functional units with. If your a good guesser then you can keep two (on a good day) of your 4 functional units busy. The art is in getting the compiler to generate code which is organised so that it can keep as many functional units on the run as possible. So are there any dhrystone figures for the 21264 yet? (and I thought it was going to be clocked faster?). Dave -- ---------------------------------------------------------------------- - David Alan Gilbert - WARNING! This is a beta release .signature - - Work: dg @ cogency.co.uk - 0161-428-9444 - - Home: gro.gilbert @ treblig.org - - ---------------------------------------------------------------------- -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com