Review of Basic Computer Architecture

Similar documents
Review of Basic. Computer Architecture. Theory Goals Specification

From CISC to RISC. CISC Creates the Anti CISC Revolution. RISC "Philosophy" CISC Limitations

Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier

Assembler. Building a Modern Computer From First Principles.

Virtual Memory. Background. No. 10. Virtual Memory: concept. Logical Memory Space (review) Demand Paging(1) Virtual Memory

Performance Evaluation

Motivation. EE 457 Unit 4. Throughput vs. Latency. Performance Depends on View Point?! Computer System Performance. An individual user wants to:

Memory and I/O Organization

Conditional Speculative Decimal Addition*

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Assembler. Shimon Schocken. Spring Elements of Computing Systems 1 Assembler (Ch. 6) Compiler. abstract interface.

Chapter 2 Instruction Set Architecture (ISA)

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Lobachevsky State University of Nizhni Novgorod. Polyhedron. Quick Start Guide

ELEC 377 Operating Systems. Week 6 Class 3

Harvard University CS 101 Fall 2005, Shimon Schocken. Assembler. Elements of Computing Systems 1 Assembler (Ch. 6)

5.1 The ISR: Overvieui. chapter

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Minimizing Data hazard Stalls by Forwarding Data Hazard Classification Data Hazards Present in Current MIPS Pipeline

NUMERICAL SOLVING OPTIMAL CONTROL PROBLEMS BY THE METHOD OF VARIATIONS

Instruction Set Architecture (ISA)

Load Balancing for Hex-Cell Interconnection Network

High level vs Low Level. What is a Computer Program? What does gcc do for you? Program = Instructions + Data. Basic Computer Organization

Outline. Digital Systems. C.2: Gates, Truth Tables and Logic Equations. Truth Tables. Logic Gates 9/8/2011

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Cache Memories. Lecture 14 Cache Memories. Inserting an L1 Cache Between the CPU and Main Memory. General Org of a Cache Memory

Lecture 4: Instruction Set Architecture

EITF20: Computer Architecture Part2.2.1: Pipeline-1

MIPS Pipelining. Computer Organization Architectures for Embedded Computing. Wednesday 8 October 14

Nachos Project 3. Speaker: Sheng-Wei Cheng 2010/12/16

AADL : about scheduling analysis

Parallelism for Nested Loops with Non-uniform and Flow Dependences

Appendix C: Pipelining: Basic and Intermediate Concepts

Instruction Level Parallelism. Appendix C and Chapter 3, HP5e

Instruction Pipelining Review

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Advanced Computer Architecture

Data Representation in Digital Design, a Single Conversion Equation and a Formal Languages Approach

ETAtouch RESTful Webservices

Problem Definitions and Evaluation Criteria for Computational Expensive Optimization

4/11/17. Agenda. Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Storage Management.

Uniprocessors. HPC Fall 2012 Prof. Robert van Engelen

Instr. execution impl. view

Speeding Up DLX Computer Architecture Hadassah College Spring 2018 Speeding Up DLX Dr. Martin Land

COMPUTER ORGANIZATION AND DESI

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Cache Performance 3/28/17. Agenda. Cache Abstraction and Metrics. Direct-Mapped Cache: Placement and Access

Predict Not Taken. Revisiting Branch Hazard Solutions. Filling the delay slot (e.g., in the compiler) Delayed Branch

Efficient Distributed File System (EDFS)

The Codesign Challenge

Pipelining concepts The DLX architecture A simple DLX pipeline Pipeline Hazards and Solution to overcome

Instruction Set Principles and Examples. Appendix B

Instruction Level Parallelism. ILP, Loop level Parallelism Dependences, Hazards Speculation, Branch prediction

The Processor: Instruction-Level Parallelism

Instruction Pipelining

A Model RISC Processor. DLX Architecture

Instruction Pipelining

CISC 662 Graduate Computer Architecture Lecture 13 - CPI < 1

Optimizing for Speed. What is the potential gain? What can go Wrong? A Simple Example. Erik Hagersten Uppsala University, Sweden

Mathematics 256 a course in differential equations for engineering students

Execution/Effective address

Parallel matrix-vector multiplication

Cluster Analysis of Electrical Behavior

Pipelining concepts The DLX architecture A simple DLX pipeline Pipeline Hazards and Solution to overcome

News. Recap: While Loop Example. Reading. Recap: Do Loop Example. Recap: For Loop Example

Advanced d Instruction Level Parallelism. Computer Systems Laboratory Sungkyunkwan University

Specifications in 2001

Giving credit where credit is due

There are different characteristics for exceptions. They are as follows:

CPU Architecture and Instruction Sets Chapter 1

CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar

Verification by testing

