Upload
hoangdiep
View
271
Download
5
Embed Size (px)
Citation preview
EdyWin 1
Pipelining
EdyWin 2
Pipelining adalah teknik pemrosesan dengan mengoverlapkan eksekusibeberapa sub-proses.
Tenik pemrosesan : (a) Sekuensial, (b) Paralel (c) PipelineContoh : Proses pencucian baju.
Ani, Budi, Cindy dan Dani masing masing mempunyai sekeranjangbaju kotor yang harus dicuci, dikeringkan dan kemudian disetrika.
A B C DPekerjaan :
Sub-pekerjaan 1
Sub-pekerjaan 2
Sub-pekerjaan 3
4 cucian
Pencucian ( 40 menit)
Pengeringan ( 30 menit)
Penyetrikaan ( 20 menit )
Waktutotal :
90 menit
EdyWin 3
Laundry sekuensial untuk 4 cucian.
Proses laundry 4 cucian secara sekuensial membutuhkan1 mesin cuci, 1 pengering dan 1 tukang-setrika , waktu total = 4x90 menit
A
B
C
D
40 30 20 40 30 20 40 30 20 40 30 20urutan
cucian
waktu
menit
t
90 menit 90 menit 90 menit 90 menit
1 1 1
1 1 1
1 1 1
1 1 1
EdyWin 4
Laundry Paralel untuk 4 cucian
Proses laundry 4 cucian secara paralel
membutuhkan :4 mesin cuci, 4 pengering dan4 orang penyetrika,
waktu total = 90 menit
A
B
C
D
40 30 20
waktu
menit
90 menit
t
1 1 1
2 2 2
3 3 3
4 4 4
EdyWin 5
Laundry Pipeline untuk 4 cucian
Proses laundry secara pipeline
membutuhkan1 mesin cuci, 1 pengering ,1 orang penyetrika
waktu total = 6 x 40 menit= 240 menit
A
B
C
D
40 40 40 40 40 40 40 4040
urutan
cucian
waktu
menit
t
= 40 menit
Tp = 1 Pipeline Cycle= Max { 40 , 30 , 20 }
1 1 1
1 1 1
1 1 1
1 11
TpTpTpTpTpTp
EdyWin 6
Pekerjaan berikutnya baru bisa dimulai setelah peker-jaan sebelumnya diselesaikan.
1 pekerjaan (A)
Dengan mengoverlapkan sub-pekerjaan , pekerjaan berikut-nya bisa dimulai tanpa menunggu selesainya pekerjaansebelumnya
Sekuensial :
Pipelined :
1 pekerjaan (B)
1 pekerjaan (C)1 pekerjaan (D)
Pipelining meningkatkan throughputpekerjaan
A B CA B C
A B CA B C
1234
t
2 pekerjaan diselesaikan
3 pekerjaan diselesaikan
EdyWin 7
Untuk pemrosesan secara pipeline,
Pecah setiap pekerjaan menjadi K sub-pekerjaan.
Pipelined :
subpekerjaan K
waktu
subpekerjaan 1
subpekerjaan 2
subpekerjaan 3
Bila k adalah tunda eksekusi sub-pekerjaan k ,maka pipeline-cycle
Tp = max , ... ,
EdyWin 8
Gantt Chart
21
I1 I2 I3 I4 I5 In-1 Intime
space(= sub proses )
( Pipeline 2-ruas ) , Gantt Chartnya adalah sebagai berikut :
Gantt Chart adalah diagram ruang-waktu yang digunakan untukmenggambarkan aktifitas proses pipelining.
Contoh 1 :Untuk sebuah proses yang dapat didekomposisi menjadi 2 sub-proses
O1 O2 O3 O4 O5 On
Oi : output pekerjaan i
Ii : input pekerjaan i
EdyWin 9
Pipeline 4-ruas, K = 4Contoh 2 :
In
1
2
3
4
n output
n.T(k-1)T
latency
0output
Pada daerah latency , pipeline belum menghasilkan output
T
EdyWin 10
1234
n.T(k-1)T
Pipeline 4-ruas
1234
Non-Pipeline
Berapakah jumlah pekerjaan yang dapat diselesaikan oleh(a) proses pipeline (b) proses non-pipeline ???
Berapakah peningkatan throughput oleh proses pipeline ????
o1 on
EdyWin 11
Peningkatan throughput (jumlah pekerjaan yang dapat diselesaikan persatuan waktu) dengan pipeline k-ruas :
Untuk eksekusi n buah pekerjaan,
Non-pipeline : Waktu eksekusi = n . k .T (1)
Pipeline : Waktu eksekusi = n.T + (k-1) . T (2)
latency
Peningkatan throughput =
=
(1)
(2)
n.k
k + (n-1)~~ k utk n >> 1
ideal
EdyWin 12
Peningkatan throughput eksekusi instruksidengan pendekatan pipeline
INSTRUCTION PIPELINE
Peningkatan throughputdengan pipeline
EdyWin 13
INSTRUCTION PIPELINE
Arsitektur pipeline untuk pekerjaan eksekusi instruksi
eksekusi instruksi I1
eksekusi instruksi I2
eksekusi instruksi I3
eksekusi instruksi I4
Sub pekerjaan
Eksekusi sebuah instruksi disebut1 instruction-cycle.
1 instruction cycle mempunyai polaberaturan (sama untuk semua instruksi)
t
EdyWin 14
1 Instruction Cycle = 1 set sub-cycle
InstructionFetch
InstructionDecode
OperandFetch
Execute
ResultStore
NextInstruction
1
2
3
4
5
6
sub-cycle 1; waktu yg dibutuhkan : 1
sub-cycle 2; waktu yg dibutuhkan : 2
sub-cycle 3; waktu yg dibutuhkan : 3
sub-cycle 4; waktu yg dibutuhkan : 4
sub-cycle 5; waktu yg dibutuhkan : 5
sub-cycle 6; waktu yg dibutuhkan : 6
= sub proses
EdyWin 15
Pipeline Cycle = ?
Tp = Max { i } , untuk i = 1, ... ,6
1 = 20 ndet
2 = 3 ndet
3 = 20 ndet
4 = 5 ndet
5 = 20 ndet
1 = 3 ndet
Misal :
maka,
Tp = 20 detik
Dengan struktur pipeline, i harus diseragamkan
EdyWin 16
InstructionFetch
InstructionDecode
OperandFetch
Execute
ResultStore
NextInstruction
InstructionFetch
InstructionDecode
OperandFetch
Execute
ResultStore
NextInstruction
T=20 ndet T = Max{23,25,23} = 25 ndet
20 20
3 20
5 20
20 20
20 20
3 20
idle
diatasi denganPengelompokan sub-cycle
23 25
25 25
23 25
masalah !
EdyWin 17
Instruction Pipeline 5-ruas
IF : Baca satu instruksi dari memory (Instruction Fetch)
ID/OF : Instruksi di interpretasikan (Instruction Decode) danOperand dibaca dari register atau dari memory (Operand Fetch)
EX : Laksanakan perintah yang dimaksud oleh instruksi (Execution)
STO : Simpan hasil eksekusi ke memory (MEM : Memory))atau
Simpan hasil eksekusi ke register (WB: Write Back)
IF ID/OF EX MEM WB
STO
EdyWin 18
IFinstruction
fetch
ID/OFinstruction decode/
operand fetch
MEMmemoryaccess
EXexecute/
address calculation
WBwriteback
PC
Instr.Mem.
Reg.Array
regA
regB
regWdatW
datA
datB
ALU
18:14
4:0
DataMem.
datIn
addrdatOut
aluA
aluB
IncrPC
Instr
29:25
Wdata
Wdest
Xtnd12:0
nPC
Xtnd << 221:0
Hardware untuk pipeline
STO
EdyWin 19
reg[R1] reg[R1] op reg[R2]
Eksekusi instruksi RR (operand operandnya terletak dalam register)
• IF: Instruction fetchIR Memory[PC]PC increment [PC] (alamat instruksi yang akan diekseku-
si pada instruction cycle berikutnya)• ID: Instruction decode/operand-fetch
A register [R1]B register [R2]
• Ex: ExecuteALUOutput A op B
• MEM: Memory (nop = no operation, tidak adanop penulisan hasil ALU ke memory)
• WB: Write backRegister[R1] ALUOutput (menuliskan hasil ALU ke register R1)
A dan B: register register pada bagianinput ALU
EdyWin 20
• IF: Instruction fetch
IR <-- IMemory[PC]
PC Incr [PC]• ID: Instruction decode/operand-fetch
A register [R1]B mem [M1]
• Ex: ExecuteALUOutput A op B
• MEM: Memory
Mem [M1] ALUOutput hasil disimpan di memory• WB: Write back
– nop no-operation, hasil tidak disimpan di register
mem[M1] r[R1] op mem[M1]
Eksekusi instruksi dengan operand sumber1 di register, operand sumber2dan operand hasil di memory
EdyWin 21
• IF: Instruction fetchIR IMemory[PC]PC incr.PC
• ID: Instruction decode/operand-fetchnop tidak ada operand-fetch
• Ex: ExecuteTarget PC + displacement menghitung alamat target
(= alamat instruksi berikutnya)• MEM: Memory
PC Target atau Bila syarat percabangan dipenuhi• WB: Write back
nop
Eksekusi instruksi percabangan bersyarat BRZ
displacement(relativeaddressingmode)
Branch if Zero
alamat penyimpanan instruksi berikutnya tergantungdari hasil pengujian syarat (hasil ALU = 0 ? )
syarat percabangan
EdyWin 22
Pipeline HazardsHazard adalah keadaan yang dapat menimbulkan tunda (delay, stall)pada pipeline. Pada keadaan stall, pipeline tidak menghasilkan outputsehingga peningkatan throughput ideal tidak dapat dicapai.
stallIj Ij+1
ideal
real
o1 oM
o1 oNI1
I1
IM
IN
N < M
EdyWin 23
Tiga tipe hazard :
Structural hazards:terjadi akibat konflik penggunaan hardware resources(memory, register, unit fungsional,...)
Data hazardscontoh : sebuah instruksi membutuhkan data yang belumselesai diproses oleh instruksi sebelumnya
Control hazardskeputusan kendali sebagai hasil eksekusi instruksisebelumnya belum diketahui.contoh : alamat instruksi yang harus dieksekusi berikutnya
(setelah instruksi percabangan bersyarat) belumdiketahui.
EdyWin 24
Sumber sumber hazard
: Bagian memory yang menyimpan instruksi (program)
: Bagian memory yang menyimpan data (operand)
Reg : Register register didalam CPU
AL
U
Reg/Md
RegMi Md
IF ID/OF EX MEM WBt
Structural hazards
Mi
Md
lokasi operand : di memory atau didalam register CPU
lokasi instruksi: di memory
EdyWin 25STRUCTURAL HAZARD
IF ID/OF EX MEM WB
AL
UMiReg/Md
MdReg
AL
U Reg
AL
U Reg
AL
U Reg
AL
U
Mi
Mi
Mi
Mi
Md
Md
Md
Md
Reg/Md
Reg/Md
Reg/Md
Reg/Md
t
Ins.1
Ins.2
Ins.3
Ins.4
Ins.5
Md: data memoryMi : instruction me-
mory
EdyWin 26
IF ID/OF EX MEM WB
AL
UMiReg/Md
MdReg
AL
U Reg
AL
U Reg
AL
U Reg
AL
U
Mi
Mi
Mi
Mi
Md
Md
Md
Md
Reg/Md
Reg/Md
Reg/Md
Reg/Md
Ins.1
Ins.2
Ins.3
Ins.4
Ins.5
Bila digunakan memory yang dual-port, sehingga akses ke Mi dan Md
dapat dilakukan serentak, maka konflik dapat dihindari.
EdyWin 27
Dual port memorySingle port memory
instruksi/program
portinstruksi
data
instruksi
data
portdata
portinstruksi/
data
EdyWin 28
DATA HAZARD akibat adanya ketergantungan data antar instruksi
ADD R1, R2, R3
SUB R4, R1, R3
AND R6, R1, R7
OR R8, R1, R9
XOR R10, R1, R11
ada ketergantungan data antar instruksi !
Non-pipeline : R4 = ? , R6 = ? , R8 = ?
Pipeline : R4 = ? , R6 = ? , R8 = ?
Misalkan mula mula nilai R1 = 5 , R2 = 1, R3 = 2, R7 = 4, R9 = 8,berapakah seharusnya nilai akhir R4, R6 dan R8 ?
EdyWin 29
t (clock cycles)
add r1,r2,r3
sub r4,r1,r3
and r6,r1,r7
or r8,r1,r9
xor r10,r1,r11
IF ID/OF EX MEM WB
AL
UMibacar2,r3
Md
AL
U Reg
AL
Ubacar1, r7
Reg
AL
Ubacar1, r9
Reg
AL
Ubacar1,r11
Mi
Mi
Mi
Mi
Md
Md
Md
Md
DATA HAZARD
harga r1 yang baru
hargar1 lama
harga r1tak-tentu
simpanr1
bacar1, r3
T1 T2 T4T3 T5 T6 T7
EdyWin 30
ADD R1, R2, R3
SUB R4, R1, R3
AND R6, R1, R7
OR R8, R1, R9
XOR R10, R1, R11
184215
R11R10R9R8R7R6R5R4R3R2R1
18113
8
4
4
4
11 8
8
8
8
0
0
11213
13
11213
1213
NON-PIPELINE
PIPELINE 4 83
13 atau 11
tidak sama
EdyWin 31
Klasifikasi data hazardsTipe ketergantungan data antar instruksi:
(Instruksi Ii adalah instruksi yang dieksekusi sebelum instruksi IJ)
– RAW -- read after write – Instruksi J mencoba
membaca data sebelum instruksi I mengubahnya.
– WAR -- write after read –instruksi J mencobamengubah (write) data sebelum data tersebut dibaca
oleh instruksi I.
– WAW -- write after write – Instruksi J mencoba menulis (mengubah)sebuah data sebelum data tersebut diubah oleh instruksi I. Urutanpenulisan salah.
I I
IJ
program
EdyWin 32write R7write R7
read R7write R7
read R6read R6
read R5read R5
write R1read R1
write R8read R8
LD R1, 45(R2)DADD R5, R6, R1DSUB R8, R6, R7OR R7, R5, R8AND R7, R1, R5
LD R1, 45(R2)DADD R5, R6, R7DSUB R8, R1, R7OR R7, R5, R8AND R7, R1, R5
LD R1, 45(R2)DADD R5, R6, R1DSUB R8, R6, R7OR R7, R5, R8AND R7, R1, R5
LD R1, 45(R2)DADD R5, R6, R1DSUB R8, R6, R7OR R7, R5, R8AND R7, R1, R5
Deteksi sumber data hazard
RAW
RAR*
WAR
WAW
EdyWin 33
Ii : OR R7, R5, R8Ii+1 : AND R7, R1, R5
Ii : DSUB R8, R1, R7Ii+1 : OR R7, R5, R8
Ii : DADD R5, R6, R1Ii+1 : DSUB R8, R6, R7
Ii : LD R1, 45(R2)Ii+1 : DADD R5, R6, R1
Contoh
operand sumber pada instruksi Ii =operand tujuan pada instruksi Ii+1 ?
WAR
operand tujuan pada instruksi Ii =operand tujuan pada instruksi Ii+1 ?
WAW
operand sumber pada instruksi Ii =operand sumber pada instruksi Ii+1 ?
RAR
operand tujuan pada instruksi Ii =operand sumber pada instruksi Ii+1 ?
RAWDeteksiTipe Data Hazard
Contoh : Untuk format instruksi
opcode operand-tujuan , operand-sumber1 , operand-sumber2
Deteksi dapat dilakukan secara hardware maupun secara software (oleh compiler)
EdyWin 34
Deteksi secara Software
Kompiler mengenali sumber data hazard dan menambahkan instruksi
NOP (no operation) untuk mengeliminasi data hazard
SUB R2, R1, R3 ; isi register R2 diubahNOP ;NOP ; 3 instruksi no operationNOP ;AND R12, R2, R5 ; isi R2 yg baru sudah dapat digunakanOR R13, R6, R2ADD R14, R2, R2SW 100 (R2), R15
atau instruksi instruksi yang tidak menimbulkan data hazard
EdyWin 35
sub R2, R1,R3
and R4, R2,R5
or R8, R2,R6
add R9, R4,R2
slt R1, R6,R7
Untuk ruas program dibawah ini,dimana saja instruksi NOP harus disisipkan ?
EdyWin 36
t (clock cycles)
sub r2,r1,r3
NOP
and r12,r2,r5
NOP
NOP
IF ID/OF EX MEM WB
AL
UMiReg Md Reg
AL
URegMi Md
harga r2 yang baru
bubblebubble bubblebubble bubble
bubblebubble bubblebubble bubble
bubblebubble bubblebubble bubble
membaca r2 yang sudah diubah oleh instruksi sub
EdyWin 37
Disamping Data Hazard, kompiler juga dapat mendeteksi potensi terjadinya
structural hazard, sehingga kompiler dapat menyisipkan instruksi NOP
pada saat kompilasi.
Apa kelemahan penyisipan instruksi NOP untuk mengatasi data-hazard atau
Structural hazard ????
EdyWin 38
AddBRZ LoadSubMult
ANDSHLAdd
Bila dari hasil pengujian syarat dipenuhimaka instruksi berikutnya adalah instruksiAND,tetapi bila syarat tidak dipenuhi makainstruksi berikutnya adalah instruksi Load
Dari eksekusi instruksi BRZ, alamat instruksiberikutnya (target) baru diketahui pada waktuinstruksi BRZ berada pada ruas MEM, atausetelah syarat diuji (pada ruas EX)
Pada saat itu instruksi2 Load, Sub dan Multsudah (terlanjur) masuk pipeline.
Control Hazard Hazard tipe ini ditimbulkan oleh perubahan aliraneksekusi instruksi, sebagai hasil eksekusi instruksipercabangan (BRANCH, JUMP, CALL, GOTO,...)atau interupsi
EdyWin 39
Ik10
Ib1
Ic2
Id3
Ie4
If5
Ig6
Ih7
Ii8
Ij9
Ia0
instruksialamat
Misalkan Ic = instruksi BRZ 4
Alamat target = PC + 4,yaitu bila syarat dipenuhi
Alamat next-instruction =
isi PC (= 3), yaitu bilasyarat tidak dipenuhi
displacement
EdyWin 40
• IF: Instruction fetchIR IMemory[PC]PC incr.PC alamat next-instruction
• ID: Instruction decode/operand-fetchnop tidak ada operand-fetch
• Ex: Executepengujian syarat apakah hasil ALU = 0 ?Target PC +displacement menghitung alamat target
(alamat instruksi berikutnya)• MEM: Memory
PC Target Bila syarat percabangan dipenuhi.Bila tidak dipenuhi mk digunakanisi PC hasil inrement pada fase IF
• WB: Write backnop
Eksekusi instruksi percabangan bersyaratmisal BRZ
Tergantung hasil pengujiansyarat pada fase EX
EdyWin 41
AL
UReg Mem RegMem
Add
BRZ
Load
AL
UMem Reg Mem Reg
AL
UMem Reg Reg
Sub
AL
UReg Mem RegMem
Mem
AL
URegMemMult
Mem
AL
URegMemAND
dibatalkan(flush)
CONTROL HAZARD
EdyWin 42
Deteksi control hazard secara software oleh kompiler dapat dilakukan.Instruksi NOP akan disisipkan dibawah instruksi percabangan.
Berapa jumlah instruksi NOP yang harus dididipkan dibawah intruksipercabangan bersyarat dan berapa untuk instruksi percabangan tak-bersyarat ?
EdyWin 43
DETEKSI HAZARD dan STALL SECARA HARDWARE
Untuk deteksi hazard dan stall secara hardware, sebuah modul hardwareakan :
Mendeteksi hazardDengan membandingkan bagian operand dari instruksi Ii+1 yang sudahberada dalam register instruksi (hasil dari fase IF untuk instruksi Ii+1 )dengan bagian operand dari instruksi Ii.
Memberikan tunda (stall)
a) menonaktifkan ruas ID/OF bagi Ii+1 , sehingga instruksi Ii+1 tidakdiproses oleh ruas ID/OF.
b) menonaktifkan ruas IF bagi instruksi instruksi Ii+2, Ii+3, ... tidak
dapat masuk kedalam pipeline.
Ruas IF dan ID/OF diaktifkan kembali setelah hazard diatasi (misalsetelah hasil instruksi Ii disimpan ke operand tujuan)
EdyWin 44
sub R2, R1, R3
and R12, R2, R5
or R13, R6, R2
add R14, R2, R2
Mi Reg Md Reg
Mi Reg Md
Mi Reg Md Reg
Mi Reg Md Reg
CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8
Bubble Bubble
IF IDstall
IFstall
IDstall
IFstall
IDstall
IDaktif
IFaktif
IDaktif
EdyWin 45
Structural hazard ?
DADD R1, R2, R3DSUB R4, R1, R5AND R6, R1, R7OR R8, R1, R9XOR R10, R1, R11
Data hazard ?
LD R1, 0(R2)
DSUB R4, R1, R5
AND R6, R1, R7
OR R8, R1, R9
(b) Gambarkan Gantt Chartnya
(a) Identifikasikan
EdyWin 46
Waktu eksekusi n buah instruksi
= (k-1) T + n.T + stall > (k-1) T + n.T
Makin banyak stallnya maka kinerja pipeline akan menurun.
WBMEMEXID/OFIF
tidak dihasilkan outputstall
insruksi instuksi LOAD, SUB, MULTyang sudah terlanjur masuk pipeline
AND
Kinerja :
k : Jumlah ruas pipeline
n : Jumlah instruksi yg dieksekusi
EdyWin 47
Peningkatan “kecepatan” dengan Pipelining
Ideal CPI = CPIunpipelined /Pipeline depth
CPI unpipelined Clock Cycle unpipelined
CPI pipelined Clock Cycle pipelined
CPIunpipelined
CPIpipelined
Clock Cycleunpipelined
Clock Cyclepipelined
Ideal CPI Pipeline depthCPIpipelined
Clock Cycleunpipelined
Clock Cyclepipelined
Speedup from pipelining
Speedup
=
=
=
=
= Jumlah ruas pipeline
Average Instr. Time Unpipelined
Average Instr. Time Pipelined
Tanpa stall
~~ 1
EdyWin 48
CPIpipelined = Ideal CPI + Pipeline stall clock cycles per instr
Speedup = Ideal CPI x Pipeline depthIdeal CPI + Pipeline stall CPI
Clock Cycle unpipelined
Clock Cycle pipelined
Speedup = Pipeline depth1 + Pipeline stall CPI
Clock Cycle unpipelined
Clock Cycle pipelined
Ideal CPI Pipeline depthCPIpipelined
Clock Cycleunpipelined
Clock Cyclepipelined
Speedup =
Untuk Ideal CPI ,~~ 1
EdyWin 49
WBMEMEXID/OFIF
tidak dihasilkan outputstall
10 instruksi 3 cycle stall
Pipeline Stall CPI = (3/10) cycle per instruction
EdyWin 50
Contoh : Dual-port vs. Single-port• Mesin A: Dual ported memory• Mesin B: Single ported memory, tetapi pipeline-nya menggunakan pesat clock
yang 1.2 kali lebih cepat• Ideal CPI =1 untuk keduanya• 40%dari instruksi yang dieksekusi adalah instruksi Load dan Store
Mesin A 1.17 kali lebih cepat
SpeedUp A Pipeline Depth / (1 + 0) (clock unpipe / clock pipe )
Pipeline Depth
SpeedUp B Pipeline Depth / (1 + 0.4 (clockunpipe
/ ( 1,2 clockpipe
.)
(Pipeline Depth/1.4) 1.2
0.86 Pipeline Depth
SpeedUp A / SpeedUp B Pipeline Depth/(0.86 Pipeline Depth) = 1.17
EdyWin 51
• Pentium:– 2 pipelines, masing masing 5 cycles– Pentium Pro/II/III– 3 pipelines, masing masing 12 cycles
EdyWin 52
Mengurangi Data Hazards dengan Forwarding (bypassing)
Mi Reg
ALU Md Reg
Mi Reg
ALU Md Reg
ADD R2, R3, R4
OR R5, R3, R2
Hazard dapat dicegah dengan mem-bypass atau forward Output ALU darioperasi ADD keinput ALU untuk operasi OR (disamping menyimpan output ALUke R2 seperti prosedur biasa)
Registers
ID/EX
ALU
EX/MEM MEM/WB
DataMemory
0
1
EdyWin 53
Bila pada sebuah cycle hardware mendeteksi adanya permintaan Readdan permintaan Write untuk Register yang sama,maka data yang akan dituliskan diforward ke input ALU.
EdyWin 54
Bypassing(Forwarding)
•Beberapa data hazard dapat dieliminasi dengan: bypassingatau forwarding
Pada tipe RAW :hasil ALU tidak hanya disimpanke memory atau register,ttp juga diberikan langsung keinput ALU
DADD R1, R2, R3
DSUB R4, R1, R5
AND R6, R1, R7
OR R8, R1, R9
XOR R10, R1, R11
EdyWin 55
Dengan Stall (tanpa Forwarding)
DADD R1, R2, R3
DSUB R4, R1, R5
AND R6, R1, R7
OR R8, R1, R9
XOR R10, R1, R11
EdyWin 56
DADD R1, R2, R3LD R4, 0(R1)STO R4, 12(R1)
EdyWin 57
Data Hazard Stalls : Tidak semua data hazard dapat di eliminasi
Contoh :
LD R1, 0(R2)
DSUB R4, R1, R5
AND R6, R1, R7
OR R8, R1, R9
EdyWin 58
lw R2, 10(R1)
and R12, R2, R5
or R13, R6, R2
add R14, R2, R2
store R15, 100(R2)
IM Reg
AL
U DM Reg
IM Reg
AL
U DM
IM Reg
AL
U DM Reg
IM Reg
AL
U DM Reg
CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8
IM Reg
AL
U
Bubble
Bubble
untuk masalah yang tidak dapat dieliminasi dengan forwarding masih perluditambahkan stall
EdyWin 59
sub R2, R1, R3
and R6, R2, R5
or R13, R6, R2
add R14, R2, R2
sto R15, 100(R2)
M Reg
AL
U
M Reg
IM Reg
AL
U
DM
IM Reg
AL
U
DM Reg
IM Reg
AL
U
DM Reg
M Reg
AL
U
M Reg
CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8
Mi
Mi
Mi
Mi
Mi
Md
Md
Md
Md
Md
(1) Identifikasikan forwardingnya
EdyWin 60
(2) Tunjukkan stalls dan forwarding untuk kode dibawah ini
add R3, R2, R1
load R4, 100(R3)
and R6, R4, R3
sub R7, R6, R2
EdyWin 61
Jelaskan dengan contoh, teknik teknik software untuk mengatasi pipelinehazard.