המצגת נטענת. אנא המתן

המצגת נטענת. אנא המתן

Out Of Order Execution (Part 1)

מצגות קשורות


מצגת בנושא: "Out Of Order Execution (Part 1)"— תמליל מצגת:

1 Out Of Order Execution (Part 1)

2 Execution of instructions with variable execution time
Problem: Single cycle Execution phase  The longest operation possible in the machine fixes the frequency Example: ADD/SUB=2ns, MUL=10ns, DIV=20ns  cc=20ns Solution: Implement a pipeline in EXE Execution time of certain instructions is now variable (i.e. load with or without cache miss) More pipe stages = bigger penalty on misprediction and more data hazards (but generally an increase in CPI)

3 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider

4 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R2  R3*R3 R1R1+4

5 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R1  R1+4 R4  R3+R4 R2  R3*R3

6 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R1  R1+4 R2  R3*R3 R4  R3+R4

7 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R1  R1+4 R2  R3*R3

8 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R2  R3*R3

9 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R2  R3*R3

10 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R2  R3*R3

11 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R2  R3*R3

12 Execution of instructions with variable execution time
Problem: A short operation might get “stuck” waiting for another operation of a different type to leave the Execution phase. Solution: Allow instructions of different types/pipelines to be executed Out of Order. Execute many independent instructions in parallel (in different pipelines). Improves CPI. Execution must keep correctness of the code. Note: If an operation gets “stuck” waiting for another operation of the same type to leave the Execution phase.  Structural Hazard (need to add more execution units to solve).

13 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R2  R3*R3 R1R1+4

14 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R1  R1+4 R4  R3+R4 R2  R3*R3

15 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R1  R1+4 R2  R3*R3 R4  R3+R4

16 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R1  R1+4 R2  R3*R3

17 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R2  R3*R3

18 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R4  R3+R4 R2  R3*R3

19 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R2  R3*R3

20 דוגמא R1R1+4 R2R3*R3 R4R3+R4 IF ID MEM WB DIV EX M1 M2 M3 M4
Integer unit Multiply divider R2  R3*R3

21 CPI במכונות in order כמו שהכרנו עד היום ה-CPI המינימלי שניתן להשיג הוא 1 גם בביצוע שהינו OOO חסם זה קיים כל עוד נאפשר ביצוע מקביל רק של שלב ה-EXE. אם נאפשר ביצוע מספר הוראות במקביל גם בשאר השלבים אזי נוכל לשבור חסם זה. IF ID EXE MEM WB IF ID EXE MEM WB

22 תלויות מידע (data hazard)
להזכירכם אנו מכירים כבר תלות מידע מסוג RAW: ADD R1,R2,R3 ADD R5,R6,R1 :RAW (Read After Write) יעד של הפקודה הראשונה הוא מקור בפקודה השניה. זוהי תלות אמיתית שיש לקיים על מנת לשמור על נכונות התכנית.

23 תלויות מידע (data hazard)
ביצוע שלא על פי הסדר (OOOE) יוצר תלויות חדשות בין פקודות: WAR – Write After Read DIV R1,R2,R3 // many cycles ADD R5,R6,R1 // depends on previous instruction ADD R6,R7,R8 // WAR issue הוראת החילוק הארוכה מעכבת את הוראת החיבור שאחריה (ממתינה לערך של (R1. מכיוון שאנו מאפשרים ביצוע out of order, ההוראה השלישית (שלא מחכה לכלום) תתבצע לפני השנייה, ולכן ההוראה השנייה (כשתתבצע) עלולה לקרוא את הערך של R6 כפי שנכתב ע"י ההוראה השלישית ולא את הערך הקודם (כפי שהתכוון הקומפיילר/מתכנת). הכתיבה ל-R6 ע"י הוראה (3) צריכה לקרות אחרי הקריאה שלו ע"י הוראה (2)