COSC4201 Pipelining. Prof. Mokhtar Aboelaze York University

Oracle Database: SQL and PL/SQL Fundamentals Certification Course

Programming in Fortran 90 : 2017/2018

3D vector computer graphics

Computer Architecture

Pipelining. CS701 High Performance Computing

Processor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

IP Camera Configuration Software Instruction Manual

Introduction to Programming. Lecture 13: Container data structures. Container data structures. Topics for this lecture. A basic issue with containers

Storage Binding in RTL synthesis

An Optimal Algorithm for Prufer Codes *

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

These actions may use different parts of the CPU. Pipelining is when the parts run simultaneously on different instructions.

What is Good Performance. Benchmark at Home and Office. Benchmark at Home and Office. Program with 2 threads Home program.

Lecture 7: Pipelining Contd. More pipelining complications: Interrupts and Exceptions

CMPS 10 Introduction to Computer Science Lecture Notes

EC 513 Computer Architecture

Multiple Issue ILP Processors. Summary of discussions

Chapter 2: Instructions How we talk to the computer

RISC & Superscalar. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 12. Instruction Pipeline no hazard.

COSC 6385 Computer Architecture. Instruction Set Architectures

Advanced Parallel Architecture Lessons 5 and 6. Annalisa Massini /2017

Multi-cycle Instructions in the Pipeline (Floating Point)

INSTRUCTION LEVEL PARALLELISM

Processor Architecture

William Stallings Computer Organization and Architecture. Chapter 11 CPU Structure and Function

If you miss a key. Chapter 6: Demand Paging Source:

Reminder: tutorials start next week!

Transcription:

of Basc Computer Archtecture 1

Computer Archtecture What s Computer Archtecture From Wkpeda, the free encyclopeda In computer scence and engneerng, computer archtecture refers to specfcaton of the relatonshp between dfferent hardware components of a computer system. It may also refer to the practcal art of defnng the structure and relatonshp of the subcomponents of a computer. Ths artcle needs attenton from an expert n computer scence. 2

Computer Archtecture What s Computer Archtecture Defnton 2.0 In computer scence and engneerng, computer archtecture refers to the study of performance n computer systems. It also refers to the practcal scence of applyng performance theory to specfyng the structure and relatonshp of the subcomponents of a computer. From an expert n computer scence. 3

Theory Goals Specfcaton Theory Computaton components CPU: ALU + memory + control Instructons Performance = run-tme speed Run-tme of what? Compared to what? von Neumann Archtecture nput memory output Arthmetc Logc Unt (ALU) Requrements Word processng Number crunchng Gamng Web server Real tme controller data/nstructon path control path Specfcaton Requrements + performance theory component mplementaton 4

Requrements Relatve to Applcaton Fastest CPU Intel Xeon Gold Hgh-end verson of Intel x86-64 processor famly IA-32 nstructon set on enhanced P6 mcro-archtecture Netburst Ivy Brdge Haswell Broadwell Skylake Pentum II Pentum III Pentum 4 Multcore Fastest supercomputer IBM Summt 4,608 compute nodes 2 Power9 22-core CPUs 6 NVIDIA Tesla V100 GPUs (graphcs processng unt) 202,752 CPU cores + 27,648 GPUs 10 PB memory = 10 Mega GB (10,000 TB) Energy effcent 13.889 GFlops/watt Smartphones ARM CPU Low power Hgher performance / Watt than x86 5

Fundamental Archtectural Abstractons Dgtal computer Machne that can be programmed to process symbols Data Symbol wth no ntrnsc meanng to machne User mposes meanng Integer, float, strng,... Operaton Symbol descrbng processng of data symbols Machne nterprets meanng transfer, ALU, control, OS,... Instructon Symbol descrbng operaton on data Machne language = collecton of legal nstructons Addressng Mode Specfes data locaton as operand Source operand data nput to operaton Destnaton operand data output from operaton 6

Stages n Computer Desgn Instructon Set Archtecture (ISA) 1. Defne unverse of problems to be solved 2. Study canddate operatons at level of system programmer Atomc operatons complete sequentally General operaton = combnaton of atomc operatons 3. Specfy nstructon set for machne language Choose mnmum set of orthogonal operatons Not too many ways to solve same problem Implementaton 1. Desgn machne as mplementaton of ISA 2. Evaluate theoretcal performance 3. Identfy performance problem areas 4. Improve processor effcency 7

Typcal Operatons Data transfer Load (r m), store (m r), move (r/m r/m), convert data types Arthmetc/Logcal (ALU) Integer arthmetc (+ compare shft) and logcal (AND, OR, NOR, XOR) Decmal Integer arthmetc on decmal numbers Floatng pont (FPU) Floatng pont arthmetc (+ sqrt trg exp ) Strng Strng move, strng compare, strng search Control Condtonal and uncondtonal branch, call/return, trap Operatng System System calls, vrtual memory management nstructons Graphcs Pxel operatons, compresson/decompresson operatons 8

