Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computer Architecture Final Project Report, Lab Reports of Computer Architecture and Organization

Final report for CSE 240A 2021 Fall

Typology: Lab Reports

2020/2021

Uploaded on 09/20/2022

hansong-zhang
hansong-zhang 🇺🇸

1 document

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download Computer Architecture Final Project Report and more Lab Reports Computer Architecture and Organization in PDF only on Docsity! CSE240A Computer Architecture Final Project Report Hansong Zhang Computer Science and Engineering Department, University of California San Diego, United States haz064@ucsd.edu Abstract - This is the report of my final project. In the final project we explored and implemented the Gshare, Tournament branch predictor and a self-designed custom branch predictor, and we tested and compared their performances with several traces. This project helped me to have a deeper understand- ing of the branch predictors in computer architecture. 1 Introduction In modern computer architecture, pipeline design is an important technique that allow different instructions to be processed at different stages of the processor, thus it can significantly increase the overall instruction throughput, because the processor can run multiple instructions at the same time. As shown in Figure 1, it is a basic five-stage pipeline, and it could simultaneously execute five different instructions. However, sometimes pipelines may not have better performance, especially when there is a conditional jump instruction, the processor has to wait for the branch outcome, and then to process the next instruction. As long as the processor cannot determine the next instruction to run, the pipeline is blocked. This kind of issue will delay the whole pipelines. In order to deal with this kind of special situation and further improve the performance of the processor, branch predictor is invented. Figure 1. Basic five-stage pipeline [1] Just like its name, the branch predictors are used to predict the branch outcome of different conditional jump instructions. With branch predictors, the processor can fetch and execute next instruction before the exact branch outcome is determined. You can imagine that if the branch predictor successfully predicts the branch outcome, the processor can immediately fetch the corresponding in- struction and execute it in the next cycle. However, on the other hand, if the branch predictor makes a wrong pre- diction, which means we fetch a wrong instruction and execute it, it will take several cycles before the processor gets the branch outcome and realizes the mistake, then it has to roll back the stages of processor, flush the wrong instruction and fetch another instruction instead. Thus, with a wrong prediction, the time penalty is quite large, and it will harm the performance of the processor. Due to the obvious advantages and disadvantages of branch predictors, people try to make more and more ac- curate branch predictors, but it is not an easy way. The most simplest branch predictor is static branch predictor [2], it makes a prediction based solely on the conditional jump instruction itself, and all predictions are made at compile time. Another more advanced implementation is called dynamic branch predictor [3], it will take run-time history of branch outcomes into consideration, everytime a branch outcomes is got, the inner states will be up- dated. One example of the dynamic branch predictor is correlated predictor, it will maintain branch outcomes in Branch History Register (BHR), and use another Branch History Table (BHT) to store the prediction for different BHR pattern. In the past few years, TAGE (TAgged GEometric length predictor) is one of the most popular branch predictors, it relies on several predictor tables indexed through indepen- dent functions of global branch or path history and branch address. And with the rise and maturity of machine learn- ing and deep learning, computer scientists try to apply this emerging technology to branch prediction. In "pa- per name", they tried to train a multi-layer neural network based on the feedback and used this model to improve the prediction. At last they increased the prediction accuracy to 97.10%. In this project, our team mainly focus on the dynamic branch predictor, we implemented two traditional dynamic branch predictors, Gshare and Tournament, then we de- signed our own custom branch predictor. We also com- pared the test result of these three branch predictors and drew a conclusion based on the observation. 2 Implementation In this section, we will explain the details about Gshare, Tournament and our custom branch predictor. 2.1 Gshare Before we talk about the Gshare branch predictor, we need to first explain what are global branch predictor and local branch predictor. Global branch predictor is a kind of correlated predic- tor, as shown in Figure 2, it will maintain a global branch history register (GBHR), and each time a branch outcome is generated by a instruction, the predictor will update its GBHR regardless of the instruction itself. Besides, the global branch predictor will also hold a global branch his- tory table (GBHT), this table takes the pattern of GBHR as an input and return the corresponding prediction. Af- ter a prediction is made, the global branch predictor will also compare the real branch outcome with its prediction, and then update GBHT accordingly. In a word, the sim- plest global branch predictor will not store any information about a local instruction, and it focuses on the global trend of all instructions. Figure 2. Global Branch Predictor And for local branch predictor, it will hold a two-level history table (Figure 3), the first one stores the history of recent branches indexed by the low address bits of branch instruction, and the second one stores the prediction in- dexed by the history pattern from first table. These two tables will be updated according to real branch outcome. We can see, comparing to global branch predictor, local branch predictor will use extra spaces and focus on the local trend of each individual instruction. Then here comes the Gshare branch predictor [4] (Fig- ure 6), it is a special global branch predictor. Although it hold the same GBHR as normal global branch predic- tors, when it is searching prediction in GBHT, instead of simply using the global branch history pattern, it does a XOR operation between the branch history pattern and the branch instruction address, and takes the result as Figure 3. Local Branch Predictor the index of GBHT searching. In this case, by using the XOR operation, GBHT will capture some information from the GBHT. When compared with global branch pre- dictor, Gshare usually has a better performance, cause it takes both global history and local address into consid- eration, and when compared with local branch predictor, Gshare takes less space. Figure 4. Gshare Branch Predictor 2.2 Tournament As we have mentioned, global branch predictor will focus on the global trend of all instructions, while local branch predictor will focus on local trend of each indi- vidual instruction, then why don’t we combine these two branch predictor into one and take advantages of both at the same time? Following this idea, the Tournament branch predictor was invented [5]. Figure 5. Tournament Branch Predictor In Tournament branch predictor (Figure 8), there are three major components: a local branch predictor, a global branch predictor and a choice predictor. The local branch
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved