Pipeline-Pipeline related calculations

Pipeline-pipeline calculation

The production of a car by a car factory is divided into four processes: ABCD. Car No. 1 starts production, process A ends, process B enters process, then process C, then D, finally completed, car No. 2 starts production, ibid., After the end of the production of the No. 3 car, but the problem that follows is that when the A process is completed, the B process is carried out, and the corresponding A process staff will have a period of window period, this period of window period time It is very long, until the BCD is all over, so the boss of the factory will suffer a blood loss, and the assembly line production mode will follow.
Car No. 1 enters the process B after the A process is completed, then the second car immediately proceeds to the A process, after the first car enters the C process, the second car enters the B process, and the No. 3 car enters the A process, which will effectively avoid the staff’s empty space. Window period will improve efficiency and save costs.

  • The pipeline cycle is the longest execution time period

For example: A process needs 2 hours, B needs 1 hour, C needs 4 hours, and D needs 3 hours, so the cycle of the assembly line is 4 hours.
As for why it is 4 hours, it is actually very easy to understand. If the 4 hours is not used as the cycle, what will happen if the two hours of the A process is used as the cycle?

Think about it carefully, will it cause product retention, because your C needs 4 hours, while A needs 2 hours, and B needs 1 hour, there will be a large number of products B staying between BC, waiting for C, This is only an ideal assumption, and sometimes it can cause paralysis, so the cycle of the pipeline must be the longest period of time on the execution line.

  • Calculated pipeline
    an instruction execution time + (the Number of instruction -1) * pipeline cycle
    theoretical formula: (t¹ t² + + + ... + tⁿ t³) + (. 1-X) [Delta]
    time formulas: (n + x-1) *∆
    where n is the number of processes required for a project, just like ABCD above, x is how many products need to be completed in the assembly line, just like the number of cars in the above, ∆ is the cycle of the assembly line.

If the instruction pipeline divides an instruction into three parts: evaluation, analysis, and execution, and the time of the three parts is 2ns, analysis 2ns, and execution 1ns, then what is the pipeline cycle? How long does it take to execute all 100 instructions?
Insert picture description here

显然,通过定义可以得到,该流水线周期为2ns 需要的时间通过两个公式计算可分别得到理论203,实践204,这两种都是正确答案,在做题时,可灵活选择

Everyone must be very puzzled, why there are two results, why not the most standard answer, the editor here gives you some explanations, I hope it can be understood.

Explain the two calculation methods through the above figure.
1. There are three processes in total, so the total time of the three processes is 2+2+1=5ns. After the first product is completed, does the second product enter? The last process, that is to say, add a cycle on the basis of the previous 5, it is the time when the second product is finished, and so on, is the time when the last product is finished, is it added n- on the basis of 5? 1 cycle. (Have you ever thought that the third process actually has a 1ns window period, because the cycle is 2, and the third process time is 1)
Method 2, consider the time of each process as 2ns, then the whole process is completed Isn’t time just a few processes for the first product, plus the last process for the remaining products? That is (3+n-1)*2.

  • Throughput rate calculation of the pipeline The throughput
    rate refers to the number of tasks completed by the pipeline per unit time or the number of results output. The basic formula for calculating the throughput rate of the pipeline is as follows:
    Insert picture description here
    Bringing into the above question, you can get TP=100/203
  • The speedup ratio of the pipeline To
    complete the same batch of tasks, the ratio of the time used without the pipeline to the time used by the pipeline is called the speedup ratio of the pipeline. The speedup formula for calculating the pipeline is as follows:
    Insert picture description here
    Bring the scenario of the above question into the
    execution time without pipeline (2+2+1)*100
    using pipeline time 203
    , that is, s=500/203
  • The efficiency of the
    assembly line The efficiency of the assembly line refers to the equipment utilization of the assembly line. On the space-time diagram, the efficiency of the pipeline is defined as the ratio of the space-time area occupied by n tasks to the total space-time area of ​​the k
    pipeline stages. The formula for calculating the pipeline: Insert picture description here
    Insert picture description here
    calculate the efficiency through the above figure, and the space-time area occupied by n tasks = 4* (1+1+1+3), the total space-time area of ​​k flow segments, that is, the total area of ​​all grids, which is 15*4.
    So efficiency can also be understood in this way, that is, the area of ​​the grid to do the task/total grid area.

I don’t know if you can understand the explanation of the editor. If you have any questions, you are welcome to ask questions and correct me! ! !

Guess you like

Origin blog.csdn.net/Desire_Dir_W/article/details/114446468