dendibakh / perf-book

The book "Performance Analysis and Tuning on Modern CPU"
https://book.easyperf.net/perf_book
Creative Commons Zero v1.0 Universal
2k stars 144 forks source link

Time per instruction on pipelined machine #10

Closed ming535 closed 10 months ago

ming535 commented 2 years ago

Hi, I was confused by this formula on page 31: "Time per instruction on pipelined machine = Time per instruction on non-pipelined machine / Number of pipe stage"

My understanding is that the time per instruction is the same on pipelined machine or non-pipelined machine, since pipeline only improves the throughput but not the latency. If the "Time per instruction on pipelined machine" is decreased compared to non-pipeline machine, the only reason is that the frequency increases. Is there any misunderstanding here?

dendibakh commented 2 years ago

No, I think your understanding is correct. Pipelining helps improve the throughput, while the latency of a single instruction doesn't change. So it won't help when you have a dependency chain but will help if there is instruction-level parallelism.