Memory Herarchy Memory locatons outsde CPU and RAM Memory locaton outsde CPU Memory locaton n or near CPU Memory locaton nsde CPU Stores data and nstructons of "all" programs Stores "all" data and nstructons of runnng programs Fast access to mportant data and nstructons from RAM Fast access to small amount of nformaton Organzed by OS Organzed by addresses Copy of RAM secton Organzed by CPU Long Term Storage Man Memory (RAM) Cache Regster All Fles and Data Runnng Programs and Data Next Few Instructons and Data Current Data 9

CPU and Memory Herarchy CPU controller accesses L1 cache f (L1 cache ht) {access performed n 1 clock cycle} else { CPU L1 cache mss L1 cache accesses cache controller cache controller ntates access to L2 and man memory f (address n L2 cache) {controller copes contents to L1 from L2} else {controller copes locaton to L1 from man memory} } ALU Regsters L1 nstructons L1 data cache controller L2 I/O Dsk Man Memory access n 1 CC request update access latency >> 1 clock cycle Cache mss penalty Address not n L1 delay n memory access 10

Specfyng Operands Immedate Constant = IMM = numercal value coded nto nstructon Regster operands regster name = a CPU storage locaton REGS[regster name] = data stored n regster REGS[R3] = data stored n regster R3 = 11223340 R3 11223340 Memory operands address = a memory storage locaton MEM[address] = data stored n memory MEM[11223344] = data stored at address 11223344 = 45 11223344 Effectve Address (EA) ponter arthmetc REGS[R3] &(varable) MEM[REGS[R3]+4] = *(&(varable)+4) = *(REGS[R3]+4) = *(11223340+4) = 45 45 11

Addressng Modes Mode Syntax Memory Access Use Regster R3 Regs[R3] Regster data Immedate #3 3 Constant Drect (absolute) Regster deferred (1001) Mem[1001] Statc data (R1) Mem[Regs[R1]] Ponter Dsplacement 100(R1) Mem[100+Regs[R1]] Local varable Indexed (R1 + R2) Mem[Regs[R1]+Regs[R2]] Array addressng Memory ndrect Auto Increment Auto Decrement @(R3) Mem[Mem[Regs[R3]]] Ponter to ponter (R2)+ -(R2) Mem[Regs[R2]] Regs[R2] Regs[R2]+d Regs[R2] Regs[R2]-d Mem[Regs[R2]] Stack access Stack access Scaled 100(R2)[R3] Mem[100+Regs[R2]+Regs[R3]*d] Indexng arrays PC-relatve (PC) Mem[PC+value] PC-relatve deferred 1001(PC) Mem[PC+Mem[1001]] Load nstructon to data regster Load nstructon to data regster 12

Commtment to State Internal regsters Temporary regsters used n executng machne nstructons Not vsble to programs Archtectural state CPU regsters vsble to programs System state All data resources vsble to programs Archtectural state + system memory Commtment to state Update of system state Wrte to archtectural state / system memory 13

Complex Instructon Set Computer (CISC) Classc Machne Desgn 300 nstructon types 15 addressng modes 10 data types Complex machne mplementatons Manframes (1955 2000) Large, expensve, centralzed computers for bg busness and government Manufacturers: IBM, Control Data, Burrows, Honeywell Mncomputers (1965 1990) Smaller computers for smaller organzatons Manufacturers: Dgtal (PDP/VAX), Data General (Eclpse) CISC mcroprocessors (1979 1996) 6800 (1974) and 8086 (1978) desgned as tny CISC on chp Apple II (1977) 6502 (1975) IBM PC (1981) 8088 (1979) Intel x86 for PC/Mac = last CISC ISA stll manufactured. 14

Why CISC? Semantc Gap Argument Computer language should mtate natural language Large vocabulary + hgh redundancy flexblty + power Terrble complers Lmted optmzaton Lmted error messagng Effcent code wrtten or optmzed n assembly language Expensve memory RAM ~ $5000/MB wholesale n 1977 RAM ~ $0.01/MB n 2012 Implcatons for machne language Desgn for user-frendly programmng and small memory use Many hghly specfc nstructons usng many addressng modes Compact nstructon codes that perform a lot of work 15

Physcal Implementaton of CISC Generc Machne ALU Subsystem 1 Regsters IN 2 3 OUT ALU Operaton ALU Result Flag System Bus Status Word Decoder IR PC + control MAR MDR PC - program counter MAR - memory address regster Address Data IR - nstructon regster MDR - memory data regster Man Memory 16