24 WAW – Write After Write DIV R1,R2,R3 // many cycles
ADD R5,R6,R1 // depends on previous instruction ADD R5,R7,R8 // WAW issue גם כאן ההוראה השנייה מעוכבת ואילו השלישית לא, מה שעלול להוביל לכך שההוראה השנייה תכתוב ל-R5 אחרי ההוראה השלישית, כך שבסופו של דבר R5 יכיל ערך לא עדכני. צריך לוודא שהכתיבה של R5 ע"י הוראה (3) תיעשה לאחר הכתיבה שלו ע"י הוראה (2). תלויות אלו נקראות False Dependencies מכיוון שניתן היה להשתמש ברגיסטרים שונים ובכך לשבור את התלות (כלומר הפקודות לא באמת תלויות בגלל ערכים שהן מחשבות, אלא עקב בחירת רגיסטרים זהה אך שרירותית עבורן). אם היו לרשות הקומפיילר/מתכנת יותר רגיסטרים, היה יכול לבחור רגיסטרים שונים לכל פעולה ובכך "לשבור" את התלות.

25 Register Renaming דרך לפתור את בעיית התלויות החדשות (WAR, WAW) היא ע"י Register Renaming. הרעיון: שמירת שתי מערכות רגיסטרים: זאת אשר גלויה למשתמש (רגיסטרים ארכיטקטונים, למשל R5) וזאת אשר לשימוש המהדר (רגיסטרים פיזיים, למשל P8) ישנו מס' גדול יותר של רגיסטרים פיזיים מאשר רגיסטרים ארכיטקטונים. כאשר פקודה מבקשת להשתמש ברגיסטר ארכ' כלשהו ממנים לה רגיסטר פיזי. שתי פקודות שמבקשות להשתמש באותו רגיסטר, איך אינן תלויות באופן אמיתי (RAW), מקבלות באופן אוטומטי שני רגיסטרים פיזיים שונים: R1  R2+R3  P1  R2+R3 R1  R4+R5  P2  R4+R5 אנו מנהלים שני מיפויים: מיפוי מהרגיסטרים הארכיטקטוניים לרגיסטרים הפיזיים (למשל R5P8) לצורך פתירת בעיות תלויות מדומות. המיפוי הזה נשמר כחלק מהמעבר בין שלב ה-decode לשלב ה-execution מיפוי מהרגיסטרים הפיזיים לארכיטקטוניים (למשל P8R5) לצורך שמירת הערך שפקודה מפיקה חזרה לרגיסטר אליו התכוון הקומפיילר. המיפוי הזה נשמר כחלק משלב ה-commit.

26 OOO-Execution Processor
רוב המעבדים המודרניים מבצעים את שלבי ה-commit וה- fetch/decode בסדר התוכנית (in order) ואילו רק שלב הביצוע מתבצע out of order. (out-of-order) Fetch & Decode EXE Retire (commit) In-order מקום להוראה הבאה הוראה הבאה שמבצעת commit

27 ROB (Re-Order Buffer) דרך נפוצה למימוש של Register Renaming היא ע"י ROB, שהוא בעצם חוצץ (buffer) המקבל את ההוראות משלב ה-decode ע"פ הסדר. הכניסה המתאימה ב-ROB מהווה את מספר הרגיסטר הפיזי אליו הפקודה כותבת. לאחר שלב ה-EXE של פקודה כלשהי, התוצאה שלה נכתבת לכניסה המתאימה ב-ROB. הוראות מבצעות את שלב ה-commit (לקראת יציאה מהמעבד לאחר סיום) ע"פ הסדר שלהן ב-ROB: הוראה יכולה לבצע commit רק אם זו שלפניה עשתה זאת.

28 דוגמא: DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 WAW WAR
Arch reg.. Phys reg.. R1 R2 R3 R4 DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 WAW WAR Renamer P0 P1 P2 P3 Pn buffer ציקלי

29 דוגמא: P0 DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 Renamer
Arch reg.. Phys reg.. R1 R2 R3 R4 P0 DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 Renamer P0 P1 P2 P3 Pn R2/R3

30 דוגמא: P0 DIV R1,R2,R3 P1 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2
Arch reg.. Phys reg.. R1 R2 R3 R4 P0 DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 P1 Renamer P0 P1 P2 P3 Pn R2/R3 R4+P0

31 דוגמא: P0 DIV R1,R2,R3 P2 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2
Arch reg.. Phys reg.. R1 R2 R3 R4 P0 DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 P2 Renamer P0 P1 P2 P3 Pn R2/R3 R4+P0 R3+R3

