Exercise 2 - Counting cycles correctly

Objectives

Attention: This exercise, like all others, is individual. This means that you cannot, under any circumstances, look at the code of one of your colleagues. You can take questions away from the computer or ask the teacher for help.

Before you start

You should remember the concepts related to performance measures. Try to think of answers to the following questions (you do not need to include them in your report):

It is important that you know how to answer these questions before continuing the activity.

Activity

In this activity you must use the same programs as 1 Exercise. But I recommend that you first do an evaluation on "Hello World" for its size and ease of debugging. Subsequently run your code with the 3 largest programs.

Pre-activity

Just as there are behaviors ac_behavior (begin) e ac_behavior (end) of the simulator, each instruction has its own behavior. The instruction addu has the behavior declared in ac_behavior (addu). However, a single behavior per instruction makes the code quite repetitive, so each instruction executes 3 behaviors in sequence. For instruction addu we will have the general behavior: ac_behavior (instruction), executed for all instructions, the behavior of the instruction format: ac_behavior (Type_R), executed for all type R instructions, and the specific behaviorac_behavior (addu). Note that the PC increment (ac_pc) is done only in general behavior and all instructions take advantage of this operation.

Its pre-activity is to count how many instructions of each format are executed by your program. Include this in a table in your report (you will have more data for this table in the following steps).

Computing the overhead of running a program

Your simulator already performs the correct execution of the program. So all the hazards were resolved correctly. It does this considering that one instruction executes at a time, which makes the simulation much easier, however it is not able to compute the correct execution time of the program because it does not calculate the effects between the instructions nor even the time that each one spends individually. . You must assess the impacts, as you did for the average CPI, in each of the program instructions. Only now, some instructions will impact the code differently depending on your behavior (a jump taken or not taken) and also the instructions around you (a data or control hazard).

The recommended methodology remains similar to the previous exercise, only now you need to create more groups of instructions to add their correct impact on the execution time of your program.

Start by considering the average CPI per instruction group of the 1 Exercise. The next step is to consider the effects of hazards and, later, the prediction of jumps. In your report, you should generate columns with run times in cycles and the average CPI for each setting. For each activity to follow, you must include new columns indicating the new results, so you maintain only one table of results. Start by including the columns: original (considering CPI = 1 for all instructions) and variable CPI table in Exercise 1 (this is the same result as in Exercise 1).

Data Hazard

What data hazards can happen in the MIPS 5-stage pipeline? Which of them can be solved through forwarding and which cannot? Modify the simulator to count the data hazards and classify them in these two categories: those that are resolved by forwarding and those that are not. Those that are not resolved by forwarding will have a performance impact. How many extra cycles will it take to run them?

Once you have detected the sequences of instructions that need to be monitored, you also need to assess the delay that these sequences cause in the execution of the program and capture the number of times that the simulator has executed these sequences. You will probably want to change the behaviors of the formats to capture this information in a generic way.

Hazard control and deviation prediction

This part was moved to Exercise 3. You do not need to do anything related to the control hazard in this exercise.

Delivery

Everyone must submit a 1 page report, in PDF format, through the Susy. Keep the source code until the end of the semester.

In your report, include a table with at least the following columns: