1) The following shows two threads, Thread A and Thread B, to be run on supersca
ID: 3911110 • Letter: 1
Question
1) The following shows two threads, Thread A and Thread B, to be run on superscalar machine with 2 slots. Assume that before the code is run a, b, x and y are 0. Show how each would execute on Fine-Grained Multithreading. What are values of a, b, x and y at the end of Fine MT completion? Time Thread A Al A2 A3 A4 A5 A6 A7 Thread B Bl B2 B3 B4 4 Al: x-y+5 A2: a-b+7 ??: ? ?? BI : a-y+3 B2: x-at y AT b = y+b 2) Now thread A and thread B are run on 2 separate cores of a processor. What are the possible values of a, b, x, and y? Core 1: Thread A Core 2: Thread BExplanation / Answer
1. In every cycle, a different thread is executed in fine-grained multithreading.
There are two issue slots
Cycle 1: Thread A is executed utilizing both the slots
x = y + 5 => x = 5
a = b + 7 => a = 7
Cycle 2: Thread B is executed. Since it is having only one instruction to be executed, the second slot will be wasted.
a = y + 3 => a = 3
Cycle 3: Thread A is executed. Since it is having only one instruction to be executed, the second slot will be wasted.
y = x*a => y = 15
Cycle 4: Thread B is executed. Since it is having only one instruction to be executed, the second slot will be wasted.
x = y + a => x = 18
Cycle 5: Thread A is executed. Since it is having only one instruction to be executed, the second slot will be wasted.
a = x+ y => a = 33
Cycle 6: Thread B is executed utilizing both the slots
x = b + 7 => x = 7
y = a + 7 => y = 40
Cycle 7: Thread A is executed utilizing both the slots
x + = 5 => x = 12
a = y + 7 => a = 47
Cycle 8: As there is no instruction to be executed by thread B, the control stays with Thread A and the last instruction is executed.
b = y + b => b = 40
Final values
x = 12
y = 40
a = 47
b = 40
----------------------------------------------------------------------------------------------------------------------------------------------------
2. Thread A and Thread B are running on 2 separate cores of a processor. This means two threads are running concurrently.Two separate cores have two separate cache memory. So they maintain values of a, b, x and y individually.
Thread A
x = y + 5 => x = 5
a = b + 7 => a = 7
y = x*a => y = 35
a = x+ y => a = 40
x + = 5 => x = 10
a = y + 7 => a = 42
b = y + b => b = 35
Final values seen by core 1
x = 10
y = 35
a = 42
b = 35
Thread B
a = y + 3 => a = 3
x = y + a => x = 3
x = b + 7 => x = 7
y = a + 7 => y = 10
Final values seen by core 2
x = 7
y = 10
a = 3
b = 0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.