32 דוגמא: P0 DIV R1,R2,R3 P2 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 P3
Arch reg.. Phys reg. R1 R2 R3 R4 P0 DIV R1,R2,R3 ADD R2,R4,R1 ADD R2,R3,R3 ADD R4,R3,R2 P2 P3 Renamer P0 P1 P2 P3 Pn R2/R3 R4+P0 R3+R3 שים לב: כעת אין תלויות מסוג False Dependencies )אבל RAW עדיין קיים( R3+P2

33 X86 Structures IDQ RAT / Alloc ROB RS RRF: (4 write ports)
Dest (Arch) #phys reg 0: Read from RRF 1: Read from ROB EAX xxx 0 (RRF) EBX 19 1 (ROB) ECX 23 ROB RS # Data Valid Data DST 19 V 12 EBX 23 33 ECX 37 I xxx EAX 38 x v src1 src2 Pdst add 1 97H 12H 37 sub rob37 33H 38 Dest. (Phys Reg) (4 write Ports, 1 entry per uop) Arch reg: value from RRF Phys reg + valid: value from ROB Phys reg + not valid: wait for value RRF: EAX 97H Source & dest values updated after EXE

34 IBM model 91 First IBM computer to support OOO execution.
Tomasulo Algorithm

35 דוגמא ל-OOO Execution נתונה מכונת ה-P6 שמומשה במעבדי Pentium 2/3.
במכונה זו הוראות (CISC) נכנסות לשלב ה-decode ע"פ הסדר, ולפני היציאה ל-Execution הן מפורקות לפקודות פנימיות הנקראות uops (RISC). למשל, הוראת LD R4, (R5+50) מפורקת לשתי uops: פקודה אריתמטית שמחשבת את הכתובת בזכרון פקודת טעינה מהזכרון (של הכתובת שחושבה) אל רגיסטר. הערה: התרגום מהוראות (CISC) לפקודות/uops (RISC) נעשה ברוב המעבדים המודרניים. ה-uops מתבצעות בשלב ה-EXE באופן out-of-order. לבסוף, בשלב ה-retire ה-uops יוצאות מהמכונה בסדר בו נכנסו אליה (כלומר ע"פ הסדר המקורי של ההוראות בתכנית). המכונה מבצעת Register Renaming הממומש ב-ROB (כפי שנלמד). פקודות נכתבות אל ה-ROB כאשר הן יוצאות משלב ה-Decode אל שלב ה-Execution.

36 התכנית DIV R2,R4,R3 LD R3,R4(50) מס' מחזורי ביצוע לכל פקודה: DIV: 4cc
ADD R2,R4,R3 SUB R3,R2,R3 מס' מחזורי ביצוע לכל פקודה: DIV: 4cc LD: 2cc ADD/SUB: 1cc

37 Instruction Q ROB Execute Retire (WB) RAT R3R2-R3 RF1 R2R4+R3 RF2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RF1 Arch Reg. RF2 Program Order RF3 RF4 RS MOB ROB # Valid Data Valid Data DST I x xxx X Phys. Reg. Execute Retire (WB)

38 Instruction Q Cycle 1 ROB Execute Retire (WB) RAT R3R2-R3 RF1
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RF1 RF2 RB0 RF3 RF4 RS MOB ROB RB0R4/R3 Comment Valid Data Valid Data DST Execute Retire (WB)

39 Instruction Q Cycle 2 ROB Execute Retire (WB) RAT R3R2-R3 RF1
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RF1 RB0 RB1 RB1 RF3 RF4 RS MOB ROB RB0R4/R3 RB1MEM(not rdy) MobR4+50 Comment Valid Data Valid Data DST R2 R4/R3 1 xxx R2 R3MEM(r4+50) R3 Execute RB0R4/R3 (1) Retire (WB)

40 Instruction Q Cycle 3 ROB Execute Retire (WB) RAT R3R2-R3 RB2 RF1
R3MEM(R4+50) R2  R4/R3 RF4 RS MOB ROB RB1MEM(not Rdy) W MobR4+50 Comment Valid Data Valid Data DST R2 R4/R3 1 xxx R2 R3MEM(R4+50) R3 R1  R2 / R3 RB2RB0/RB1 Execute RB0  R4/R3 (1) (2) Retire (WB)

