
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In the course of intro to computer architecture, the main points are:Selection Sort Algorithm, Array Numbers, Unconditional Branches, Language Statements, Ascending Order, Six-Stage Pipeline, Target Addresses, Data Hazards, Total Branch Penalty, Branch-History Table, Machinelanguage
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

SelectionSort(int length; int numbers[ ]) int firstUnsortedIndex, testIndex, smallestIndex, temp for firstUnsortedIndex = 0 to (length-2) do smallestIndex = firstUnsortedIndex
for testIndex = firstUnsortedIndex + 1 to length - 1 do if numbers[ testIndex ] < numbers[ smallestIndex ] then smallestIndex = testIndex end if end for
temp = numbers[ firstUnsortedIndex ] numbers [ firstUnsortedIndex ] = numbers [ smallestIndex ] numbers [ smallestIndex ] = temp end for end SelectionSort
a) Where in the code would unconditional branches be used and where would conditional branches be used?
b) If the compiler could predict by opcode for the conditional branches (i.e., select whether to use machine language statements like: “BRANCH_LE_PREDICT_NOT_TAKEN” or “BRANCH_LE_PREDICT_TAKEN"), then which conditional branches would be "PREDICT_NOT_TAKEN" and which would be "PREDICT_TAKEN"?
c) Assumptions: length = 100 and the numbers are initially in ascending order before the selection sort algorithm is called the six-stage pipeline of the text the outcome of conditional branches is known at the end of the EI stage target addresses of all branches is known at the end of the CO stage ignore any data hazards Under the above assumptions, answer the following questions:
i) If static predict-never-taken is used by the hardware, then what will be the total branch penalty (# cycles wasted) for the algorithm? (Here assume NO branch-history table) For partial credit, explain your answer.
ii) If a branch-history table with one history bit per entry is used, then what will be the total branch penalty (# cycles wasted) for the algorithm? (Assume predict-not taken is used if there is no match in the branch-history table) For partial credit, explain your answer.
iii) If a branch-history table with two history bits per entry is used as in Figure 11.16, then what will be the total branch penalty (# cycles wasted) for the algorithm? (Assume predict-not taken is used if there is no match in the branch-history table) For partial credit, explain your answer.