Segmentación del Path de Datos

Documentos relacionados
Segmentación del Path de Datos

Forwarding versus Stalling

Forwarding versus Stalling

Pipeline (Segmentación)

Arquitectura de Computadores II Clase #5

EE 361L Implementation Notes for Subproject 1

Ejercicios para el 3er parcial

Aspectos avanzados de arquitectura de computadoras Pipeline. Facultad de Ingeniería - Universidad de la República Curso 2017

Pipelining. Introducción

Segmentación: Mejora del rendimiento. IEC UTM Moisés E. Ramírez G. Segmentación

Procesador Segmentado

Tema 6. Introducción a la segmentación avanzada: Riesgos

Fig Riesgos por dependencias de datos.

Arquitectura Segmentada: Conceptos básicosb

Introducción a paralelismo a nivel de instrucción

MIPS: Modelo de programación. (I Parte)

Tema 1: PROCESADORES SEGMENTADOS

Lecture 8. Computer Decisions

Pipeline o Segmentación Encausada

Arquitectura de Computadores

Tutorías con Grupos Reducidos (TGR) Sesión 2: Paralelismo a Nivel de Instrucción

Arquitectura de Computadoras Trabajo Práctico N 8 Pipeline de Instrucciones 1 Primer Cuatrimestre de 2016

Segmentación del ciclo de instrucción

Organización del Computador I Verano. Control Multiciclo. Basado en el capítulo 5 del libro de Patterson y Hennessy

Fundamentos de los Computadores Grado en Ingeniería Informática (hasta final del diseño monociclo)

Arquitectura de Computadoras Trabajo Práctico N 7 Pipeline de Instrucciones Primer Cuatrimestre de 2010

El procesador. Diseño del control

Segmentación del ciclo de instrucción

Estructura de Computadores 2 [08/09] Entrada/Salida en procesadores MIPS

Organización del Computador I Verano. MIPS (2 de 2) Basado en el capítulo 2 del libro de Patterson y Hennessy

Tema 5. Segmentación: conceptos básicos

TEMA 4. ARQUITECTURA IA-64

El procesador. Datapath y control

Arquitectura de Computadoras. Clase 4 Segmentación de Instrucciones

Circuitos Digitales II y Laboratorio Fundamentos de Arquitectura de Computadores

Tratamiento de Excepciones en MIPS

Pregunta 1 Suponga que una muestra de 35 observaciones es obtenida de una población con media y varianza. Entonces la se calcula como.

Flashcards Series 2 Las Necesidades de la Vida

Organización del Computador I Verano. Aritmética (4 de 5) Basado en el capítulo 4 del libro de Patterson y Hennessy Multiplicaciones y Divisiones

Modos de Direccionamiento

IE12_ CONSOLIDACIÓN Y DESARROLLO DE NUEVAS TÉCNICAS DE EVALUACIÓN INTENSIVAS ON-LINE YA IMPLEMENTADAS POR EL GIE E4

Plataformas de soporte computacional: arquitecturas avanzadas,

ARQUITECTURA DE COMPUTADORES CAPÍTULO 2. PROCESADORES SEGMENTADOS

Flashcards Series 4 El Hotel

La Unidad de Control y el Camino de Datos

The Data Path. The Microarchitecture Level. Data Path Ops. Microarchitecture 1 8/20/2011

3. SEGMENTACIÓN DEL CAUCE

16/04/2012. Introducción. Construyendo el Datapath. Esquema de implementación Simple. Unidad de Control. Arquitectura de Computadoras Primavera 2012

Ejercicios de Paralelismo a Nivel de Instrucción

CONTROLADORA PARA PIXELS CONPIX

Qué es Pipelining? Es una técnica de implementación en la que se superpone la ejecución de varias instrucciones.

Might. Área Lectura y Escritura. In order to understand the use of the modal verb might we will check some examples:

El procesador. Datapath para las instrucciones de brinco

Superescalares. Scheduling estático

Exercise List 3 - Microeconomics II Moral Hazard - Screening- Signaling

Organización de la Computadora

Arquitectura de Computadoras I Ingeniería de Sistemas Curso 2017

Definición de prestaciones

Flip-flops. Luis Entrena, Celia López, Mario García, Enrique San Millán. Universidad Carlos III de Madrid