Decodng Machne Instructons Machne Language Instructon SUB R1, R2, 100(R3) Mcrocode Instructon Sequence (Mcroprogram) ALU_IN R3 Mcrocode nstructon ALU 100 Hardware level atomc operaton ADD 9 lnes = 9 clock cycles MAR OUT READ 1 ALU_IN MDR Regsters IN 2 ALU R2 ALU Operaton SUB ALU Result Flag System Bus R1 OUT ALU Subsystem 3 OUT Status Word Decoder IR PC + control MAR MDR PC - program counter IR - nstructon regster MAR - memory address regster MDR - memory data regster Address Data Man Memory 17

Run Tme and Clock Cycles CPU s tmed by perodc sgnal called clock (CLK) clock cycle Clock Cycle (CC) tme = seconds per cycle Instructon requres 1 or more clock cycles to process Clock Rate = cycles per second = Hz (Hertz) Run tme = clock cycles to run program seconds per clock cycles clock cycles to run program = clock cycles per second Hgher clock rate shorter run tme More clock cycles (at constant clock rate) longer run tme 18

Intel 386 Mcroprocessor 19

Basc Performance Measures Run Tme Elapsed tme T from start to fnsh of a defned program task Latency Excess response tme depends on context Throughput Number of defned tasks performed per unt tme 1 Throughput = T + latency between tasks Enhancement Change to system new run tme T ' Speedup T S = S > 1 T' < T T ' 20

