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UVSHFLILHUVIGHFLGH LIRULQVWUXFWLRQVFDQLVVXH 7UDGHRIILQVWUXFWLRQVSDFHIRUVLPSOHGHFRGLQJ ² 5HJLVWHUILOHQHHG[UHDGVDQG[ZULWHVF\FOH ² 7KHORQJLQVWUXFWLRQZRUGKDVURRPIRUPDQ\RSHUDWLRQV ² 5HQDPHORJLFPXVWEHDEOHWRUHQDPHVDPHUHJLVWHUPXOWLSOHWLPHV ² %\GHILQLWLRQDOOWKHRSHUDWLRQVWKHFRPSLOHUSXWVLQWKHORQJ LQRQHF\FOHR)RULQVWDQFHFRQVLGHUZD\LVVXH LQVWUXFWLRQZRUGDUHLQGHSHQGHQW !H[HFXWHLQSDUDOOHO add r1, r2, r3 add p11, p4, p7 ² (JLQWHJHURSHUDWLRQV)3RSV0HPRU\UHIVEUDQFK sub r4, r1, r2 ⇒ sub p22, p11, p4 lw r1, 4(r4) lw p23, 4(p22) ª WRELWVSHUILHOG ! RUELWVWR RU add r5, r1, r2 add p12, p23, p4 ELWVZLGH ,PDJLQHGRLQJWKLVWUDQVIRUPDWLRQLQDVLQJOHF\FOHR ² 1HHGFRPSLOLQJWHFKQLTXHWKDWVFKHGXOHVDFURVVVHYHUDOEUDQFKHV ² 5HVXOWEXVHV1HHGWRFRPSOHWHPXOWLSOHLQVWUXFWLRQVF\FOH ª 6RQHHGPXOWLSOHEXVHVZLWKDVVRFLDWHGPDWFKLQJORJLFDWHYHU\ UHVHUYDWLRQVWDWLRQ ª 2UQHHGPXOWLSOHIRUZDUGLQJSDWKV &6.XELDWRZLF] &6.XELDWRZLF] /HF /HF 5HFDOO8QUROOHG/RRSWKDW /RRS8QUROOLQJLQ9/,: 0LQLPL]HV6WDOOVIRU6FDODU Memory Memory FP FP Int. op/Clock 1 Loop: LD F0,0(R1) LD to ADDD: 1 Cycle reference 1 reference 2 operation 1 op. 2 branch 2 LD F6,-8(R1) ADDD to SD: 2 Cycles LD F0,0(R1) LD F6,-8(R1) 1 3 LD F10,-16(R1) LD F10,-16(R1) LD F14,-24(R1) 2 4 LD F14,-24(R1) LD F18,-32(R1) LD F22,-40(R1) ADDD F4,F0,F2 ADDD F8,F6,F2 3 5 ADDD F4,F0,F2 LD F26,-48(R1) ADDD F12,F10,F2 ADDD F16,F14,F2 4 6 ADDD F8,F6,F2 7 ADDD F12,F10,F2 ADDD F20,F18,F2 ADDD F24,F22,F2 5 8 ADDD F16,F14,F2 SD 0(R1),F4 SD -8(R1),F8 ADDD F28,F26,F2 6 9 SD 0(R1),F4 SD -16(R1),F12 SD -24(R1),F16 7 10 SD -8(R1),F8 SD -32(R1),F20 SD -40(R1),F24 SUBI R1,R1,#48 8 11 SD -16(R1),F12 SD -0(R1),F28 BNEZ R1,LOOP 9 12 SUBI R1,R1,#32 Unrolled 7 times to avoid delays 13 BNEZ R1,LOOP 14 SD 8(R1),F16 ; 8-32 = -24 7 results in 9 clocks, or 1.3 clocks per iteration (1.8X) Average: 2.5 ops per clock, 50% efficiency 14 clock cycles, or 3.5 per iteration &6.XELDWRZLF] Note: Need more registers in VLIW (15 vs. 6 in SS)&6.XELDWRZLF] /HF /HF 5HFDOO6RIWZDUH3LSHOLQLQJ 5HFDOO6RIWZDUH3LSHOLQLQJ([DPSOH %HIRUH8QUROOHGWLPHV After: Software Pipelined 2EVHUYDWLRQLILWHUDWLRQVIURPORRSVDUHLQGHSHQGHQW LD F0,0(R1) 1 SD 0(R1),F4 ; Stores M[i] WKHQFDQJHWPRUH,/3E\WDNLQJLQVWUXFWLRQVIURP ADDD F4,F0,F2 2 ADDD F4,F0,F2 ; Adds to M[i-1] GLIIHUHQW LWHUDWLRQV SD 0(R1),F4 3 LD F0,-16(R1); Loads M[i-2] LD F6,-8(R1) 4 SUBI R1,R1,#8 6RIWZDUHSLSHOLQLQJUHRUJDQL]HVORRSVVRWKDWHDFK ADDD F8,F6,F2 5 BNEZ R1,LOOP LWHUDWLRQLVPDGHIURPLQVWUXFWLRQVFKRVHQIURP SD -8(R1),F8 GLIIHUHQWLWHUDWLRQVRIWKHRULJLQDOORRS 7RPDVXOR LQ LD F10,-16(R1) 6: ADDD F12,F10,F2 SW Pipeline Iteration SD -16(R1),F12 0 Iteration 1 Iteration SUBI R1,R1,#24 2 Iteration BNEZ R1,LOOP Time 3 Iteration 4 Loop Unrolled • Symbolic Loop Unrolling Software- – Maximize result-use distance ops overlapped pipelined iteration – Less code space than unrolling – Fill & drain pipe only once per loop Time vs. once per each unrolled iteration in loop unrolling &6.XELDWRZLF] &6.XELDWRZLF] /HF /HF 6RIWZDUH3LSHOLQLQJZLWK /RRS8QUROOLQJLQ9/,: 7UDFH6FKHGXOLQJ 3DUDOOHOLVPDFURVV,)EUDQFKHVYV/223EUDQFKHV Memory Memory FP FP Int. op/Clock 7ZRVWHSV reference 1 reference 2 operation 1 op. 2 branch ² 7UDFH 6HOHFWLRQ LD F0,-48(R1) ST 0(R1),F4 ADDD F4,F0,F2 1 ª )LQGOLNHO\VHTXHQFHRIEDVLFEORFNV WUDFH LD F6,-56(R1) ST -8(R1),F8 ADDD F8,F6,F2 SUBI R1,R1,#24 2 RI VWDWLFDOO\SUHGLFWHGRUSURILOHSUHGLFWHG LD F10,-40(R1) ST 8(R1),F12 ADDD F12,F10,F2 BNEZ R1,LOOP 3 ORQJVHTXHQFHRIVWUDLJKWOLQHFRGH ² 7UDFH &RPSDFWLRQ • Software pipelined across 9 iterations of original loop ª 6TXHH]HWUDFHLQWRIHZ9/,:LQVWUXFWLRQV – In each iteration of above loop, we: ª 1HHGERRNNHHSLQJFRGHLQFDVHSUHGLFWLRQLVZURQJ » Store to m,m-8,m-16 (iterations I-3,I-2,I-1) 7KLVLVDIRUPRIFRPSLOHUJHQHUDWHGVSHFXODWLRQ » Compute for m-24,m-32,m-40 (iterations I,I+1,I+2) ² &RPSLOHUPXVWJHQHUDWH´IL[XSµFRGHWRKDQGOHFDVHVLQZKLFK » Load from m-48,m-56,m-64 (iterations I+3,I+4,I+5) WUDFHLVQRWWKHWDNHQEUDQFK • 9 results in 9 cycles, or 1 clock per iteration ² 1HHGVH[WUDUHJLVWHUVXQGRHVEDGJXHVVE\GLVFDUGLQJ • Average: 3.3 ops per clock, 66% efficiency 6XEWOHFRPSLOHUEXJVPHDQZURQJDQVZHU YVSRRUHUSHUIRUPDQFHQRKDUGZDUHLQWHUORFNV Note: Need less registers for software pipelining &6.XELDWRZLF] &6.XELDWRZLF] (only using 7 registers