Prof. Aidsa Santiago. Cesar A Aceros Moreno

SEGMENTACIÓN EN LA EJECUCIÓN DE INSTRUCCIONES

Pipelining o Segmentación de Instrucciones

ELO311 Estructuras de Computadores Digitales. Operaciones MIPS para Control de flujo

Real Time Systems. Part 2: Cyclic schedulers. Real Time Systems. Francisco Martín Rico. URJC. 2011

GRADO EN INGENIERÍA DE COMPUTADORES

Diseño de la ruta de datos multiciclo. Procesador Multiciclo. Diseño de la ruta de datos multiciclo. Diseño de la ruta de datos multiciclo

UNIDAD 5: Mejora del rendimiento con la segmentación.

Ada County Existing/Resale

Ada County Existing/Resale

MANUAL DE FARMACIA CLINICA Y ATENCION FARMACEUTICA. EL PRECIO ES EN DOLARES BY JOAQUIN HERRERA CARRANZA

Segmentación de cauce

Decodificador de funciones v.2

Arquitectura de Computadores

ARQUITECTURA DE COMPUTADORES CAPÍTULO 2. PROCESADORES SEGMENTADOS

EC - Bibliografía EC -

Repaso de funciones exponenciales y logarítmicas. Review of exponential and logarithmic functions

Sección de procesamiento: El camino de datos

PIPELINING: Antes de adentrarnos en el tema, veremos una analogía de un pipeline:

Arquitectura t de Computadores

ELO311 Estructuras de Computadores Digitales. Pipeline (Segmentación)

Modelo de von Neumann

Los números. 0 cero 1 uno / un 2 dos 3 tres 4 cuatro. 6 seis 7 siete 8 ocho 9 nueve 10 diez 5 cinco

Primer Semestre Laboratorio de Electrónica Universidad de San Carlos de Guatemala. Electrónica 5. Aux. Marie Chantelle Cruz.

Level 1 Spanish, 2012

Level 1 Spanish, 2016

Do Now! Question 1: Pregunta 1

Los nombres originales de los territorios, sitios y accidentes geograficos de Colombia (Spanish Edition)

Segmentación del ciclo de instrucción v.2016

Learning Spanish Like Crazy. Spoken Spanish Lección Uno. Listen to the following conversation. Male: Hola Hablas inglés? Female: Quién?

Organización de Computadoras. Algunas temas tomados en 2ª evaluación integradora

Convenciones. Introducción. Unidades principales en la implementación. El procesador: camino de datos y control. Tipos de elementos:

Fundamentos de los Computadores Grado en Ingeniería Informática (desde diseño multiciclo en adelante)

TX MULTI MANUAL TX MULTI. Mando copiador multifrecuencia 1. PASOS PARA COPIAR UN MANDO CÓDIGO FIJO Y ROLLING ESTÁNDAR:

Arquitectura t de Computadores Clase 10: Diseño del microprocesador monociclo pt.2

Level 1 Spanish, 2013

IJVM Instructions. Computer Architecture The instruction opcode is 8 bit wide. Offsets are 16 bits wide (stored in two consecutive bytes)

Soluciones a ejercicios de Paralelismo a Nivel de instrucción

Arquitectura de Computadores Problemas (hoja 2). Curso

Programación lineal Optimización de procesos químicos DIQUIMA-ETSII

Transcripción:

Maestría en Electrónica Arquitectura de Computadoras Unidad 5 (Parte II) M. C. Felipe Santiago Espinosa Abril/2018

Pipelining Analogy Pipelined laundry: overlapping execution Parallelism improves performance Four loads: Speedup = 8/3.5 = 2.3 Non-stop: Speedup = 2*n/0.5 + 1.5 4 = number of stages 2

MIPS Pipeline Five stages, one step per stage 1. IF: Instruction fetch from memory 2. ID: Instruction decode & register read 3. EX: Execute operation or calculate address 4. MEM: Access memory operand 5. WB: Write result back to register 3

Pipeline Performance Assume time for stages is 100ps for register read or write 200ps for other stages Compare pipelined datapath with single-cycle datapath Instr Instr fetch Register read ALU op Memory access Register write Total time lw 200ps 100 ps 200ps 200ps 100 ps 800ps sw 200ps 100 ps 200ps 200ps 700ps R-format 200ps 100 ps 200ps 100 ps 600ps beq 200ps 100 ps 200ps 500ps 4