41 Instruction Q Cycle 4 ROB Execute Retire (WB) RAT R3R2-R3 R2R4+R3
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB0 RB1 RF4 RS MOB ROB RB1MEM(not rdy) RB1MEM(R4+50) W (1) RB3R4+RB1 Comment Valid Data Valid Data DST R2 R4/R3 1 xxx R2 R3MEM(R4+50) R3 R1  R2 / R3 R1 R2  R4 + R3 RB2RB0/RB1 W Mob R4+50 Execute RB0R4/R3 (2) (3) Retire (WB)

42 Instruction Q Cycle 6 Cycle 5 ROB Execute Retire (WB) RAT R3R2-R3 RB2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB4 RB1 RF4 RS MOB ROB RB1MEM(R4+50) (2) (1) RB3R4+RB1 W Comment Valid Data Valid Data DST R2 R4/R3 1 xxx R2 R3MEM(R4+50) R3 R1  R2 / R3 R1 R2  R4 + R3 R3  R2 – R3 RB2RB0/RB1 W 1 Value2 Value3 RB4RB3-RB1 Execute RB0 R4/R3 (3) (4) Retire (WB)

43 Instruction Q Cycle 6 ROB Execute Retire (WB) RAT R3R2-R3 RB2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB4 RF4 RS MOB ROB RB3R4+RB1 Comment Valid Data Valid Data DST R2 R4/R3 1 Value2 R2 R3MEM(R4+50) Value3 R3 R1  R2 / R3 xxx R1 R2  R4 + R3 R3  R2 – R3 RB2RB0/RB1 RB4RB3-RB1 W Execute Retire (WB)

44 Instruction Q Cycle 7 ROB Execute Retire (WB) RAT R3R2-R3 RB2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB4 RF4 RS MOB ROB Comment Valid Data Valid Data DST R2 R4/R3 1 Value2 R2 R3MEM(r4+50) Value3 R3 R1  R2 / R3 xxx R1 R2  R4 + R3 R3  R2 – R3 R2 RB0 R3 RB1 RB4RB3-RB1 RB3 R4+RB1 1 Value4 RB2 RB0/RB1 (1) Execute (2) Retire (WB)

45 Instruction Q Cycle 8 ROB Execute Retire (WB) RAT R3R2-R3 RB2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB4 RF4 RS MOB ROB Comment Valid Data Valid Data DST R2 R4/R3 R3MEM(R4+50) R1  R2 / R3 1 xxx R1 R2  R4 + R3 Value4 R2 R3  R2 – R3 R3 RB2 RB0/RB1 (3) Execute 1 Value5 RB4RB3-RB1 Retire (WB)

46 Instruction Q Cycle 9 ROB Execute Retire (WB) RAT R3R2-R3 RB2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB4 RF4 RS MOB ROB Comment Valid Data Valid Data DST R2 R4/R3 R3MEM(R4+50) R1  R2 / R3 1 xxx R1 R2  R4 + R3 Value4 R2 R3  R2 – R3 Value5 R3 RB2 RB0/RB1 (3) (4) Execute Retire (WB)

47 Instruction Q Cycle 10 ROB Execute Retire (WB) RAT R3R2-R3 RB2
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RB2 RB3 RB4 RF4 RS MOB ROB Comment Valid Data Valid Data DST R2 R4/R3 R3MEM(R4+50) R1  R2 / R3 1 xxx R1 R2  R4 + R3 Value4 R2 R3  R2 – R3 Value5 R3 1 Value6 RB2 RB0/RB1 (4) Execute Retire (WB)

48 Instruction Q Cycle 11 ROB Execute Retire (WB) RAT R3R2-R3 R2R4+R3
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RF4 RS MOB ROB Comment Valid Data Valid Data DST R2 R4/R3 R3MEM(R4+50) R1  R2 / R3 1 Value6 R1 R2  R4 + R3 Value4 R2 R3  R2 – R3 Value5 R3 R1RB2 R2RB3 Execute R3RB4 Retire (WB)

49 Instruction Q Cycle 12 ROB Execute Retire (WB) RAT R3R2-R3 RF1
R3MEM(R4+50) R2  R4/R3 R1 R2 R3 R4 RF1 RF2 RF3 RF4 RS MOB ROB Comment Valid Data Valid Data DST R2 R4/R3 R3MEM(R4+50) R1  R2 / R3 R2  R4 + R3 R3  R2 – R3 Execute Retire (WB)


הורד את "ppt "Out Of Order Execution (Part 1)

מצגות קשורות


מודעות Google