Upload
conchita-espin
View
223
Download
0
Tags:
Embed Size (px)
Citation preview
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
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Gracias!