Pipeline Performance Single-cycle (T c = 800ps) Pipelined (T c = 200ps) 5

Pipeline Speedup If all stages are balanced i.e., all take the same time Time between instructions pipelined = Time between instructions nonpipelined Number of stages If not balanced, speedup is less Speedup due to increased throughput Latency (time for each instruction) does not decrease 6

Pipelining and ISA Design MIPS ISA designed for pipelining All instructions are 32-bits Easier to fetch and decode in one cycle c.f. x86: 1- to 17-byte instructions Few and regular instruction formats Can decode and read registers in one step Load/store addressing Can calculate address in 3 rd stage, access memory in 4 th stage Alignment of memory operands Memory access takes only one cycle 7

Hazards Situations that prevent starting the next instruction in the next cycle Structure hazards A required resource is busy Data hazard Need to wait for previous instruction to complete its data read/write Control hazard Deciding on control action depends on previous instruction 8

Structure Hazards Conflict for use of a resource In MIPS pipeline with a single memory Load/store requires data access Instruction fetch would have to stall for that cycle Would cause a pipeline bubble Hence, pipelined datapaths require separate instruction/data memories Or separate instruction/data caches 9

Data Hazards An instruction depends on completion of data access by a previous instruction add $s0, $t0, $t1 sub $t2, $s0, $t3 10

Forwarding (aka Bypassing) Use result when it is computed Don t wait for it to be stored in a register Requires extra connections in the datapath 11

Load-Use Data Hazard Can t always avoid stalls by forwarding If value not computed when needed Can t forward backward in time! 12

Code Scheduling to Avoid Stalls Reorder code to avoid use of load result in the next instruction C code for A = B + E; C = B + F; stall stall lw $t1, 0($t0) lw $t2, 4($t0) add $t3, $t1, $t2 sw $t3, 12($t0) lw $t4, 8($t0) add $t5, $t1, $t4 sw $t5, 16($t0) 13 cycles lw $t1, 0($t0) lw $t2, 4($t0) lw $t4, 8($t0) add $t3, $t1, $t2 sw $t3, 12($t0) add $t5, $t1, $t4 sw $t5, 16($t0) 11 cycles 13

Control Hazards Branch determines flow of control Fetching next instruction depends on branch outcome Pipeline can t always fetch correct instruction Still working on ID stage of branch In MIPS pipeline Need to compare registers and compute target early in the pipeline Add hardware to do it in ID stage 14

Stall on Branch Wait until branch outcome determined before fetching next instruction 15

Branch Prediction Longer pipelines can t readily determine branch outcome early Stall penalty becomes unacceptable Predict outcome of branch Only stall if prediction is wrong In MIPS pipeline Can predict branches not taken Fetch instruction after branch, with no delay 16

MIPS with Predict Not Taken Prediction correct Prediction incorrect 17

More-Realistic Branch Prediction Static branch prediction Based on typical branch behavior Example: loop and if-statement branches Predict backward branches taken Predict forward branches not taken Dynamic branch prediction Hardware measures actual branch behavior e.g., record recent history of each branch Assume future behavior will continue the trend When wrong, stall while re-fetching, and update history 18

Pipeline Summary The BIG Picture Pipelining improves performance by increasing instruction throughput Executes multiple instructions in parallel Each instruction has the same latency Subject to hazards Structure, data, control Instruction set design affects complexity of pipeline implementation 19

MIPS Pipelined Datapath MEM Right-to-left flow leads to hazards WB 20

Pipeline registers Need registers between stages To hold information produced in previous cycle 21

Pipeline Operation Cycle-by-cycle flow of instructions through the pipelined datapath Single-clock-cycle pipeline diagram Shows pipeline usage in a single cycle Highlight resources used c.f. multi-clock-cycle diagram Graph of operation over time We ll look at single-clock-cycle diagrams for load & store 22

IF for Load, Store, 23

ID for Load, Store, 24

EX for Load 25

MEM for Load 26

WB for Load Wrong register number 27

Corrected Datapath for Load 28

EX for Store 29

MEM for Store 30

WB for Store 31

Multi-Cycle Pipeline Diagram Traditional form 32

Multi-Cycle Pipeline Diagram Form showing resource usage 33

