Docsity

Practice Homework 3 - High Performance Computer Architecture | CS 6290, Assignments of Computer Science

Toggle sidebar
bg1
Name: GTid:
Homework 3
Prof. Loh
CS6290 - Fall 2006
Handed Out: 12 Oct 2006 (Thu)
Due: 26 Oct 2006 (Thu)
1. Instruction Scheduling
In a dynamically scheduled processor, it is possible that in a given cycle there are more in-
structions ready to execute (all dependencies satisfied) than available functional units. Some
form of arbitration algorithm is required to select which instructions to execute. A com-
mon heuristic is to simply choose the oldest instructions, however one could conceivably
implement any other algorithm as well.
In SimpleScalar, the arbitration logic is implemented in the function readyq enqueue (in
mase-exec.c). The priority for arbitration is implemented by maintaining a linked list of
ready-to-execute instructions (called the ready-queue) sorted such that the items at the head
of the list receive priority. The algorithm that they implement is: long latency operations are
given highest priority1(if it’s going to take a long time, you might as well try to get it started
as early as possible), and then for all other instructions an oldest-first approach is taken.
What they should have implemented is: give highest priority to the long-latency instructions
(and use an oldest-first approach among these instructions), and then use oldest first-among
the remaining instructions. For example, if we had the following instructions with ages in
parentheses and high-latency instructions marked in bold:
add (2), xor (5), load (4), sub (6), divide (8), mult (3), not (1), add (7)
Then, these would receive the following scheduling priority (highest priority on the left):
mult (3), load (4), divide (8), not (1), add (2), xor (5), sub (6), add (7)
(a) Modify the code such that it now implements the “correct” heuristic as described
above. Before changing anything, take a look at the mase-opts.{c,h}files to figure
out how to add new command-line parameters. In particular, add a new parameter
-sched:heuristic so that you can tell the simulator what scheduling heuristic to
make use of. If this option is unspecified or set to zero, then the simulator should use
the original “broken” heuristic. If it is set to 1, then it should use the “correct” version.
1When multiple long-latency instructions are present, the default implementation just inserts them into the linked
list in a first-come, first-insert order, which does not take instruction age into account.
1
pf3
pf4
pf5

Partial preview of the text

Download Practice Homework 3 - High Performance Computer Architecture | CS 6290 and more Assignments Computer Science in PDF only on Docsity!

Name: GTid:

Homework 3

Prof. Loh

CS6290 - Fall 2006

Handed Out: 12 Oct 2006 (Thu)

Due: 26 Oct 2006 (Thu)

  1. Instruction Scheduling In a dynamically scheduled processor, it is possible that in a given cycle there are more in- structions ready to execute (all dependencies satisfied) than available functional units. Some form of arbitration algorithm is required to select which instructions to execute. A com- mon heuristic is to simply choose the oldest instructions, however one could conceivably implement any other algorithm as well. In SimpleScalar, the arbitration logic is implemented in the function readyq enqueue (in mase-exec.c). The priority for arbitration is implemented by maintaining a linked list of ready-to-execute instructions (called the ready-queue) sorted such that the items at the head of the list receive priority. The algorithm that they implement is: long latency operations are given highest priority^1 (if it’s going to take a long time, you might as well try to get it started as early as possible), and then for all other instructions an oldest-first approach is taken. What they should have implemented is: give highest priority to the long-latency instructions ( and use an oldest-first approach among these instructions ), and then use oldest first-among the remaining instructions. For example, if we had the following instructions with ages in parentheses and high-latency instructions marked in bold:

add (2), xor (5), load (4), sub (6), divide (8), mult (3), not (1), add (7)

Then, these would receive the following scheduling priority (highest priority on the left):

mult (3), load (4), divide (8), not (1), add (2), xor (5), sub (6), add (7)

(a) Modify the code such that it now implements the “correct” heuristic as described above. Before changing anything, take a look at the mase-opts.{c,h} files to figure out how to add new command-line parameters. In particular, add a new parameter -sched:heuristic so that you can tell the simulator what scheduling heuristic to make use of. If this option is unspecified or set to zero, then the simulator should use the original “broken” heuristic. If it is set to 1, then it should use the “correct” version. (^1) When multiple long-latency instructions are present, the default implementation just inserts them into the linked list in a first-come, first-insert order, which does not take instruction age into account.

(b) What would happen if the processor used a random selection heuristic? Find out by im- plementing this in the simulator (the simulator should use this when the sched:heuristic option is set to 2). This heuristic should not consider the latency of the instruction as was done in the previous heuristics. Implement the randomness by performing random insertions of instructions into the ready list. In particular, walk the list once to find out the length of the list (or otherwise keep track of this information). If the list has N items, then insert the new item at any of the N + 1 possible locations with equal probability (there are N − 1 location in between any two adjacent items, and then 2 more possible insertion points for the front and end of the list). (c) Turn in a printout of your version of only the readyq enqueue function.

