Top Banner
Programación en los procecesadores Intel® Multi Core
30

Programación en los procecesadores Intel® Multi Core.

Jan 24, 2016

Download

Documents

Conchita Espin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programación en los procecesadores Intel® Multi Core.

Programación en los procecesadores Intel® Multi

Core

Page 2: Programación en los procecesadores Intel® Multi Core.

2

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

¿Qué son las instrucciones máquina?

Conjunto de instrucciones

La colección de instrucciones que entiende un CPU

Lenguaje máquina

• Usualmente representado por códigos en ensamblador

• Se almacena en binario

Page 3: Programación en los procecesadores Intel® Multi Core.

3

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Elementos de una instrucción

Código de operación (Op code)

• Hacer esto

Referencia al operando fuente

• A esto

Referencia al operando resultante

• Poner la respuesta aquí

MOV 5 , EAX

Page 4: Programación en los procecesadores Intel® Multi Core.

4

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Ejecución de instrucciones

Secuencial

Pipelinening

Superescalar

Paralelo

Page 5: Programación en los procecesadores Intel® Multi Core.

5

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Ejecucuión de una secuencia de instrucciones

ADD EBX, EAX (EAX := EAX+EBX;)MOV EAX, ECX (ECX := EAX;)

EAX=1

EBX=2

ECX=3

CPU 1

ECX=3

Flujo de instrucciones

EAX=3

Page 6: Programación en los procecesadores Intel® Multi Core.

6

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Ejecución de instrucciones (secuencial)

Instrucción 1Instrucción 2Instrucción 3Instrucción 4Instrucción 5Instrucción 6Instrucción 7Instrucción 8

Captación

Decodificación

Calcula operandos

Capta operandos

Ejecuta instrucción

Escribe operandos

Page 7: Programación en los procecesadores Intel® Multi Core.

7

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Ejecución de instrucciones (pipelinening)

Instrucción 1Instrucción 2Instrucción 3Instrucción 4Instrucción 5Instrucción 6Instrucción 7Instrucción 8

Captación

Decodificación

Calcula operandos

Capta operandos

Ejecuta instrucción

Escribe operandos

Page 8: Programación en los procecesadores Intel® Multi Core.

8

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Plataformas para computación en paralelo

Diferentes arquitecturas

• SMP

• Hyper threading

• Multi core

Page 9: Programación en los procecesadores Intel® Multi Core.

9

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Multi Core Vs Hyper Threading

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

Cache

Estado del CPU

Lógica de Interrupciones

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

CacheUnidades de

EjecuciónCache

Single Core

Multiprocesador (SMP)

Page 10: Programación en los procecesadores Intel® Multi Core.

10

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Multi Core Vs Hyper Threading

Estado del CPU

Lógica de Interrupciones

Estado del CPU

Lógica de Interrupciones

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

Cache

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

CacheUnidades de

EjecuciónCache

Tecnología Hyper Threading

Multi Core

Page 11: Programación en los procecesadores Intel® Multi Core.

11

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Multi Core Vs Hyper Threading

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

Cache

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

Cache

Estado del CPU

Lógica de Interrupciones

Estado del CPU

Lógica de Interrupciones

Unidades deEjecución

Cache

Estado del CPU

Lógica de Interrupciones

Multi Core con caché compartida

Multi Core con tecnología Hyper Threading

Page 12: Programación en los procecesadores Intel® Multi Core.

12

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

¿Para que sirve tener dos o más núcleo en un CPU?

¿Puedo ejecutar en paralelo instrucciones de una secuencia?

Dependencias

Page 13: Programación en los procecesadores Intel® Multi Core.

13

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Dependencias

Puede extraer y decodificar la segunda instrucción en paralelo con la primera

No puede ejecutar la segunda instrucción hasta que la primera haya finalizado

ADD EBX, EAX (EAX := EAX+EBX;)MOV EAX, ECX (ECX := EAX;)

EAX=1

EBX=2

ECX=3

EAX=1

EBX=2

ECX=3

CPU 1 CPU 2

EAX=3

ECX=1

Flujo de instrucciones

Page 14: Programación en los procecesadores Intel® Multi Core.

14

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

¿Para que sirve tener dos o más núcleo en un CPU?

Aumentar tasa de trabajos

¿Qué tipo de trabajos?

•Trabajos que hacen uso intensivo del CPU

•Trabajos que requieren E/S

•Trabajos mixtos

Page 15: Programación en los procecesadores Intel® Multi Core.

15

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Un trabajo en un nucleoUn trabajo en un nucleo

1 trabajo en 10 segundos1 trabajo en 10 segundos

Tasa = 1 / 10 = 0.1Tasa = 1 / 10 = 0.1

Tiempo de Tiempo de retorno =10 retorno =10 segssegs

10 segundos10 segundos

En el CPUEn el CPU

Page 16: Programación en los procecesadores Intel® Multi Core.

16

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Dos trabajos en un nucleoDos trabajos en un nucleo

2 trabajos en 20 segundos2 trabajos en 20 segundos

Tasa = 2 / 20 = 0.1Tasa = 2 / 20 = 0.1

Tiempo de retorno P0 =20 Tiempo de retorno P0 =20 segssegs

Tiempo de retorno P1 =20 Tiempo de retorno P1 =20 segssegs

10 segundos10 segundos

10 segundos10 segundos

En el CPUEn el CPU

Page 17: Programación en los procecesadores Intel® Multi Core.

17

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Con un CPU

•El tiempo de retorno aumenta

•La tasa de trabajos se mantiene

Page 18: Programación en los procecesadores Intel® Multi Core.