Single-Cycle Pipeline Diagram State of pipeline in a given cycle 34

Pipelined Control (Simplified) 35

Pipelined Control Control signals derived from instruction As in single-cycle implementation 36

Pipelined Control 37

Ejemplo: Evaluar la ejecución de las instrucciones siguientes a través de un procesador segmentado: lw $10, 20 ($1) sub $11, $2, $3 and $12, $4, $5 or $13, $6, $7 add $14, $8, $9 Respuesta: Se requieren 5 ciclos de reloj para concluir con la instrucción lw Cuando lw termina su ejecución, las siguientes instrucciones se producen una por ciclo de reloj. En total se requiere de 9 ciclos para la ejecución de las cinco instrucciones. 38

Ciclo de reloj no. 1 39

Ciclo de reloj no. 2 40

Ciclo de reloj no. 3 41

Ciclo de reloj no. 4 42

Ciclo de reloj no. 5 43

Ciclo de reloj no. 6 44

Ciclo de reloj no. 7 45

Ciclo de reloj no. 8 46

Ciclo de reloj no. 9 47

Data Hazards in ALU Instructions Consider this sequence: sub $2, $1,$3 and $12,$2,$5 or $13,$6,$2 add $14,$2,$2 sw $15,100($2) We can resolve hazards with forwarding How do we detect when to forward? 48

Dependencies & Forwarding 49

Detecting the Need to Forward ALU operand register numbers in EX stage are given by ID/EX.RegisterRs, ID/EX.RegisterRt Data hazards when 1a. EX/MEM.RegisterRd = ID/EX.RegisterRs 1b. EX/MEM.RegisterRd = ID/EX.RegisterRt 2a. MEM/WB.RegisterRd = ID/EX.RegisterRs 2b. MEM/WB.RegisterRd = ID/EX.RegisterRt Fwd from EX/MEM pipeline reg Fwd from MEM/WB pipeline reg 50

Detecting the Need to Forward But only if forwarding instruction will write to a register! EX/MEM.RegWrite, MEM/WB.RegWrite And only if Rd for that instruction is not $zero EX/MEM.RegisterRd 0, MEM/WB.RegisterRd 0 51

Forwarding Paths 52

Forwarding Conditions EX hazard if (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs)) ForwardA = 10 if (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRt)) ForwardB = 10 MEM hazard if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) ForwardA = 01 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0) and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01 53

Double Data Hazard Consider the sequence: add $1,$1,$2 add $1,$1,$3 add $1,$1,$4 Both hazards occur Want to use the most recent Revise MEM hazard condition Only fwd if EX hazard condition isn t true 54

Revised Forwarding Condition MEM hazard if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0) and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRs)) and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) ForwardA = 01 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd 0) and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd 0) and (EX/MEM.RegisterRd = ID/EX.RegisterRt)) and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) ForwardB = 01 55

Datapath with Forwarding 56

Load-Use Data Hazard Need to stall for one cycle 57

Load-Use Hazard Detection Check when using instruction is decoded in ID stage ALU operand register numbers in ID stage are given by IF/ID.RegisterRs, IF/ID.RegisterRt Load-use hazard when ID/EX.MemRead and ((ID/EX.RegisterRt = IF/ID.RegisterRs) or (ID/EX.RegisterRt = IF/ID.RegisterRt)) If detected, stall and insert bubble 58

How to Stall the Pipeline Force control values in ID/EX register to 0 EX, MEM and WB do nop (no-operation) Prevent update of PC and IF/ID register Using instruction is decoded again Following instruction is fetched again 1-cycle stall allows MEM to read data for lw Can subsequently forward to EX stage 59

Stall/Bubble in the Pipeline Stall inserted here 60

Stall/Bubble in the Pipeline Or, more accurately 61

Datapath with Hazard Detection 62

Ejemplo: Con la unidad de anticipación y la unidad de detección de riesgos incorporadas en el procesador segmentando, analice su comportamiento ciclo a ciclo durante la ejecución del código: lw $2, 20($1) and $4, $2, $5 or $4, $4, $2 add $9, $4, $2 Se revisarán los ciclos del 2 al 7 para observar cómo se inserta la burbuja y cómo avanza sin afectar la ejecución del programa. También se notará que no hay conflictos entre ambas unidades. Desarrolle la representación Multi-ciclos para observar el comportamiento global de la ejecución. 63

