Activity 3, Investigating Hazards
Short Description:
In a group or as an individual, perform the following activities related to data hazards in a pipelined architecture.
Goals
When you finish this homework, you should have:- Developed a basic understanding of data hazards program.
- Developed an understanding of the impact on hazards on program performance.
Formal Description
For this group activity you will construct a document that explains your explorations into the impact of different aspects of data hazards. Respond to each part in your document as appropriate. I.E. if you are asked to compute/trace/comment on something, put it in your document.Please start a word document and record the following, one per group
- Record the names of all members of the group.
- Only one group member need submit this homework, but at least one must.
- Record if you employed any outside sources to solve this problem, including all AI use.
- How would a pipeline that ignores hazards "work"?
- Assume the 5 stage pipelined LEG 8 architecture from our notes.
- Assume
- x1 holds 11
- x2 holds 22
- Assume the the following code is running in a pipeline with no hazard detection/mitigation:
-
I1 Addi x1, x2, #5 I2 Addi x2, x1, #5 I3 Add x3, x1, x2 I4 Add x4, x1, x2 I5 Add x5, x1, x2
-
- In your document, create a pipeline diagram like the one in these notes, but
-
Time IF ID EX MEM WB 0 I1 1 I2 I1 3 I2 I1 ... ? I5
-
- Build a table of the values of X1 through x5 as the instruction exits the ID stage.
-
Instruction Register Values on exit from ID I1 11,22,?,?,? I2 I3 I4 I5 - ? means unknown value.
- Remember, the data is not committed to a register until the first 1/2 of WB for that instruction. The values an instruction reads in ID are the values it will use, even if another instruction subsequently changes those registers.
- Remember, the data is not read from a register until the second 1/2 of ID for that instruction.
-
- In your document indicate the final values for x1 through x5
- Do this by completing this table
-
Register Value Explanation x1 27 I1: 22 + 5 x2 I2: 11 + 5 (stale x1 holds 11) x3 x4 x5 x1
- Reflect on the value of a pipelined machine that does not have hazard detection.
- If the machine running these instructions has a clock that runs at 200ps, what is the time required to complete these instructions in the case above?
- Remember the time is more than 5 * 200, you need to empty the pipeline!
- Rewrite the above code by inserting
nopinstructions to add user supplied pipeline bubbles.- Trace your code in a pipeline diagram to show that your solution works.
- Compare your resulting register values to the register values above.
- How many
nopinstructions did you have to add? - Justify your insertions of
nopinstructions.
- Compute the time required for your modified code.
- Compute the impact of pipeline bubbles on a large program:
- I would use a spreadsheet like we did in class.
- Isolate assumptions as much as possible by putting values in a cell and referring back to these assumptions in your computations.
- This will allow you to change the assumptions and still have a valid working model.
- This is what we did as we developed the spreadsheet in class.
- Assume the following
- 25% of the R/I/CB/D-type instructions need a single NOP instructions inserted
- 15% of the R/I/CB/D-type instructions need two NOP instructions inserted
- 10% of the R/I type instructions need three NOP instructions inserted
- Thse are mutually exclusive, so 50% of the R/I-type instructions will have at least one nop instruction inserted.
- R and I-type instructions constitute 40% of the computation
- CB-type instructions constitute 25% of the computation
- D-Type instructions constitute 30% of the computation
- Other instructions make up 5% of the computation.
- Assume a program needs 1,000,000 instructions to execute.
- Compute:
- the time to run the program in a single-cycle 800 ps clock.
- the time to run the program if hazards are ignored with a 200ps clock.
- the speedup for the broken pipeline provides.
- the time to run the program if hazards are fixed by he programmer/compiler inserting
nopinstructions using a 200ps clock. - the slowdown (opposite of speedup) for fixing the pipeline
- I would use a spreadsheet like we did in class.
- Assume data forwarding fixes all but 10% of the R/I-type instructions, and that only costs one
nop.- Compute the time and speedup in this case.
- Summarize your discoveries about the impact of hazards and data forwarding on pipelined program performance.
Notes
This is based on a number of exercises from the end of chapter 4 in your book.I used ChatGPT to fine tune this. It had some really good suggestions and said that this was a "solid" activity.