2 15 11 New School Machine Structures It s a bit more complicated So ware Hardware Parallel Requests Assigned to computer e g Search Katz CS 61C Great Ideas in Computer Architecture Machine Structures Parallel Threads Parallelism Assigned to core e g Lookup Ads Achieve High Performance 1 instruc on one me e g 5 pipelined instruc ons Parallel Data 1 data item one me e g Add of 4 pairs of words Hardware descrip ons All gates one me Spring 2010 Lecture 9 1 Levels of Representa on Interpreta on Compiler Assembly Language Program e g MIPS lw lw sw sw Assembler Machine Language Program MIPS t0 0 2 t1 4 2 t1 0 2 t0 4 2 0000 1010 1100 0101 1001 1111 0110 1000 1100 0101 1010 0000 2 15 11 Core Core Memory Cache Input Output Instruc on Unit s Core Func onal Unit s A0 B0 A1 B1 A2 B2 A3 B3 Main Memory Logic Gates Spring 2010 Lecture 9 3 Review Today s Lecture temp v k v k v k 1 v k 1 temp High Level Language Program e g C Today s Lecture Computer Parallel Instruc ons Instructors Randy H Katz David A PaGerson hGp inst eecs Berkeley edu cs61c fa10 2 15 11 Harness Smart Phone Warehouse Scale Computer Everything is a binary number in a computer Anything can be represented as a number i e data or instruc ons 0110 1000 1111 1001 1010 0000 0101 1100 1111 1001 1000 0110 0101 1100 0000 1010 1000 0110 1001 1111 Machine Interpreta4on Hardware Architecture DescripCon e g block diagrams Architecture Implementa4on Instruc ons and data stored program concept Assemblers can enhance machine instruc on set to help assembly language programmer Translate from text that easy for programmers to understand into code that machine executes e ciently Compilers Assemblers Linkers allow separate transla on of modules Logic Circuit DescripCon 2 15 11 Circuit SchemaCc Diagrams Spring 2010 Lecture 9 4 2 15 11 Agenda Spring 2010 Lecture 9 5 What s a Compiler Compiler a program that accepts as input a program text in a certain language and produces as output a program text in another language while preserving the meaning of that text The text must comply with the syntax rules of whichever programming language it is wriGen in A compiler s complexity depends on the syntax of the language and how much abstrac on that programming language provides Compilers Op miza on Interpreters Just In Time Compiler Administrivia Dynamic Linking Technology Trends Revisited Technology Break Components of a Computer 2 15 11 Spring 2010 Lecture 9 A C compiler is much simpler than C Compiler Compiler executes before compiled program runs 6 2 15 11 Spring 2010 Lecture 9 7 1 2 15 11 Compiled Languages Edit Compile Link Run Editor Source code Compiler gcc compiler op ons O1 the compiler tries to reduce code size and execu on me without performing any op miza ons that take a great deal of compila on me O2 Op mize even more GCC performs nearly all supported op miza ons that do not involve a space speed tradeo As compared to O this op on increases both compila on me and the performance of the generated code O3 Op mize yet more All O2 op miza ons and also turns on the nline func ons Object code Linker Editor Source code Compiler Object code Editor Source code Compiler Object code 2 15 11 Compiler Op miza on Executable program Spring 2010 Lecture 9 2 8 What is Typical Bene t of Compiler Op miza on What is a typical program For now try a toy program BubbleSort c 2 15 11 10 L3 addu 2 3 2 lw 2 80016 sp lw 4 80020 sp slt 3 2 20000 addu 3 4 1 bne 3 0 L6 move 4 3 j L4 sll 3 4 2 L6 addu 4 sp 16 set noreorder addu 3 4 3 nop lw 2 0 2 set reorder lw 3 0 3 sw 0 80020 sp slt 2 3 2 L7 beq 2 0 L9 lw 2 80020 sp lw 3 80020 sp slt 3 2 19999 addu 2 3 1 bne 3 0 L10 move 3 2 j L5 sll 2 3 2 L10 addu 3 sp 16 lw 2 80020 sp addu 2 3 2 move 3 2 lw 3 0 2 sll 2 3 2 addu 3 sp 16 2 15 11 O2 op mized MIPS Code addu 6 8 2 addu 7 3 1 sll 2 7 2 addu 5 8 2 lw 3 0 6 lw 4 0 5 2 15 11 9 lw 3 80020 sp addu 2 3 1 move 3 2 sll 2 3 2 addu 3 sp 16 addu 2 3 2 lw 3 80020 sp move 4 3 sll 3 4 2 addu 4 sp 16 addu 3 4 3 lw 4 0 3 sw 4 0 2 lw 2 80020 sp move 3 2 sll 2 3 2 addu 3 sp 16 addu 2 3 2 sw 3 80024 sp lw 3 80024 sp sw 3 0 2 Spring 2010 Lecture 9 L11 L9 lw 2 80020 sp addu 3 2 1 sw 3 80020 sp j L7 L8 L5 lw 2 80016 sp addu 3 2 1 sw 3 80016 sp j L3 L4 L2 li 12 65536 ori 12 12 0x38b0 addu 13 12 sp addu sp sp 12 11 j 31 What s an Interpreter li 13 65536 slt 2 4 3 ori 13 13 0x3890 beq 2 0 L9 addu 13 13 sp sw 3 0 5 sw 28 0 13 sw 4 0 6 move 4 0 L9 addu 8 sp 16 move 3 7 L6 move 3 0 addu 9 4 1 p2align 3 L10 sll 2 3 2 Spring 2010 Lecture 9 Unop mized MIPS Code de ne ARRAY SIZE 20000 int main int iarray ARRAY SIZE x y holder for x 0 x ARRAY SIZE x for y 0 y ARRAY SIZE 1 y if iarray y iarray y 1 holder iarray y 1 iarray y 1 iarray y iarray y holder Spring 2010 Lecture 9 2 15 11 It reads and executes source statements executed one at a me No linking No machine code genera on so more portable slt 2 3 19999 bne 2 0 L10 move 4 9 slt 2 4 20000 bne 2 0 L6 li 12 65536 Start execu ng quicker but run much more slowly than compiled code Performing the ac ons straight from the text allows beGer error checking and repor ng to be done The interpreter stays around during execu on ori 12 12 0x38a0 addu 13 12 sp addu sp sp 12 j 31 Spring 2010 Lecture 9 Unlike compiler some work is done a er program starts Wri ng an interpreter is much less work than wri ng a compiler 12 2 15 11 Spring 2010 Lecture 9 13 2 2 15 11 Compiler vs Interpreter Advantages Interpreted Languages Edit Run Editor Source code 2 15 11 Interpreter Compilation Faster Execu on Single le to execute …
View Full Document
Unlocking...