Run the simulator for the three traces that we’ve been using for the original, your “correct” version, and your randomized scheduling heuristics. In particular, use the config files hw3- narrow.cfg (a 2-issue OOO processor) and hw3-wide.cfg (an 8-issue CPU).

(d) What are the IPC rates of each application and the harmonic mean IPC on each of the CPU configurations? (e) Why is there so little IPC difference between the arbitration policies for the wide- processor configuration?

  1. Correlating Branch Predictors Consider the following code segment within a loop body:

if (x is prime) then ← (branch b1) increment a ← (b1 not taken) if (x is odd) then ← (branch b2) increment b ← (b2 not taken)

Assume that the following list of nine values of x is to be processed by nine iterations of the loop

Note: Assume that predictor entries (counters) are updated by each dynamic branch before the next dynamic branch accesses the predictor (strict alternation between lookup and up- date). Assume a global-history correlating branch prediction scheme is used, and assume the coun- ters are 1-bit wide (simply remembers last outcome with no hysteresis). In addition to the 1-bit counters, a 1-bit global register (g) is stored to store the direction of the last branch executed (which may not be the same branch as the branch currently being predicted). The predictor would look like:

-bpred 2lev -bpred:2lev L1size L2size histsize xor ctrsize

The ctrsize variable should be able to take a value of 1 or 2. If ctrsize=2, then use the default 2-bit counter implementation (already in the code). If ctrsize=1, make the predictor only use a 1-bit counter. Except for the command-line options changes (mase-opts.{c,h}), you should only have to modify bpred.h and bpred.c. Report the branch prediction rates and the IPC performance using hw3-wide.cfg for:

(a) -bpred 2lev -bpred:2lev 1 1024 8 1 2 // 8-bit global history, 1K 2-bit counters (b) -bpred 2lev -bpred:2lev 1 2048 8 1 1 // 2K 1-bit counters → same # of bits (c) Explain why the results are similar/different.

  1. Branch Target Prediction The branch target buffer is a simple table that remembers “When we last saw branch X, its taken target was address Y.” For most branches, this simple mapping is sufficient for providing high target prediction rates because most branches have PC-relative targets, and the displacement is hard-coded into the instruction as an immediate field. So except in the case of self-modifying code, the taken-targets for these branches never change. However, with the popularity of object-oriented class-based programming, more and more functions are implemented with indirect jumps where the target of the jump is a computed value (target address is stored in a register, as opposed to being encoded directly in the instruction). The Intel Pentium M includes a global branch history-indexed branch target buffer for predicting these indirect jumps. Consider the following code take from the video game Haylo , which goes through three branches, which at the end the pointer enemy points to one of three enemy-subclasses. The call to the method pick target involves an indirect jump because the jump’s target must be loaded from the enemy class’ vtable.

if (level1) then ← (branch b1) { ← (b1 not taken) if (cond1) then ← (branch b2-a) enemy = new grunt( ); ← (b2-a not taken) if (cond2) then ← (branch b3-a) enemy = new jackal( ); ← (b3-a not taken) } else ← (b1 taken) { if (cond1) then ← (branch b2-b) enemy = new grunt( ); ← (b2-b not taken) if (cond2) then ← (branch b3-b) enemy = new elite( ); ← (b3-b not taken) } target = enemy→pick target(environment); Indirect jump (computed target)

Assume the following locations for the implementations of the pick target() methods:

grunt→pick target( ) → 0x jackal→pick target( ) → 0x811c elite→pick target( ) → 0x

Using a global history length of 3, fill in the entries of the following global history-indexed branch target buffer such that we will be able to make 100% accurate target predictions for the indirect jump. Assume that only the indirect jump makes use of this table; do not worry about the target predictions for b1-b3 (in a real processor, those targets would be handled by the “plain” branch target predictor).

last three enemy→pick target( )’s predicted branch outcomes target address 000 001 010 011 100 101 110 111

Extra Credit Branch Predictor Competition Assuming a total hardware budget of 2KB (16384 bits), implement a branch predictor to maximize processor performance (which not necessarily the same as maximizing the branch prediction rate, although they are usually highly correlated) using hw3-wide.cfg. Processor performance will be measured by the harmonic mean IPC across the course benchmarks. You must justify why your predictor actually fits within the 2KB budget. For example, a table of 8192 2-bit counters would eat up the entire 16384-bit budget. Assume “logic” (adders, FSM update circuitry, etc.) is free. Note that using something like a float would actually cost you 32 bits per float (or 64 bits for a double), and so it’s likely that you’ll want to stick with narrow-width integer counters. The top 5 performing entries will receive extra credit in the amount of:

1st place: +5 points on your final grade 2nd place: +4 points on your final grade 3rd place: +3 points on your final grade 4th place: +2 points on your final grade 5th place: +1 point on your final grade