2
$\begingroup$

I finished watching a video about pipelining https://www.youtube.com/watch?v=eVRdfl4zxfI which I thought made sense. Latency is the amount of time it takes to complete each instruction. Even with pipelining, the time it takes to complete an instruction is still the sum of the time it takes for every stage, in this case it's 20ns.

But then I did a bit more studying and found out the latency is supposed to be time for the longest stage to finish execution + the "cost" of pipelining, rather than the sum of time it takes to execute all the stages? http://web.cs.iastate.edu/~prabhu/Tutorial/PIPELINE/perform.html

Is there something I'm missing?

$\endgroup$
0
$\begingroup$

It is possible that you did not understand the mentioned references. Let say that $T_s$ is the time that is needed for completion of each stage, and $k$ is the number of stages. $T_s$ may or may not include the cost of pipelining. The latency of the first instruction is equal to the sum of times needed for completion of each stage, i.e., $kT_s$. Once the pipeline is full, the latency of each subsequent instruction is $T_s$. Therefore, the total time needed for execution of $n$ instructions is: $kT_s$ (first instruction) $+ (n - 1) T_s$ (each subsequent instruction).

Therefore, when pipeline is full, latency of each instruction is $T_s$. Still, the time needed for completion of each instruction is $kT_s$. Please note the difference between the latency and the time needed for completion of instruction. Pipelining only reduces the latency.

$\endgroup$
1
  • $\begingroup$ Pipelining doesn't reduce the latency at all. Pipelining allows to execute parts of different instructions simultaneously and to make progress on multiple instructions at the same time. You were thinking about throughput or the inverse, clocks per instruction. $\endgroup$
    – gnasher729
    Sep 4 '20 at 14:45
0
$\begingroup$

In practice, you won't find any processor where different pipeline stages take different amounts of time - that would be a nightmare to implement. In practice, every pipeline stage takes one clock cycle.

"Latency" is the time from the start of the instruction to the point where the result can be used. For example, it takes some time from starting execution of an instruction x = y * z until an instruction a = b + x can start, because the result of the first instruction must first be available. That is not necessarily the execution time of the first instruction. There may be additional time needed to move the result of the multiplication into the register x, if the processor is clever enough in a = b + x to use the result of the multiplier as soon as it is available, instead of insisting on reading the register x.

Latency is important when you have a long sequence of instructions where each is dependent of the result of the previous one, and you don't have any other instructions that can be executed at the same time.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.