計算機系統(tǒng)結構實驗報告_1_第1頁
計算機系統(tǒng)結構實驗報告_1_第2頁
計算機系統(tǒng)結構實驗報告_1_第3頁
計算機系統(tǒng)結構實驗報告_1_第4頁
免費預覽已結束,剩余10頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、計算機系統(tǒng)結構實驗報告計算機系統(tǒng)結構實驗報告一.流水線中的相關實驗目的:1. 熟練掌握windlx莫擬器的操作和使用,熟悉dlx旨令集結構及其特點;2. 加深對計算機流水線基本概念的理解;3. 進一步了解dlx基本流水線各段的功能以及基本操作;4. 加深對數(shù)據(jù)相關、結構相關的理解,了解這兩類相關對cpi性能的影響;5. 了解解決數(shù)據(jù)相關的方法,掌握如何使用定向技術來減少數(shù)據(jù)相關帶來的暫停。實驗平臺:win dlx模擬器實驗內(nèi)容和步驟:1.用windlx模擬器執(zhí)行下列三個程序:求階乘程序fact.s求最大公倍數(shù)程序gcm.s求素數(shù)程序prim.s分別以步進、連續(xù)、設置斷點的方式運行程序,觀察程序

2、在流水線中的執(zhí)行情況,觀察cpi中寄存器和存儲器的內(nèi)容。熟練掌握win dlx勺操作和使用。2. 用windlx!行程序structure_d.s ,通過模擬找出存在資源相關的指令對以及導致資源相關的部件;記錄由資源相關引起的暫停時鐘周期數(shù),計算暫停時鐘周期數(shù)占總執(zhí)行周期數(shù)的百分比;論述資源相關對cpi性能的影響,討論解決資源相關的方法。3. 在不采用定向技術的情況下(去掉configuration 菜單中enable forwarding 選項前的勾選符),用windlx!行程序data_d.s。記錄數(shù)據(jù)相關引起的暫停時鐘周期數(shù)以及程序執(zhí)行的總時鐘周期數(shù),計算暫停時鐘周期數(shù)占總執(zhí)行周期數(shù)的百