64

65

66

67

68

69

Stalls and Performance The BIG Picture Stalls reduce performance But are required to get correct results Compiler can arrange code to avoid hazards and stalls Requires knowledge of the pipeline structure 70

Branch Hazards If branch outcome determined in MEM Flush these instructions (Set control values to 0) PC 71

Incorporando Saltos Incondicionales Los saltos incondicionales (J) se pueden ejecutar tan pronto se identifica a la instrucción. Esto se hace en la etapa ID. Dos acciones deben realizarse: Anular la instrucción que está en la etapa IF limpiando el registro IF/ID. Remplazar el valor del PC por el destino del salto. 72

Implementación que resuelve a BEQ en la etapa MEM y a J en la etapa ID 73

Reducing Branch Delay Move hardware to determine outcome to ID stage Target address adder Register comparator Example: branch taken 36: sub $10, $4, $8 40: beq $1, $3, 7 44: and $12, $2, $5 48: or $13, $2, $6 52: add $14, $4, $2 56: slt $15, $6, $7... 72: lw $4, 50($7) 74

Example: Branch Taken 75

Example: Branch Taken 76

Data Hazards for Branches If a comparison register is a destination of 2 nd or 3 rd preceding ALU instruction add $1, $2, $3 IF ID EX MEM WB add $4, $5, $6 IF ID EX MEM WB IF ID EX MEM WB beq $1, $4, target IF ID EX MEM WB Can resolve using forwarding 77

Data Hazards for Branches If a comparison register is a destination of preceding ALU instruction or 2 nd preceding load instruction Need 1 stall cycle lw $1, addr IF ID EX MEM WB add $4, $5, $6 IF ID EX MEM WB beq stalled IF ID beq $1, $4, target ID EX MEM WB 78

Data Hazards for Branches If a comparison register is a destination of immediately preceding load instruction Need 2 stall cycles lw $1, addr IF ID EX MEM WB beq stalled IF ID beq stalled ID beq $1, $0, target ID EX MEM WB 79

Ejercicio: Comparación de Implementaciones Comparar el rendimiento de una implementación de un solo ciclo de reloj (PSC) con una implementación segmentada (PSEG). Considerando un programa de prueba con la siguiente distribución de instrucciones: Tipo Frecuencia Cargas 20 % Almacenamientos 15 % Brincos 20 % Saltos 5 % Aritmético Lógicas 40 % Tiempos de operación para las unidades funcionales: 2 ns - acceso a memoria, 2 ns - operación de la ALU, 1 ns acceso a registros. Para la implementación segmentada suponer que: la mitad de las instrucciones de carga están inmediatamente seguidas por una instrucción que usará el valor obtenido de la memoria, que una cuarta parte de los brincos condicionales si se realizan y sólo producen un retraso de 1 ciclo de reloj y que los saltos incondicionales también requieren de 1 ciclo de reloj adicional. 80

Ejercicios: 1. Por medio de una representación de múltiples ciclos de la segmentación, representar la ejecución de las siguientes instrucciones: Add $2, $5, $4 Add $4, $2, $5 Lw $5, 100($2) Add $3, $5, $4 Beq $8, $8, s1 And $1, $2, $3 Or $4, $5, $6 s1: Sub $7, $8, $9 Mostrar las líneas por medio de las cuales se resuelven las dependencias de datos y/o mostrar la inserción de burbujas si es que se requieren. Suponga que los brincos se resuelven en la etapa ID. 81

Ejercicios (Comprensión y ampliación de la implementación). Utilizando como base la figura de la diapositiva 73, analice como avanzan las instrucciones durante su ejecución: add $t5, $t1, $t0 beq $t2, $t3, et1 Suponga que están ubicadas en la dirección 4000diez, que los registros $t0 y $t1 tienen los valores 30 y 40 respectivamente, que $t2 y $t3 tienen el dato 33 y que la etiqueta está ubicada 10 instrucciones después de la que se está evaluando. Resalte las líneas que estarán activas durante la ejecución y escriba el valor de cada una de esas líneas. A la misma figura, agregue el hardware necesario (camino de datos y control) para que soporte la instrucción addi. De manera similar, agregue el hardware necesario para que el procesador soporte la instrucción jal. 82