From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199712161440.JAA29020@rrdjazz.nist.gov> Date: Tue, 16 Dec 1997 09:40:55 -0500 From: Przemek Klosowski Subject: Re: Seasons Greetings from a new platform :-) mike@clove.com asks I've heard of `speculative execution' in the stock market, but ... what is this in a microprocessor? Briefly, modern CPUs are heavily pipelined, meaning that any given moment they are handling several instructions in different stages of completion (e.g. they may be writing out results of one instruction, calculating the results of another one, fetching the operands for a third one and fetching/decoding a fourth one). This works rather well for code that simply runs through a long sequence of instructions, resulting in an average one or more machine instructions completed per clock cycle, even though the actual instruction operation is much longer. 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. This is of course only possible if the CPU does have multiple independent functional units (ALUs etc) and temporary storage; Alpha had such parallel functional units for some time now because they help even for non-speculative code. It turns out that with enough functional units and temporary result storage it pays to do this extra work even though half (or 3/4 or 7/8) of it is wasted. -- 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