3、分比。在采用定向技術的情況下(勾選enable forwarding ),用windlx再次運行程序data_d.&重復上述3中的工作,并計算采用定向技術后性能提高的倍數(shù)。1.求階乘程序用windlx模擬器執(zhí)行求階乘程序fact.s。這個程序說明浮點指令的使用。該程序從標準輸入讀入一個整數(shù),求其階乘,然后將結果輸出。該程序中調(diào)用了input.s中的輸入子程序,這個子程序用于讀入正整數(shù)。實驗結果:在載入fact.s和input.s之后,不設置任何斷點運行。a不采用重新定向技術,我們得到的結果total:cycle($ executed.id executed bp 145 lnshuctiori

4、($)-2 instruction(s) currently in pipeline. stalls: raw 泅is: 53 (22.46 of all cycles) waw stalls: 0 (0.00 of all ccle)stiuctural stalk 0 (oldo of all cyclescontrol stalls: 25 (1(159% of dl cdesjtrap stals 12 5l08 of all cycles) total:90 stall(s) (30 14 of all cycles)b.采用定向技術,我們得到的結果:total:215 cycle(

5、s) executedid ewecuted by 145 lnebuclion(*).2instruction(s) current in pipeline.stalls:raw stalk 1 ? (/.91 cf all cycles), thereof:ld stalls: 3 (17.65x of raw stalls branch/jump 3 (17.65 of raw stdh floating point stalls:11(64.70當of rawwaw stalls: 0 (0.00 of all cycles)slructural wtallw: 0 o.co of a

6、ll cycles)control stalls:25 (11.63 ot all cycledtrap stalls: 12 (5.58 of al cyclestotal: 54 sull(s) 25.12 of all qdet)從上面的數(shù)據(jù)我們可以看出定向的作用:在定向技術存在的情況下statistics窗口中的各種統(tǒng)計數(shù)字:總的周期數(shù)(215)和暫停數(shù)(17 raw, 25 control, 12 trap; 54 total)在定向技術不存在時候,控制暫停和trap暫停仍然是同樣的值,而raw 暫停從17變成了53,總的模擬周期數(shù)增加到236。所以定向技術帶來的加速比:236 /

7、215 = 1.098dlx forwarded 比dlx not forwarded 快9.8%。2.數(shù)據(jù)相關先給出一個存在數(shù)據(jù)相關的程序:lhi r2, (a16) & 0xffffaddui r2, r2, a & 0xfffflhi r3, (b16)&0xffffaddui r3, r3, b&0xffffloop:lw r1,0 (r2)add r1, r1, r3sw 0(r2), r1lw r5, 0 (r1)addi r5, r5, #10addi r2, r2, #4sub r4, r3, r2bnez r4, looptrap #0a: .word 0, 4, 8, 12

8、, 16, 20, 24, 28, 32, 36b: .word 9, 8, 7, 6, 5, 4, 3, 2, 1,0沒有采用定向技術時運行該程序:得到 rotal: 202 cicle($) executed.id execljled by ei5 instruction(s).2lnstruction(s currently in pipeline.stalis:raw 紡瞳104 (51 4眈af all cdeswaw atolls: 0 (0.00 of all cyclesstructural 躺11$:0 (j.oo of all cycles)contirol stalls:

9、 9 (4 4e蠱of al cycles)trap stak: 3 (1.48%of all cyclesto怕i:116 stall(s) (57.42 of oil cycles程序執(zhí)行了202個周期,10個數(shù)據(jù)相關引起的時鐘周期raw stall為104個。暫停時鐘周期數(shù)占總執(zhí)行周期數(shù)的百分比=51.48%采用定向技術時運行該程序:得到total:12s cycle$) executedid executed by 85 iri2hruction(s).2inskuctionbi cuirently in pipeline.stalls:rawstk 30(23.443:dal cyc

10、les), thereofld 站憑:20 (66.67 of raw 期lg) branchzjump stalls: 1d (33.33 of raw 奴all$floating point stall:0 (0.00 of raw sials)waw slab: 0 (0 00 d all cycles)structural stalls 0 (0 00 of al cycles)cortral stalls: 9 (/.03 of cill cycles)tiap stalls- 3 (2.34 of all clestotal: 42 stal|s) (j2.81 of al cyc

11、les)程序執(zhí)行了128個周期,共有6個數(shù)據(jù)相關引起的時鐘周期raw stall為30個。暫停時鐘周期數(shù)占總執(zhí)行周期數(shù)的百分比=23.44%可見通過定向技術,減少了數(shù)據(jù)相關,縮短了程序的執(zhí)行周期,整個性能為原來的1.57 倍。3.結構相關下面這段程序存在結構相關addi r5, r5, 1subi r4, r4, 1and r3, r3, r3xor r7, r7, r7addi r8, r8, 1addi r9, r9, 1mult r1,r5,r4mult r2,r3,r7執(zhí)行之后得到的clock cycle programeirblrucliare/?1陰:-舊卜日丨ii 一 ti巳廠“

12、it舟卜電i i * t * r彳r彳i彳iiaddi石托血1 | if | id berrmemtb|iand r3j3j3 : | if | id | inlv | mem |nor r7j7j? : | 1卜| id l”s | z ili addi r?油血1 : | if | id | iiw | mem | vje |addi占油血1 : if | id | in段| mem |衛(wèi)鳥!rrdt rlj5j4 ?|_l 血imule兇1j | mem w廠rrdt r2j3j? : if id _| imu丸1 mem v/e statistics: total:20 cycle($

13、) ekecuted.id executed 14 instructior(s).5 lntruction($) currentlv in pipeline.stalls:raw stalls: 0 (0.00 of all cycles, thereof:ld shlls: 0(0.00 d raw stalls)branchalump stalls:0 (0 00 of raw 咖ll$floating point stalls: 0 (0l0ds of raw stalls)waw stalls 0 0.00s;d all cycles)structural 旳胚:4 (20.00 of

14、 all cycles)control stalk: q (0 00 of al cycles)trp stalls: 0 (0.00 of all cycles)i otal: 4 staksj 20.00 of all cycles)可見1個結構相關引起了4個stall,占總共20個cycle的20%為了避免結構相關,可以考慮采用資源重復的方法,比如,在流水線機器中設置相互獨立的指令存儲器和數(shù)據(jù)存儲器,也可以將cache分割成指令cache和數(shù)據(jù)cache。二.循環(huán)展開及指令調(diào)度實驗目的:1. 加深對循環(huán)級并行性、指令調(diào)度技術、循環(huán)展開技術以及寄存器換名技術的理解;2. 熟悉用指令調(diào)度技術

15、來解決流水線中的數(shù)據(jù)相關的方法;3. 了解循環(huán)展開、指令調(diào)度等技術對cpi性能的改進。實驗平臺:windlx模擬器 實驗內(nèi)容和步驟: 1 ?用指令調(diào)度技術解決流水線中的結構相關與數(shù)據(jù)相關(1 )用dlx匯編語言編寫代碼文件*.s,程序中應包括數(shù)據(jù)相關與結構相關(假設:加法、乘法、除法部件各有2個,延遲時間都是3個時鐘周期)(2)通過configuration菜單中的floating point stages選項,把加法、乘法、除法部件的個數(shù)設置為2個,把延遲都設置為3個時鐘周期;(3)用如dlx運行程序。記錄程序執(zhí)行過程中各種相關發(fā)生的次數(shù)、發(fā)生相關的指令組合,以及程序執(zhí)行的總時鐘周期數(shù);(4

16、)采用指令調(diào)度技術對程序進行指令調(diào)度,消除相關;(5運行調(diào)度后的程序,觀察程序在流水線中的執(zhí)行情況,記錄程序執(zhí)行的總時鐘周期數(shù);(6)根據(jù)記錄結果,比較調(diào)度前和調(diào)度后的性能。論述指令調(diào)度對于提高cpu性能的意義。2.用循環(huán)展開、寄存器換名以及指令調(diào)度提高性能(1 )用dlx匯編語言編寫代碼文件*.s,程序中包含一個循環(huán)次數(shù)為4的整數(shù)倍的簡單循環(huán);(2運行該程序。記錄執(zhí)行過程中各種相關發(fā)生的次數(shù)以及程序執(zhí)行的總時鐘周期數(shù);(3)將循環(huán)展開3次,將4個循環(huán)體組成的代碼代替原來的循環(huán)體,并對程序做相應的修改。然后對新的循環(huán)體進行寄存器換名和指令調(diào)度;(4運行修改后的程序,記錄執(zhí)行過程中各種相關發(fā)生的

17、次數(shù)以及程序執(zhí)行的總時鐘周期數(shù);(5)根據(jù)記錄結果,比較循環(huán)展開、指令調(diào)度前后的性能。3)存在相關的程序1.指令調(diào)度:首先,通過configuration菜單中的白oating point stages選項,把除法單元數(shù)設置為3,把加法、乘法、除法的延遲設置為3個時鐘周期。給出調(diào)度前的程序sch_bef:.data.global oneone: .word 1.text.global mai nmain:lf f1,one ;turn divf into a movecvti2f f7,f1 ;by stori ng in f7 1 innop ;float in g-po int forma

18、tdivf f1,f8,f7 ;move y=(f8) into f1divf f2,f9,f7 ;move z=(f9) into f2addf f3,f1,f2divf f10,f3,f7 ;move f3 into x=(f10)divf f4,f11,f7 ;move b=(f11) into f4divf f5,f12,f7 ;move c=(f12) into f5multf f6,f4,f5divf f13,f6,f7 ;move f6 into a=(f13)fi nish: trap 0 運行之后可以得到結果:total:27cicle(s) executed.id exec

19、uted by 12lnshuction($._ lnstfuction|x currently in pipeline.stalls :raw stalls: 9 (33.33鬼of all cycles thereof:ld 治陸 1 (11 1uof raw stalls)branch al ump stalls: 0 0.00 龕of raw stals)floatirg point stalls: 8 1 qqloosf of raw stals)waw stalls:0 (0.003:of all cvciejstructural 如ils:0 (0.00 of all cycle

20、dconlrd stalls: 0 (0.00x of dl cydes)t rap dale 1(25l92% of dl 匚yck制total: l6stall(s) (59.26 of all cycles調(diào)度之后的程序sch_aft:.data.global oneone: .word 1.text.global mai nmain:lf f1,one ;turn divf into a movecvti2f f7,f1 ;by stori ng in f7 1 innop ;float in g-po int formatdivf f1,f8,f7 ;move y=(f8) into

21、 f1divf f2,f9,f7 ;move z=(f9) into f2divf f4,f11,f7 ;move b=(f11) into f4divf f5,f12,f7 ;move c=(f12) into f5addf f3,f1,f2multf f6,f4,f5divf f10,f3,f7 ;move f3 into x=(f10)divf f13,f6,f7 ;move f6 into a=(f13)fi nish:trap 0運行之后得到:lota 丄21 c vc i b(s)executed.id executed by 12 instruction($).2instruct

22、ion(s) currently in pipeline.stal is:raw 獻alb: 3 (14.2qk of al cycles), lhereaf: ld stalk 1 (33 33 of raw stalk branch/jump stak: 0 (0.00% of raw sials floating point sldk 2舊6.67w of raw stalls)waw stalls: 0 (0 00 nf all cyclesstiuctural stalls: 0 (0.30sof all cyclescontrol stalls: cl (0.00 of all c

23、yclestrap stab: e (29157x of dl cycledtotal: 9 stdb) (42.bg% of all cycles) 可以看出經(jīng)過調(diào)度之后 運行周期從27減少到21,而且減少了相關。2.循環(huán)展開:循環(huán)展開前的程序:lhi r2, (a16 )& oxffffaddui r2, r2, a&0xfffflhi r3, (b16) &0xffffaddui r3, r3, b&0xffffaddu r4, r0, r3noploop:subi r4, r4, #8sub r5, r4, r2bnez r5, looptrap #0a:.double 1,2, 3,

24、 4b: .double 1,2, 3, 4運行結果:statistics 一| |total:30 cycled ecuted.id executed bv i9ln$truction($).2 instruction(s) currently nn pipeline.hardware conf iguration:memory size: 32768 bytes faddex-stages: 1“ required cycles: 2 fmulex-shges: l required ccle$: 5 fdivex-stagec: 1, required cycles:19 forward

25、ing enabled.stalls:raw sc 4 (1333需of all cycles), thereof: ld stalls: 0 (0.00 of raw stalls) branch/jump stalls:4 (100.00% of raw ttek) floating point stals: 0 (0. 00 of raw stall)waw stalls 0 d o號of all cycles) strudurd stalls: l (0 00k of all cycled control tta*3(10.00 of al cycles) trap stalls; 3 (1o oox of all cycles) total: 10 stall(s) (33.33 of all cycles)循環(huán)展開后的程序:r2, (a16 )& oxfffflhiaddui r2, r2, a&oxfffflhi r3, (b16) &0xffffaddui r3, r3, b&0xffffaddu r4, r0, r3subi r4, r4, #8subi r4, r4, #8 subi r4, r4,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論