Upload
shaynewar
View
243
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Arquitectura de computadores
Citation preview
El reto de paralelismo y Multicore
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.
Intel® Software College
2
Motivación
19801980
WirelessWirelessPlug’n PlayPlug’n PlayVideo InputVideo Input
PVRPVR
20042004
Primera PCPrimera PC19811981
19901990
WindowsWindowsMouseMouseMonitor Monitor ColorColor
19951995
Internet Internet MultimediMultimedi
aaJoystickJoystick
Se requiere mejor rendimiento
20062006
MultitaskingMultitaskingMenor consumo Menor consumo
de energíade energíaMovilidadMovilidad
JuegosJuegos
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.
Intel® Software College
3
Ley de Moore’s
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.
Intel® Software College
4Time
µProc60%/año.(2X/1.5años)
DRAM9%/año.(2X/10 yrs)1
10
100
1000
19
801
98
1 19
831
98
419
851
98
619
871
98
819
891
99
019
911
99
219
931
99
419
951
99
619
971
99
8 19
992
00
0
DRAM
CPU
19
82
Hueco de rendimientoProcesador-Memoria(crece 50% / año)
Ren
dim
ien
to
“Ley de Moore”
“¿Ley Menor?
¿Quién se Preocupa por la Jerarquía de Memoria?
Hueco Procesador-Memoria DRAM (latencia)
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.
Intel® Software College
5
Implicaciones de la ley de Moore’s
• La velocidad de la memoria no está incrementando tan rápido como la velocidad de los microprocesadores
• ~1980 – i486 CPU toma ~8 ciclos de reloj (cpc cloks per cycle) para acceder memoria
• ~1990 - Intel Pentium toma ~224 cpc
• Consumo de energía• Intel Pentium ~3 millones de transistores • Intel Itanium 2 ~1 mil millones de transistores
• A esta tasa tendremos más calor por centímetro cuadrado que la superficie del sol
La aproximación multi-core mejora el rendimiento usando la estrategia
“divide y vencerás”
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.
Intel® Software College
6
Rendimiento / Consumo
Máxima FrecuenciaMáxima Frecuencia
Potencia RequeridaPotencia Requerida
RendimientoRendimiento
1.00x1.00x
Relative single-core frequency and VccRelative single-core frequency and Vcc
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.
Intel® Software College
7
“Over-clocking”
Over-clockedOver-clocked(+20%)(+20%)
Relative single-core frequency and VccRelative single-core frequency and Vcc
1.73x1.73x
1.13x1.13x1.00x1.00x
Máxima FrecuenciaMáxima Frecuencia
Potencia RequeridaPotencia Requerida
RendimientoRendimiento
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.
Intel® Software College
8
“Under-clocking”
Over-clockedOver-clocked(+20%)(+20%)
Under-clockedUnder-clocked(-20%)(-20%)
0.51x0.51x
0.87x0.87x1.00x1.00x
Relative single-core frequency and VccRelative single-core frequency and Vcc
1.73x1.73x
1.13x1.13x
Máxima FrecuenciaMáxima Frecuencia
Potencia RequeridaPotencia Requerida
RendimientoRendimiento
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.
Intel® Software College
9
Over-clockedOver-clocked(+20%)(+20%)
1.00x1.00x
Relative single-core frequency and VccRelative single-core frequency and Vcc
1.73x1.73x
1.13x1.13x
Máxima FrecuenciaMáxima Frecuencia
Potencia RequeridaPotencia Requerida
RendimientoRendimiento
Rendimiento Multi-Core y Consumo de Energía
Dual-coreDual-core(-20%)(-20%)
1.02x1.02x
1.73x1.73xDual-CoreDual-Core
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.
Intel® Software College
10
Aplicaciones en Procesadores de un solo Núcleo
Incremento en la frecuencia de reloj produce un incremento en el rendimiento de la aplicación
• La aplicación gana, no se tomó acción al respecto
Avances en la tecnología de compiladores impulsan el rendimiento
• Re-construye tu aplicación para aprovechar los beneficios adicionales de rendimiento
El cache mejora el rendimiento
• Las aplicaciones se benefician con un pequeño o ningún cambio
…2001
El Rendimiento de la Aplicación Mejora como Incrementan los GHz (frecuencia de reloj)
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.
Intel® Software College
11
Procesadores Multi-Core(comenzando con Dual-Core)
Varios núcleos del procesador disponibles• Replicar todo el núcleo del procesador en un solo chip
mejora el rendimiento de una aplicación paralelizada• Evolución natural de HT• El rendimiento mejora para aplicaciones paralelizadas
Avances en la tecnología del compilador continúan impulsando el rendimiento• OpenMP, Auto-parallelización, los compiladores
incorporan las últimas innovaciones del procesador
El Cache y la frecuencia de reloj no influyen en el rendimiento de la aplicación• El cache y la frecuencia del reloj siguen contribuyendo
…2005, 2006, 2007,…
La Mejora en el Rendimiento es lograda por medio de la Paralelización
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.
Intel® Software College
12
Rendimiento a Través de “Multi-Cores”
Normalized Performance vs. Initial IntelNormalized Performance vs. Initial Intel®® Pentium Pentium®® 4 Processor 4 Processor
20002000 2008+2008+
Ren
dim
ien
toR
en
dim
ien
to
20042004
3X3X
Source: IntelSource: Intel
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.
Intel® Software College
13
20002000 2009+2009+
Ren
dim
ien
toR
en
dim
ien
to
10X10X
SINGLE CORESINGLE CORE
MULTI-COREMULTI-CORE
20042004
3X3X
PronósticoPronóstico
Aquí estamosAquí estamos
Rendimiento a Través de “Multi-Cores”
Source: IntelSource: Intel
Normalized Performance vs. Initial IntelNormalized Performance vs. Initial Intel®® Pentium Pentium®® 4 Processor 4 Processor
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.
Intel® Software College
14
La ruta hacia“Many cores”
Standard coreStandard core
Hyper-threadingHyper-threading
Dual-CoreDual-Core
Multi-CoreMulti-Core
Many-CoreMany-Core
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.
Intel® Software College
15
Resumen
La velocidad del procesador (GHz) ya no es el principal contribuyente al rendimiento de las aplicaciones
Multi-Core hace que haya disponibles varios procesadores (núcleos/cores) en un solo chip.
• Una aplicación propiamente diseñada puede escalar incrementos en el rendimiento como el número de núcleos incremente
Las plataformas Multi-Core están aquí!
Multi-Core es una transición de la tecnología mayor para los desarrolladores de aplicaciones
Rendimiento Desktop*Rendimiento Desktop*
Server
Rendimiento Móvil* Rendimiento Móvil*
* Mobile & Desktop Pentium
2005 2006** 2007**
LanzamientoLanzamiento >70%>70% >90%>90%
>70%>70% >90%>90%
>85% ~100%
LanzamientoLanzamiento
LanzamientoLanzamiento
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.
Intel® Software College
16
Multicores – No hay almuerzo gratis
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.
Intel® Software College
17
Estableciendo el Problema
• Algunos en la industria tienen la percepción de que la paralelización de aplicaciones no es necesaria para sacar el máximo provecho de multi-core, ya que algunos creen de que el planificador del SO hace todo el trabajo para ellos.
Por las últimas décadas el software ha sido desarrollado como una aplicación de un solo hilo (serial)
Los hilos no han sido comunmente usados para tareas concurrentes, ejemplo: eventos de GUI
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.
Intel® Software College
18
Hechos del Paralelismo
•El paralelismo solo era usado para aplicaciones de alto rendimiento (No más)
•El cómputo paralelo no se va a detener
•Desarrollar aplicaciones paralelas no es simple
•Evaluar el rendimiento en paralelo es complejo
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.
Intel® Software College
19
Implicaciones del Paralelismo
• Diseño de Computadoras Paralelas
• Diseño de Algoritmos Eficientes
• Evaluación de Algoritmos Paralelos
• Desarrollo de lenguajes de programación Paralelos
• Desarrollo de Utilerías de Programación Paralela
• Portabilidad de aplicaciones paralelas
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.
Intel® Software College
20
Máquinas Paralelas:
Principalmente hay dos clases de máquinas paralelas:
• Multicomputadoras• Paso de mensajes, sistemas de memoria
distribuida, redes de estaciones de trabajo, clusters, NUMA (non-uniform memory access), etc.
• Multiprocesadores• Multiprocesadores con memoria compartida,
multiprocesamiento simétrico, UMA (uniform memory access systems).
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.
Intel® Software College
21
Arquitectura de Memoria Compartida
Procesadores y Núcleos
Cache
Bus
Bancos de Memoria
Cualquier dirección de memoria es accesible desde cualquier procesador/núcleo: dirección única por posición de memoria
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.
Intel® Software College
22
Estructura de un Proceso
Rutinas de Int.
Descriptores
HeapCódigo
IP
Stack
Proceso
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.
Intel® Software College
23
Hilos
Hilos
Rutinas de Int.
Descriptores
HeapCódigo
Stack
IP
Stack
IPHilo
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.
Intel® Software College
24
Visión de Alto-Nivel del Paralelismo
PROCESO
Una instancia de un programa en ejecución con los estados necesarios para permanecer en ejecución – la mayoría de las aplicaciones son procesos
Crear un nuevo proceso puede ser costoso en CPU, se lleva tiempo y memoria
HILO
Una instancia de subtareas subdivididas para ejecutarse en
paralelo – muchas aplicaciones se dividen en múltiples hilos
Los hilos pueden crearse sin replicar todo el proceso
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.
Intel® Software College
25
Tipos de Paralelismo
por FuncionalidadAsignar hilos a funciones separadas hechas por la aplicación
• El método más fácil desde que sobreponer tareas es obvio (ejemplo esperar actualización de una Interfaz de Usuario)
• Por lo general, mejorar la capacidad de respuesta y funcionalidad
• A menudo se hace a través de un modelo de programación por descomposición funcionalpor Rendimiento
Paralelizar para mejorar tiempo de retorno o tasa de trabajos
• Más difícil ya que los desarrolladores necesitan tener un conocimiento profundo de flujo de datos y estructuras de datos
• Por lo general, mejorar el desempeño en general• Usualmente se hace mediante un modelo de programación de
descomposición de datos
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.
Intel® Software College
26
Flujo de Tráfico en una AutopistaLa Analogía
Una Autopista Procesador Multi Core
Con Muchos Carriles Núcleo
Donde los Vehículos son Hilos de una Aplicación
Y la Longitud de un Vehículo es el Tiempo de Ejecución de un Hilo
Y todo el Flujo de Tráfico es la Ejecución del Procesador
Imagina…
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.
Intel® Software College
27
Flujo de Tráfico en una AutopistaLa Analogía
4 Carriles = 4 Núcleos
Los vehículos son hilos de una aplicación
La línea final representa la ejecución
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.
Intel® Software College
28
Flujo de Tráfico en una Autopista Partiendo Procesos
Un solo hilo…O… Unos pocos hilos grandes, de cómputo intensivo, hilos dependientes y quizá unos cuantos hilos cortos independientes o hilos más cortos
O… Un bonche de hilos cortos independientes
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.
Intel® Software College
29
Analogía con el Tráfico de una Autopista ¿Qué se puede lograr con el paralelismo?
Suponer que tenemos un convoy largo de carga: troncos de madera…
Una aplicación no paralelizada
Vamos a dividir en 4 camionetas más pequeñas…
Cuatro hilos independientes
Ahora, podemos poner una camioneta en cada carril…
Explotar los múltiples núcleos…
La carga llega mucho más rápido!
Resultado: Mejora la tasa de trabajos!
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.
Intel® Software College
30
Analogía con el Tráfico de una Autopista Vehículos en la autopista…
Ejecuta
Vehículos (Hilos) de diferentes colores son independientes entre ellos… y por lo tanto pueden moverse en paralelo en otros carriles (ser ejecutados paralelamente en múltiples núcleos)
Vehículos (Hilos) del mismo color son dependientes entre ellos… y por lo tanto no se pueden mover en paralelo en otros carriles, deben seguirse entre ellos.
Esos vehículos del mismo color (hilos dependientes) y vehículos grandes (hilos grandes no optimizados) generan carriles vacíos (utilización ineficiente del procesador)…
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.
Intel® Software College
31
Analogía con el Tráfico de una AutopistaPlanificación del Sistema Operativo
Planificador del SO (Selecciona el carril)
Debe esperar la camioneta.
El SO piensaCarril 1
1
2
3
4
Carril 2
El Sistema Operativo no puede romper una aplicación en hilos…
… solo puede planificar hilos existentes.
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.
Intel® Software College
32
Analogía con el Tráfico de una Autopista Escenario Ejemplo
Ejecuta
Vehículos grandes (hilos grandes) y vehículos del mismo color (hilos dependientes) causan tráfico torpe.. Los carros más pequeños (hilos pequeños independientes) permiten un flujo más rápido…
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.
Intel® Software College
33
Analogía con el Tráfico de una AutopistaResumen
Dividir un hilo grande en n hilos más pequeños e independientes permite que el SO los planifique en diferentes núcleos… incrementando la tasa de trabajos.
Igual que en la autopista, los vehículos grandes causan que el tráfico se entorpezca… Los pequeños permiten un flujo más rápido…
El SO ayuda a manejar el tráfico, pero el desarrollador se asegura que cada carril pueda tener suficiente tráfico para que el SO lo pueda planificar, permitiendo la mayor tasa de trabajos de carga (datos).
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.
Intel® Software College
34
Aceleración
La concurrencia está limitada por la naturaleza de la aplicación
Es el acuerdo más importante
Si s es la fracción de trabajo serial intrínsico
El tiempo de computación usando p núcleos:
pts
st ss
)1(
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.
Intel® Software College
35
Tiempo en Paralelo:
Sección Serial Sección Paralela
ts
sts (1-s)ts
(1-s)ts/p
tp
p núcleos
p
tsstT s
sp
)1(
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.
Intel® Software College
36
Ley de Amdahl
Si s es la fracción de tiempo secuencial, entonces, la aceleración es 1/s
Aceleración
p
tsstT s
sp
)1(
p
s
tt
pS )(
sp
p
ptsst
tpS
ss
s
)1(1)1()(
spSlimp
1)(
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.
Intel® Software College
38
Aceleración (Simple)
Medir qué tanto se acelera la ejecución de cómputo vs. el mejor código serial
• Tiempo serial dividido entre el tiempo paralelo
Ejemplo: Pintar una barda de tablitas• 30 minutos de preparación (serial)• Un minuto para pintar una tabla• 30 minutos para limpiar (serial)
Por lo tanto, 300 tablas toman 360 minutos (tiempo serial)
Speedup and Efficiency
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.
Intel® Software College
39
Calculando Aceleración
Que pasa si el dueño de la barda usa un spray para pintar 300 tablas en una hora ?• Mejor algoritmo serial
• Si no hay sprays disponibles para varios pintores, cuál es la máxima paralelización?
Numero de pintores
Tiempo Aceleración
1 30 + 300 + 30 = 360 1.0X
2 30 + 150 + 30 = 210 1.7X
10 30 + 30 + 30 = 90 4.0X
100 30 + 3 + 30 = 63 5.7X
Infinito 30 + 0 + 30 = 60 6.0X
Illustra la ley de Amdahl
La aceleración potencial está restringida por la porción serial
Speedup and Efficiency
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.
Intel® Software College
40
Eficiencia
Medir que tan efectivamente los recursos de cómputo están ocupados
• Aceleración dividida entre el número de hilos• Expresada como porcentaje promedio de tiempo no ocioso
Numero de pintores
Tiempo Aceleración Eficiencia
1 360 1.0X 100%
2 30 + 150 + 30 = 210 1.7X 85%
10 30 + 30 + 30 = 90 4.0X 40%
100 30 + 3 + 30 = 63 5.7X 5.7%
Infinito 30 + 0 + 30 = 60 6.0X Muy baja
Speedup and Efficiency
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.
Intel® Software College
42