Defntons T = t = IC = CPI = N = τ = R total run tme of program total run tme of nstructons n group number of nstructons n group ( Instructon Count) number of clock cycles to run 1 nstructon n group number of clock cycles to run all nstructons n group seconds per clock cycle ( C ycles Per = clock rate = clock frequency = clock cycles per second = Hertz (Hz) = IC = N = CPI = quantty ' = total number of nstructons n program total number of clock cycles to run program average number of clock cycles per nstructon for the program new value of quantty after archtectural change Instructon) 1 τ 21

CPU Equaton Clock cycles to run all nstructons of type clock cycles N = nstructons of type = IC CPI nstructon of type Total clock cycles to run all nstructons n program = = N N IC CPI all groups Average number of clock cycles per nstructon for program total number of clock cycles to run program N CPI = = total number of nstructons n program IC 1 1 IC CPI = N = IC CPI = CPI IC IC IC weghted average IC = 1 IC Rato IC IC s proporton (percent) of nstructons n group 22

CPU Run Tme Run tme of one nstructon of type clock cycles nstructon of type seconds clock cycle = CPI τ Run tme for all nstructons of type t = nstructons of type = IC CPI τ Total run tme for program So clock cycles nstructon of type seconds clock cycle IC = = = τ T t CPI IC τ CPI IC all groups IC T = CPI IC τ = clock cycles per nstructon number of nstructons clock cycle 23

Amdahl Equaton F S S t = = T t = = t ' relatve run tme of nstructons n group speedup for nstructons n group t t FT F T 1 = = = = = = T' t ' t F F F T S S S S Enhancement to group e S 1 1 = = 1 F F F + 1 Fe + S S S e e e e e e Amdahl's "Law" Speedup lmted by 1 F e Enhance maxmum F e Accept mparment to small 1 F e 24

Amdahl Equaton n Parallel Processng CPI F P n processors n= 1 CPI = P n n= 1 + CPI P work can be parallelzed ( ) work cannot be parallelzed ( ) n= 1 CPI n= 1 = F ( 1 ) P + CPI FP n = Fracton of processng that can be performed ndependently n = Number of processng unts S n= 1 n= 1 CPI IC τ CPI = = = τ n processors n processors CPI IC CPI 1 1 F + ( ) P F n P 25

SPEC Benchmark Programs for system performance measurement + comparson Standard + repeatable Test system for realstc condtons Summary score for easy comparson Results posted at http://www.spec.org/ Specfc test sutes Cnt CPU nteger nstructons Cfp CPU FP nstructons Performance as fle server, web server, mal server, graphcs Updated every few years to reflect realstc condtons Based on current statstcal dstrbutons of computng tasks Current CPU test verson 2017 Prevous verson 2006 Reports speedup Run tme compared wth a standard machne 26

How SPEC Works User runs n programs on test machne Records run-tme condtons test T, = 1,2,..., n Records program run-tme n seconds SPEC provdes run-tmes on reference machne Sun Fre V490 ref T 2100 MHz UltraSPARC-IV+ processor Powerful symmetrc multprocessng (SMP) server (2006 2014) User calculates speedup for each program S =, = 1, 2,..., n User calculates geometrc mean of speedups T T S ( test machne on ref) = = 1 ref test S ( machne A compared to machne B) n T T ref test 1 n = S ( machne A on ref) S ( machne B on ref) 27

Typcal SPEC Report 1 SPEC(R) CPU2017 Integer Speed Result ASUSTeK Computer Inc. ASUS RS700-E9(Z11PP-D24) Server System (2.70 GHz, Intel Xeon Gold 6150) CPU2017 Lcense: 9016 Test date: Dec-2017 Test sponsor: ASUSTeK Computer Inc. Hardware avalablty: Jul-2017 Tested by: ASUSTeK Computer Inc. Software avalablty: Sep-2017 Base Base Base Peak Peak Peak Benchmarks Thrds Run Tme Rato Thrds Run Tme Rato -------------- ------ --------- --------- ------ --------- --------- 600.perlbench_s 72 286 6.22 72 239 7.42 602.gcc_s 72 423 9.42 72 413 9.65 605.mcf_s 72 426 11.1 72 421 11.2 620.omnetpp_s 72 257 6.35 72 248 6.58 623.xalancbmk_s 72 150 9.46 72 140 10.1 625.x264_s 72 150 11.8 72 150 11.8 631.deepsjeng_s 72 280 5.11 72 282 5.08 641.leela_s 72 393 4.34 72 392 4.36 648.exchange2_s 72 220 13.4 72 220 13.4 657.xz_s 72 280 22.1 72 277 22.3 SPECspeed2017_nt_base 8.87 SPECspeed2017_nt_peak 9.16 Base = standard confguraton Peak = specalst confguraton 28

Typcal SPEC Report 2 HARDWARE -------- CPU Name: Intel Xeon Gold 6150 Max MHz.: 3700 Nomnal: 2700 Enabled: 36 cores, 2 chps Orderable: 1, 2 chp(s) Cache L1: 32 KB I + 32 KB D on chp per core L2: 1 MB I+D on chp per core L3: 24.75 MB I+D on chp per chp Other: None Memory: 768 GB (24 x 32 GB 2Rx4 PC4-2666V-R) Storage: 1 x 240 GB SATA SSD Other: None SOFTWARE -------- OS: Red Hat Enterprse Lnux Server release 7.3 (x86_64) Kernel 3.10.0-514.el7.x86_64 Compler: C/C++: Verson 18.0.0.128 of Intel C/C++ Compler; Fortran: Verson 18.0.0.128 of Intel Fortran Compler Parallel: Yes Frmware: Verson 0601 released Oct-2017 Fle System: xfs System State: Run level 3 (mult-user) Base Ponters: 64-bt Peak Ponters: 32/64-bt Other: jemalloc: jemalloc memory allocator lbrary V5.0.1 29

Some Cnt2017 Results Processor Clock (GHz) Total Chps Total Cores Total Threads Cnt 2017 Base Cnt 2006 Base Rato Intel Xeon Gold 6146 3.2 2 24 24 10.1 83.0 8.21 Intel Xeon Gold 6146 3.2 4 48 48 9.95 85.7 8.61 Intel Xeon Platnum 8153 2.0 4 64 64 7.00 62.8 8.97 Intel Xeon Bronze 3104 1.7 2 12 12 4.20 68.5 16.31 Intel Xeon Platnum 8180 Intel Core 2 Duo E6850 wth auto parallel Intel Core 2 Duo E6850 wth no auto parallel 2.5 8 224 224 9.37 81.6 8.71 3.0 1 2 2 19.9 3.0 1 2 1 18.7 30

Some Comments on Cnt2017 Results Auto parallel Hgh level Cnt code not threaded for parallel processng Auto parallel compler creates parallel threads usng heurstcs Provdes lmted speed up (or even degradaton) All CPU results n table use auto parallel except last Intel Xeon Gold 6146 wth 3.2 GHz clock Fastest CPU n Cnt2017 tests 2 chps (24 threads) slghtly faster than 4 chps (48 threads) Communcaton between more threads can slow processng 4 chps faster on Cnt2006 (usng dfferent benchmark programs) Intel Xeon Platnum 8152 wth 2.0 GHz clock Cnt wth 64 threads = 7.00 Wth 3.2 GHz clock, expect Cnt = 7 x 3.2 GHz / 2.0 GHz = 11.2 Not much better than Gold 6146 wth 24 threads Core Duo E6850 old processor not tested on Cnt2017 Cnt2006 wth 1 threads (no auto parallel) = 18.7 Cnt2006 wth 2 threads (auto parallel) = 19.9 = 6% speed up 31

Benchmarkng a Processor Desgn Specfy Instructon Set Archtecture (ISA) Specfes machne language for proposed CPU Provdes human-readable assembly language Determnes CPI for each nstructon group Count clock cycles requred to mplement each nstructon n ISA Wrte complers for proposed machne language C, C++, Fortran Comple benchmark programs to machne language Programs from SPEC CINT and CFP Analyze compler output (executable programs) Sort machne nstructons nto groups Calculate relatve nstructon count IC /IC for each group Calculate average CPI and overall run tme T Compare run tme wth reference machne 32

CISC Creates Ant CISC Revoluton 1974 1977 Data General ntroduces Eclpse 32-bt CISC mncomputer Dgtal (DEC) ntroduces VAX 32-bt CISC mncomputer Frst serous nexpensve competton to manframe computers 1977 1990 Serous computers became avalable to small organzatons UNIX developed as mncomputer operatng system TCP/IP developed to support networks of mncomputers Computer Scence emerged as separate academc dscplne Students needed topcs for projects, theses, dssertatons 1980 1990 Research results on mncomputer performance CISC uses machne resources neffcently Most machne nstructons are rarely used n programs CISC machnes run slowly to support unnecessary features 33

RISC "Phlosophy" Technologcal developments from 1975 to 1990 Prce of RAM drops from $5000 / MByte (1975) to $5 / MByte (1990) Complers become powerful and effcent wth extensve optmzaton Portable code made practcal by mncomputer, Unx, C, and TCP/IP Prncpal research results on CISC performance ~ 90% of run tme devoted to ~ 10% of nstructon set ~ 90% of nstructons n ISA rarely used Reduced Instructon Set Computer (RISC) Apply Amdahl's "Law" CISC ISA Speed up operatons accountng for most of run tme Ignore mparments to other nstructons RISC ISA only most mportant CISC nstructons Other CISC nstructons = multple RISC nstructons RISC mplementaton executes ts ISA n fast dedcated hardware 34

Instructon Types Representatve nstructon dstrbuton Fve programs from SPECnt92 benchmark sute Comple for x86 nstructon set (ISA for Intel 386/486/Pentum) Instructon Relatve Proporton of Total Run Tme Load 22% Condtonal branch 20% Compare 16% Store 12% Add 8% And 6% Sub 5% Move reg-reg 4% Call 1% Return 1% Other 5% Total 100% Frst 10 nstructons account for 95% of run tme Amdahl's "Law" Fast mplementaton of 95% Other 5% wll not serously degrade performance Must nclude uncondtonal branch for completeness Ref: Hennessy / Patterson, fgure 2.11 35

RISC Mcroprocessors Smpler ISA Small set of unform length machne nstructons Smpler hardware No mcrocode standard nstructon mplementaton No central system bus CPU process several nstructons at once Lower CPI + hgher clock speed Instructon completes on (almost) every clock cycle All processors today use RISC technology Pure RISC (PowerPC, Sparc, MIPS, ARM, ) RISC technology for CISC language (Pentum II 4, Centrno, Core) Explctly parallel RISC (Intel Itanum, IBM manframes) 36

Typcal RISC ISA Data types 32-bt / 64-bt nteger and floatng pont Flat memory model wth 32-bt / 64-bt address Address mode: dsp(rn) ~ Mem[Regs[Rn] + dsp] Regster-regster operaton model 32 128 nteger regsters + 32 128 FP regsters OS (kernel mode) regsters Result flags Read-only (value = 0) and wrte-only (null) regsters Instructon types Load, store, move regster-regster Integer add, sub, mult, dv, shft, compare Boolean and, or, xor Floatng pont add, sub, mult, dv, sqrt, compare Jump, jump regster, jump and lnk, condtonal branch 37

Typcal Instructon Encodng Instructon types for Alpha 64-bt RISC processor 31 26 25 21 20 16 15 5 4 0 Opcode Number PALcode type Opcode Ra Dsp Branch type Opcode Ra Rb Dsp Memory type Opcode Ra Rb Functon Rc Operate type Opcode (6 bts) dentfes operaton to CPU Ra, Rb (5 bts) dentfy regster names (R0 to R32) PALcode (Prvleged Archtecture Lbrary) hardware support for OS Branch test Ra, true Ra PC, PC PC + Dsp Memory move between Ra and Mem[Regs[Rb] + Dsp] Operate R/R Rc Ra functon Rb (regster name) Operate R/I Rc Ra functon Imm (n Rb and 3 bts of functon) 38

Smple RISC Physcal Implementaton Stage 1 Stage 2 Stage 3 Stage 4 Instructon Fetch Instructon Decode Execute Data Memory Access Wrte Back Address Instructon Address Data Instructon Memory Early PowerPC mplementaton Data Memory Wrte No system bus nstructons proceed from left to rght (assembly lne) Separate cache memory for nstructons and data Smple repettve operatons 1. Fetch unform-length nstructons 2. Instructon decode read source operands from regsters 3. Execute ALU nstructons and calculate addresses 4. Access memory and/or wrte destnaton operands (commt to state) One CC per stage per nstructon 4 clock cycles per nstructon 39

Ppelnng The RISC Advantage Instructon Level Parallelsm (ILP) Hardware starts second nstructon before frst completes Typcally 4 nstructons n varous stages of executon at one tme Stage 1 Stage 2 Stage 3 Stage 4 Instructon Fetch Instructon Decode Execute Data Memory Access Wrte Back Address Instructon Address Data Instructon Memory Data Memory Wrte CC Stage 1 Stage 2 Stage 3 Stage 4 1 I 1 2 I 2 I 1 3 I 3 I 2 I 1 4 I 4 I 3 I 2 I 1 5 I 5 I 4 I 3 I 2 6 I 6 I 5 I 4 I 3 40

Instructon Orented Vew Clock Cycles Instructons 1 2 3 4 5 6 I 1 IF ID EX W I 2 I 3 I 4 IF ID EX W IF ID EX W IF ID EX IF ID Instructon Fetch Instructon Decode I 5 IF ID EX Execute I 6 IF W Wrte N CPI deal = IC+ (ppelne length 1) deal N = IC IC + ( ppelne length 1) ppelne length 1 = = 1+ 1 IC large IC IC nstructons T = CPI IC τ IC τ = IC large clock rate deal 41

Ppelne Imbalance Stage 1 Stage 2 Stage 3 Stage 4 Instructon Fetch Instructon Decode Execute Data Memory Access Wrte Back Address Instructon Address Data Instructon Memory Data Memory Wrte Instructon executes n 4 clock cycles Clock cycle tme determned by LOAD nstructon Longest executon tme τ τ τ τ τ =τ fetch decode execute memory access regster wrte-back mnmum τ >τ +τ 2 τ clock cycle memory access regster wrte-back mnmum Most nstructons do not access data memory n stage 4 Only LOAD and STORE access data memory Only LOAD performs both memory access and regster wrte-back Most operatons can complete n tme τ mnmum 42

Superppelnng Stage 1 IF Stage 2 ID Stage 3 EX Stage 4 MEM Stage 5 WB Instructon Fetch Instructon Decode Execute Data Memory Access Wrte Back Address Instructon Address Data Instructon Memory Data Memory Dvde stage 4 nto two stages Only load/store do useful work n MEM Stage Dvde clock cycle tme (double clock rate) τ ' = τ τ/2 mnmum CPI IC τ 1 IC τ S = = = 2 CPI ' IC ' τ ' 1 IC τ/2 1 2 3 4 5 6 7 I 1 F D E M W I 2 I 3 I 4 I 5 CPI F D E M W F D E M W F D E M F D E deal deal ' = CPI = 1 Programs can run twce as fast 43

Ppelne Hazards Instructon dependences Result of one nstructon s source for later nstructon Hazard condton Processor runs unnterrupted but provdes ncorrect answers Ppelne hazard Several nstructons n varous stages of executon Ppelne uses a resource value before update by earler nstructon Example ADD R1,R2,R3 SUB R4,R5,R1 Hazard Types ; hazard f SUB reads R1 before ADD wrtes R1 Structural Hazard Data Hazard Control Hazard conflct over access to resource nstructon result not ready when needed branch address and condton not ready when needed 44

Dealng wth Hazards Avod error Pause ppelne and wat for resource to be avalable Called WAIT STATE or PIPELINE STALL Degrades processor performance Adds stall clock cycles (wasted tme) to nstructon executon CPI = processng clock cycles (deal) + stalled clock cycles completed nstructon deal stall deal stall N + N N N = = + = CPI + CPI 1+ CPI IC large IC IC IC deal stall stall performance degradaton stall deal CPI CPI = = 1 1+ CPI CPI + CPI stall deal stall Elmnate cause of stall Improve mplementaton based on analyss of stalls Man actvty of hardware archtects 45

Structural Hazards Conflct over access to resource Typcal structural hazard unfed cache hazard Instructons and data n same memory devce Cannot access data and fetch nstructon on same clock cycle To prevent hazard Stall INSTRUCTION FETCH durng data MEMORY ACCESS CC1 CC2 CC3 CC4 CC5 Instructon Fetch Instructon Decode Execute Data Access Wrte Back Address Instructon Address Data Instructon and Data Memory unfed cache 46

Stall Implementaton for Cache Hazard IF ID EX MEM WB CC1 I 1 CC2 LW I 1 CC3 I 2 LW I 1 CC4 I 3 I 2 LW I 1 CC5 φ I 3 I 2 LW I 1 CC6 I 4 φ I 3 I 2 LW CC7 I 4 φ I 3 I 2 CC8 I 4 φ I 3 CC9 I 4 φ CC10 I 4 On CC5 Load Word (LW) nstructon blocks Instructon Fetch (IF) No nstructon s fetched on CC5 No nstructon (NOP) s forwarded to ID on CC6 NOP = bubble = Φ forwarded to EX on CC7, etc CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 CC9 CC10 I 1 IF ID EX MEM WB LW IF ID EX MEM WB I 2 IF ID EX MEM WB I 3 IF ID EX MEM WB I 4 IF ID EX MEM WB 47

Calculatng Effect of Cache Hazard on CPI CPI stall stall cycles stall cycles = = nstructons stall stalls nstructon stall cycles stalls = stall nstructon = types nstructons nstructon load 1 stall cycle 1 stall IC 1 cycle 1 stall IC = + stall data memory load IC stall data memory store IC load store 1 stall cycle 1 stall IC IC = + stall data memory access IC IC 1 stall cycle 1 stall 0.25 loads 0.15 stores = + stall data memory access nstructon nstructon = 0.40 stall cycles nstructon Assume: Loads ~ 25% Stores ~ 15% Other ~ 60% store deal stall CPI CPI CPI = + = 1.40 0.4 (degradaton = = 29%) 1.4 48

Data Hazards Instructon result not ready when needed Classfcaton (named for correct order of operatons) Read After Wrte (RAW) Correct I2 reads regster after I1 wrtes to t Hazard I2 reads regster before I1 wrtes to t I2 uses ncorrect value Wrte After Wrte (WAW) Correct I2 wrtes to regster after I1 wrtes to t Hazard I2 wrtes to regster before I1 wrtes to t Incorrect value stays n regster Wrte After Read (WAR) Correct I2 wrtes to regster after I1 reads t Hazard I2 wrtes to regster before reads I1 t I1 uses ncorrect value Read After Read (RAR) No hazard reads do not affect regsters To prevent hazard stall ppelne untl result s ready 49

Control Hazards Branch outcome affects program counter (PC) Taken Branch condton s true and PC PC + Dsp Not taken Branch condton s false and PC not changed Target Result of calculaton PC PC + Dsp Branch hazard Outcome not known untl branch executon fnshes Ppelne automatcally fetches (default) nstructon followng branch Default nstructon not correct f branch taken To prevent hazard Flush default nstructons Stall ppelne untl branch condton and branch target are ready Delay n processng branch nstructons s called branch penalty 50

Excepton Hazards Excepton Hardware or software condton requrng specal servce routne Interrupt Servce response to external hardware event Usually asynchronous Not trggered by program nstructons Does not affect valdty of runnng nstructons Trap Servce response to software condton n runnng program Usually synchronous Trggered by program nstructons May stall or affect valdty of runnng nstructons Hazard Multple nstructons n varous stages of executon n ppelne How/where/when to nterrupt ppelne Where s return-pont? 51

Precse Excepton Return-pont Follows atomc operaton Prevous operatons commt all results to state No followng operatons commt any results to state I 1 I 2 I 3 I 4 commts all state I 4 Precse excepton Excepton wth well-defned return-pont Servce excepton followng atomc operaton Restart executon at return pont wthout error Return-pont I 5 commts no state I 5 I 6 I 7 Interrupt Servce Routne I 8 52

Excepton Hazards n 5 Stage Ppelne Exceptons specfc to each stage Memory access excepton n IF or MEM Instructon excepton n ID Arthmetc excepton n EX 5 nstructons n varous stages of executon Where s return-pont? How to handle subsequent partally executed nstructons? CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 CC9 I 1 IF ID EX MEM WB I 2 IF ID EX MEM error WB I 3 IF ID EX MEM WB I 4 IF ID EX MEM WB I 5 IF ID EX MEM WB 53

Berkeley Soluton Attach excepton status feld and source PC to nstructon n IF Instructon rases excepton Mark status feld wth excepton Contnue ppelne untl pror nstructon completes (reaches WB) RETURN-POINT PC of nstructon that rases excepton Flush ppelne (mark nstructons n IF MEM as NOP to cancel WB) PC EXCEPTION SERVICE ROUTINE (ESR) Return from ESR depends on excepton type I 1 CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 CC9 CC10 IF ID EX MEM WB Ref: http://www-nst.eecs.berkeley.edu/~cs252/ 54 I 1 completes atomcally I 2 IF ID EX error φ return pont = I 2 I 3 IF ID EX φ φ I 4 IF ID φ φ φ I 5 IF φ φ φ φ ESR IF ID EX MEM WB