The road to soft test-Xiaoqiao

Source: Internet
Author: User

The assembly line, from the perspective of the two decades of life experience in xiaobian, can be understood in this way. Starting from the factory in life, the work done by every worker on the assembly line is different, but it is connected, after the above workers finished his work, they threw it directly to the following workers, and then passed it down until the end of the assembly line. The pipeline will be eye-catching, or you will lose some of it before you finish it. Then you will be in a hurry and the whole line will be in disorder, in general, the pipeline in life is an industrial production method, that is, each production unit only focuses on processing a piece of work, in order to improve work efficiency and output. Pipeline also has a similar concept in our computer. What are the differences between the pipeline in xiaobian's understanding and the pipeline in the computer world? What is the magic of a computer pipeline? In this blog post, I will take a look at the pipeline-related knowledge. I will follow the context of the figure below and introduce it one by one. First, let's take a look at the overall framework of pipeline-related knowledge points.

Next, let's take a look at the traces along the assembly line. If you have any suggestions, you are welcome to discuss them.
Concept

A pipeline is a quasi-parallel processing technology that allows multiple commands to overlap during program execution. The simultaneous processing of various components is for different commands. They can work on different parts of multiple commands at the same time to improve the utilization rate of each component and the average execution speed of commands. There are so many concepts that we can understand in depth now. The concept of light is a few abstract things. We can see that there are three steps:

Next, let's take a look at the general situation. Our commands are handled by one piece. After the first command is processed, the second one is processed and the third one is processed, in this order, what is the use of devices on the machine? Let's look at this figure:

If the execution time of each command is 1 ms, for example:

It takes 9 ms to execute the three commands. We can also see that the value of this device only works in 1 ms, 4 ms, or 7 ms, the first command only takes 1/3 of the time to work, and other time will be idle. In this way, many devices will be idle in the middle. So we introduced the pipeline. Time used by pipeline:

If the device completes the value of the first command, it immediately enters the value of the second command. After the second command is completed, the device immediately executes the third command. This operation is the same for analysis, we can see that it was completed in 5 ms. Of course, we can also observe that the running time of a single command is 3 ms. Therefore, the execution of a single command in the pipeline is invalid. In addition to the command line, there is also an operation line. The operation line is that the computer can also use the line to increase the operation speed when performing various operations, this operation is performed in stages, so we use pipelines to increase the computing speed.

Calculation of pipeline command running time

Test Tool

Let's look at the formula for a few variables, which is hard to understand. Let's look at the example:

Example 1

A very simple question, which we can see, is easy to calculate: (2 + 2 + 1) + (100-1) * 2 = 203

Next, let's take a look at the figure for a deep understanding:

In this figure, we assume that the value is 5ns, 2ns is analyzed, and 5ns is executed. Then, we have executed the following command:

If the analysis is executed after the value is set, you only need 7ns to complete the analysis phase. Therefore, you only need 12ns instead of 15ns to complete the analysis. Why do we say that the analysis can be executed immediately after the value is set? Let's take a look at the steps:

After the value of the first command is complete, the two lines will be removed, that is, the line hindering the development of I2 and C1 will be broken, and they will be able to run:

We can clearly see that the analysis can proceed with the value of the next command. Next, let's look at a strange question:

Example 2

Based on the previous formula, we can quickly calculate the cycle = 100ns (the longest time), and then obtain the result of the first command: 60ns + 100ns + 50ns + 70ns = 280ns. Then complete the program: 280 + (20-1) * 100 = 2180. According to this formula, there is no problem at all. But let's take a look at the answer:

But what should we do if there is no such answer in our options? Think about it. We have no error. We use the formula. We certainly cannot be wrong. However, sometimes we have to change to another direction in order to score, that is, our cycle is 100ns, so we all calculate by cycle, the completion time of the First Command is 4*100 = 400, and then the completion time of the First Command is 100*4 + (20-1) * 100 = 100. Then we can get points for this question.

Small message: In this blog post, I will briefly review and summarize the knowledge points of the pipeline from three aspects. First, I will briefly introduce the concept of the pipeline, and second, the calculation of the command running time. Thirdly, the theoretical knowledge is consolidated and two examples are explained. For the first time, I was not very familiar with the assembly line. If you have any suggestions, you are welcome to discuss and exchange. The days for preparing for the soft exam are coming to an end. At the end of October, the fingertip of November is blooming, thank you for choosing the blog to accompany me through the two preparation months in 2014. The countdown to the exam will take place in Beijing. Come on!

The road to soft test-Xiaoqiao

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.