18

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Dos trabajos en un nucleoDos trabajos en un nucleo

2 trabajos en 20 segundos2 trabajos en 20 segundos

Tasa = 2 / 20 = 0.1Tasa = 2 / 20 = 0.1

Tiempo de retornoTiempo de retornoP0 =15 segsP0 =15 segs Tiempo de retorno Tiempo de retorno

P1=19 segsP1=19 segs

El tiempo de retorno de El tiempo de retorno de los procesos puede los procesos puede variarvariar•PrioridadesPrioridades•Politicas de Politicas de platinificaciónplatinificación

La tasa de trabajos La tasa de trabajos se mantiene igualse mantiene igual

10 segundos10 segundos

10 segundos10 segundos

En el CPUEn el CPU

Page 19: Programación en los procecesadores Intel® Multi Core.

19

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Un trabajo en dos nucleosUn trabajo en dos nucleos

1 trabajo en 10 segundos1 trabajo en 10 segundos

Tasa = 1 / 10 = 0.1Tasa = 1 / 10 = 0.1

Tiempo de Tiempo de retorno =10 retorno =10 segssegs

No hay mejora en No hay mejora en el tiempo de el tiempo de retorno ni la tasa retorno ni la tasa de trabajosde trabajos

Nucleo 0Nucleo 0

Nucleo 1Nucleo 1

10 segundos10 segundos

Page 20: Programación en los procecesadores Intel® Multi Core.

20

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Dos trabajos en dos núcleosDos trabajos en dos núcleos

2 trabajos en 10 segundos2 trabajos en 10 segundosTasa = 2 / 10 = 0.2Tasa = 2 / 10 = 0.2

Tiempo de Tiempo de retorno =10 retorno =10 segssegs

La tasa de La tasa de trabajos aumenta trabajos aumenta al dobleal doble

El tiempo de retorno El tiempo de retorno se mantiene igual se mantiene igual que cuando que cuando ejecutamos un ejecutamos un trabajotrabajo

10 segundos10 segundos

10 segundos10 segundos

Nucleo 0Nucleo 0

Nucleo 1Nucleo 1

Page 21: Programación en los procecesadores Intel® Multi Core.

21

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Multi core

Encontramos mejora en la tasa de trabajos y tiempo de retorno cuando ejecutamos dos procesos concurrentes.

Hasta ahora un solo proceso no es capaz de obtener beneficio de las arquitecturas MultiCore

Page 22: Programación en los procecesadores Intel® Multi Core.

22

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Trabajos que hacen uso intensivo del CPU

Un trabajo optimizado en dos nucleosUn trabajo optimizado en dos nucleos

1 trabajo en 5 segundos1 trabajo en 5 segundos

Tasa = 1 / 5 = 0.2Tasa = 1 / 5 = 0.2

Tiempo de Tiempo de retorno =5 retorno =5 segssegs

10 segundos10 segundos

Nucleo 0Nucleo 0

Nucleo 1Nucleo 1

5 segundos5 segundos 5 segundos5 segundos

Hilo 0Hilo 0 Hilo 1Hilo 1

Page 23: Programación en los procecesadores Intel® Multi Core.

23

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Definiendo los Hilos

Un hilo es una secuencia de instrucciones relacionadas que se ejecuta de forma independiente a otras secuencias

Todos los programas tienen al menos un hilo principal

• Inicializa el programa y comienza la ejecución de las instrucciones iniciales

• Puede crear otros hilos que ejecuten varias tareas o puede hacer todo el trabajo el solo

Page 24: Programación en los procecesadores Intel® Multi Core.

24

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Dividiendo una aplicación en hilos

Un proceso puede dividirse en múltiples hilos

• Mejor uso de los recursos de hardware

Es necesario entender

• Diseño y estructura de la aplicación

• La interfase de programación con hilos

• El compilador y el ambiente de ejecución de la aplicación

• Las plataformas destino donde la aplicación se va a ejecutar

Page 25: Programación en los procecesadores Intel® Multi Core.

25

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Estado del CPU

Lógica de Interrupciones

Cache

Unidades de ejecución

Hilos en plataformas single core

Single Core

InstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucción

InstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucción

Page 26: Programación en los procecesadores Intel® Multi Core.

26

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Estado del CPU

Lógica de Interrupciones

Estado del CPU

Lógica de Interrupciones

Cache

Unidades de ejecución

Hilos en plataformas Hyper Threading

InstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucción

InstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucción

Tecnología Hyper Threading

Ambas instrucciones requieren diferentes unidades funcionales

Ambas instrucciones requieren una misma unidad funcional

Page 27: Programación en los procecesadores Intel® Multi Core.

27

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Estado del CPU

Lógica de Interrupciones

Estado del CPU

Lógica de Interrupciones

Cache Cache

Unidades de ejecución Unidades de ejecución

Multi-hilos en plataformas multi core

InstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucción

InstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucciónInstrucción

Multi Core

Page 28: Programación en los procecesadores Intel® Multi Core.

28

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Hilos en plataformas single core

Concurrencia

• Dos o más hilos se ejecutan en el mismo procesador

• El tiempo del procesador se divide dando turnos a los dos hilos de manera que pueden avanzar

Page 29: Programación en los procecesadores Intel® Multi Core.

29

Copyright © 2006, Intel Corporation. All rights reserved.

Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.

Hilos en plataformas multi core

Paralelismo

• Dos o más hilos se ejecutan simultáneamente en dos o más procesadores

• Cada hilo tiene el tiempo de un procesador

Page 30: Programación en los procecesadores Intel® Multi Core.

Gracias!