Upload
edmund-evans
View
246
Download
4
Embed Size (px)
Citation preview
כיתה כיתה תרגיל 77תרגיל
מחשב לטכנולוגיות מחשב מבוא לטכנולוגיות מבוא
CPE CPE
– 2 –
ארכיטקטורה של מעבד מודרני
ארכיטקטורה של מעבד מודרני
ExecutionExecution
FunctionalUnits
Instruction ControlInstruction Control
Integer/Branch
FPAdd
FPMult/Div
Load Store
InstructionCache
DataCache
FetchControl
InstructionDecode
Address
Instrs.
Operations
PredictionOK?
DataData
Addr. Addr.
GeneralInteger
Operation Results
RetirementUnit
RegisterFile
RegisterUpdates
Control Unit (CU)
Arithmetic Logic Unit
(ALU)
– 3 –
Pentium IIIהיכולות של Pentium IIIהיכולות של :ניתן להריץ במקביל:ניתן להריץ במקביל
1 load 1 store 2 integer (one may be branch) 1 FP Addition 1 FP Multiplication or Division
Some Instructions Take > 1 Cycle, but Can be Some Instructions Take > 1 Cycle, but Can be PipelinedPipelined
Instruction Latency Cycles/Issue Load / Store 3 1 Integer add 1 1 Integer Multiply 4 1 Integer Divide 36 36
חלקים שונים של אותה פקודה מבוצעים על ידי רכיבים שונים. לכן ניתן לבצע מספר רכיבים של פקודות שונות בו זמנית.
– 4 –
לחישוב איברים– CPEדוגמאות מכפלת לחישוב איברים– CPEדוגמאות מכפלת
– 5 –
גרף CPEשרטוט גרף CPEשרטוט
CPE = 4
משאבים מגבלת ללא
– 6 –
לולאה לולאה פריסת פריסת
- ה פונקציה - באיזו ה פונקציה קטן CPECPEבאיזו יהיה מכפלה חישוב קטן עבור יהיה מכפלה חישוב עבוריותר:יותר:
int funca(int* a, int size) {int funca(int* a, int size) {int result = 1;int result = 1;for (int i=0; i < size; i+=2) {for (int i=0; i < size; i+=2) {
result = result * a[i];result = result * a[i];result = result * a[i+1];result = result * a[i+1];
}}return result;return result;
}}
int funcb(int* a, int size) {int funcb(int* a, int size) {int result1 = 1;int result1 = 1;int result2 = 1;int result2 = 1;for (int i=0; i < size; i+=2) {for (int i=0; i < size; i+=2) {
result1 = result1 * a[i];result1 = result1 * a[i];result2 = result2 * a[i+1];result2 = result2 * a[i+1];
}}return result1*result2;return result1*result2;
} }
- מ מורידה לולאה פריסת של זו CPE=4צורה
– 7 –
איברים איברים סכימת סכימת
CPE = 1
– 8 –
CPE = 2
משאבים מגבלת תחת איברים משאבים סכימת מגבלת תחת איברים סכימת
– 9 –
- ו - CPEפריסה ו CPEפריסה
- ל החיבור לולאת את - נפרוס ל החיבור לולאת את ::33נפרוס
– 10 –
חיבור של חיבור פריסה של פריסה
CPE = 1
– 11 –
פריסה פריסה תוצאות תוצאות
– 12 –
תרגילתרגיל
: הבא הקוד :נתון הבא הקוד נתון
int inner_product (int * u, int * v, int n)int inner_product (int * u, int * v, int n)
{{
int i;int i;
int res=0;int res=0;
for ( i=1 ; i<n ; i++ )for ( i=1 ; i<n ; i++ )
{{
res = res + u[i]*v[i];res = res + u[i]*v[i];
}}
return res;return res;
}}
– 13 –
תרגילתרגיל
- מכונה לשפת נתרגם ראשון מכונה - שלב לשפת נתרגם ראשון שלב
int inner_product (int * u, int * v, int n)int inner_product (int * u, int * v, int n)
{{
int i;int i;
int res=0;int res=0;
for ( i=1 ; i<n ; i++ )for ( i=1 ; i<n ; i++ )
{{
res = res + u[i]*v[i];res = res + u[i]*v[i];
}}
return res;return res;
}}
Assembly:Assembly:
move 8(R8), R3move 8(R8), R3
move 12(R8), R2move 12(R8), R2
move 16(R8), R6move 16(R8), R6
.loop:.loop:
move (R2,R4,4),R5move (R2,R4,4),R5
multiply (R3,R4,4),R5multiply (R3,R4,4),R5
add R5,R1 add R5,R1
increment R4increment R4
compare R6,R4compare R6,R4
jl .loopjl .loop
– 14 –
תרגילתרגיל
? מריץ - המחשב באמת מה שני ? שלב מריץ - המחשב באמת מה שני שלב
Assembly:Assembly:
.loop:.loop:
move (R2,R4,4),R5move (R2,R4,4),R5
multiply (R3,R4,4),R5multiply (R3,R4,4),R5
add R5,R1 add R5,R1
increment R4increment R4
compare R6,R4compare R6,R4
jl .loopjl .loop
– 15 –
תרגילתרגיל
load
load
R4.0
mul
R5.1t.1
addR5.1R1.0
R1.1
inc
cmpR4.1
jmpcc.1
– 16 –
load
load
R4.0
mul
R5.1t.1
addR5.1
R1.0
R1.1
inc
cmp
R4.1
jmpcc.1
load
load
mul
R5.2t.2
addR5.2
R1.2
inc
cmpR4.2
jmpcc.2