La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Programación Multi-core: Conceptos básicos

Presentaciones similares


Presentación del tema: "Programación Multi-core: Conceptos básicos"— Transcripción de la presentación:

1 Programación Multi-core: Conceptos básicos
Intel Software College

2 Objetivos Al término de este módulo estará familiarizado con los concéptos básicos de: Hilos Programación multihilos Nota: Los hilos serán agentes realizando trabajos No se usarán ejemplos de código Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Outline the objectives of this module [Details] No code segments will be used to illustrate any of the concepts. The instructor can give verbal illustration of code, but everything in this presentation is done with “agents” to perform work concurrently. Multi-core Programming: Basic Concepts

3 Agenda Conceptos básicos Conceptos de diseño Conceptos de depuración
Conceptos de rendimiento Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Put forth the Agenda topics of the module. [Background] The order and list of topics corresponds to the Threading Methodology which is the first module of the second day. Multi-core Programming: Basic Concepts

4 Agenda Conceptos básicos Procesos e hilos Paralelismo y concurrencia
Conceptos de diseño Conceptos de depuración Conceptos de rendimiento Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Expand on the first agenda topic to be covered. Multi-core Programming: Basic Concepts

5 Porque usar hilos Beneficios Riesgos Mayor rendimiento
Processes & Threads Porque usar hilos Beneficios Mayor rendimiento Método sencillo para sacar provecho de arquitecturas multi-core Mejor utilización de recursos Reduce latencia (incuso en sistemas con un procesador) Compartición eficiente de los datos Compartir datos a través de la memoria es más eficiente que pasar mensajes Riesgos Incrementa la complejidad de la aplicación Difícil depurar (condiciones de concurso, interbloqueos, etc.) Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Illustrate the advantages and point out some of the disadvantages of using threads [Details] The most prominent benefit is better performance and the ability to take advantage of the multi-core processors coming out. Reduction of latency can be seen with single core processors. If a thread blocks for some external event (memory access or I/O), having another thread ready to execute will keep processor busy. Distributed memory systems (clusters) share data through message-passing methods. This involves an active “send” and “receive” operation be executed by the participating processes. The data is moved into kernel space, transferred through a network card, across a wire, into the receiver network card, into kernel memory, and then into user memory of the receiver. To sue shared memory to share data, thread 1 writes to a common, agreed upon location, that is subsequently read by the receiving thread. This transfer, of course, must be coordinated in order to be sure the read of memory is not done before the write. Any changes to code to add threads will increase maintenance costs and complexity of the code. New error classes are going to be encountered with multithreaded applications. These will be covered in more detail (and how to detect and fix them) in subsequent modules. Multi-core Programming: Basic Concepts

6 Procesos e Hilos main() … Code segment Data segment
Los sistemas operativos modernos cargan programas como procesos Tiene recursos Ejecución Un proceso inicia ejecutando su punto de entrada como un hilo Los hilos pueden crear otros hilos dentro del proceso Cada hilo obtiene su propio stack Todos los hilos dentro de un proceso comparten código y segmentos de datos Stack thread main() thread Code segment Data segment Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Show the difference between processes (which students should have heard about) and threads (which the students may not know). [Details] Operating system theory categorizes processes as having the two roles listed here. Resource holder refers to the job of the process to “hold” memory, file pointers, and other resources of the system that have been assigned to the process. Execution is the thread within the process that processes the instructions of the code and utilizes the resources held. When the process is terminated, all resources are returned to the system. Also, any active threads that might be running are terminated and the resources assigned to them (stack and other local storage, etc) are returned to the system [Background] There are ways to have threads continue to execute after the parent process has terminated, but this topic will not be covered. Multi-core Programming: Basic Concepts

7 Concurrencia vs. Paralelismo
Concurrency vs. Parallelism Concurrencia vs. Paralelismo Concurrencia: dos o más hilos están en progreso al mismo tiempo: Paralelismo: dos o más hilos están ejecutandose al mismo tiempo Se requieren varios núcleos Hilo 1 Hilo 2 Hilo 1 Hilo 2 Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Show the difference between the common terms “parallel” and “concurrent”. [Details] Build shows that concurrent threads can execute on a single processor. Thus, threads can be “in progress” at the same time even on single cores. Parallelism requires multiple cores. [Background] Common use may have these two terms used interchangeably. This is okay, but Concurrent would be a super-set that included Parallel as a special case (which requires hardware). Multi-core Programming: Basic Concepts

8 Agenda Conceptos básicos Conceptos de diseño Conceptos de depuración
¿Paralelizando por funcionalidad o por rendimiento? ¿Paralelizando por tasa de trabajos o tiempo de retorno? Descomposición del trabajo Conceptos de depuración Conceptos de rendimiento Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Transition slide to the next set of topics. [Details] Don’t skip transition slides. Give students the chance to be able to switch gears onto new topic set. Multi-core Programming: Basic Concepts

9 Creando hilos por funcionalidad
Threading for Functionality or Performance? Creando hilos por funcionalidad Asignar hilos a diferentes funciones de la aplicación El método más simple ya que no hay como sobreponer Ejemplo: Construyendo una casa Albañil, carpintero, pintor, plomero,… Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Describe and define the idea of threading for functionality. [Background] This is the most likely case of how applications are threaded if ISVs claim to have threaded applications. A thread for input, a thread for the GUI, a thread for the computation, and a thread for output. This kind of scheme can make it easier to control the execution of the concurrent functions within an application. Much easier than trying to switch functionality within a completely serial code. [Questions to ask Students] Q: What kinds of dependencies are there between the tasks that go into building a house? A: Things like cannot start the roof until the walls are build; can’t put down carpet until the floor has been installed. Multi-core Programming: Basic Concepts

10 Hilos para el rendimiento
Threading for Functionality or Performance? Hilos para el rendimiento Mejora el rendimiento de computadoras Paralelizar para mejorar el tiempo de retorno o la tasa de trabajos Ejemplos Línea de ensamblado de automóviles Cada trabajador hace una función asignada Buscando piezas desde Skylab Divide el area a buscar Servicio postal de USA Oficinas postales, clasificadores, entrega Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Introduce and define the concept of threading for performance. [Details] Multiple assembly line workers can build cars faster then a singe worker. Divide up the search area into multiple segments and assign a worker to search a segment. Faster than having one person search the entire space. Any postal service will have multiple branches and multiple workers. Specialized workers (sorters, delivery people, long distance transportation) cooperate in order to deliver thousands of letters between people in a faster time. [Background] This is probably the most important slide in any course on threading that includes this module. If an ISV has threaded an application, it is likely to have been done by threading for functionality. This slide and all others in this module (as well as most every other module in a course) will be focused on threading for performance. Even if an app has been threaded for functionality, the whole app works well on a single core. To take advantage of the new multi-core processors, it is unlikely that ISVs can thread more functions. However, they can, hopefully, take advantage of the extra cores by looking at the computationally intense portions of the app and threading them further for performance. Multi-core Programming: Basic Concepts

11 Threading for Throughput or Turnaround?
Tiempo de retorno Complete una sola tarea en la menor cantidad de tiempo Ejemplo: Poner la mesa para la cena Uno pone los platos Uno que dobla y pone las servilletas Uno que ponga los cubiertos Cucharas, cuchillos, tenedores Uno que ponga los vasos Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define the concept of Turnaround as a goal for performance threading. [Details] The hidden actor in this slide is a group of waiters. Assign tasks to waiters (plates, napkins, silverware, etc.) to set a single table faster. Weather forecasting is another example. If it takes 72 hours to compute tomorrow’s forecast, this is too long. The single task of forecasting weather for tomorrow, needs to be done in a smaller amount of time. Multi-core Programming: Basic Concepts

12 Threading for Throughput or Turnaround?
Tasa de trabajos Completar la mayor cantidad de trabajos en un tiempo fijo Ejemplo: Poner las mesas de un banquete Varios meseros hacen mesas separadas Meseros especializados para platos, vasos, cubiertos, etc. Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define the concept of Throughput as a goal for performance threading. [Details] One waiter can be assigned to do a complete table; thus, one waiter per table would be needed. Waiters can specialize. That is, one waiter can do all the plates on all the tables, another could do all the glasses, etc. Multi-core Programming: Basic Concepts

13 Descomposición de una tarea
Task Decomposition Descomposición de una tarea Divide el tiempo de computación basado en un conjunto natural de tareas independientes Asignar datos para cada tarea conforme se van necesitando Ejemplo: Pintar por números Pintando un color es una sola tarea Número de tareas = número de colores Dos artistas: uno hace los impares y otro los pares 1 2 3 4 5 6 7 9 8 10 11 Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define the concept of task decomposition for multithreaded apps. [Details] The build first shows a sample blank canvas. Then, two artists are brought up. Each artist would be assigned a subset of the colors and paints all the spaces with the appropriate labels. [Background] Paint-by-numbers was a popular hobby in the US in the ‘50s and ‘60s. Kits that were available included paint (numbered, of course), brushes, and the blank picture with the appropriate numbers labeling each different color section. Task decomposition and data decomposition can often be applied to the same problem. They are not necessarily exclusive. It may just be a matter of perspective on the part of the programmer as to which method is chosen. The picture can be divided into two halves and each artist is assigned one half and all the colors needed. This would be a data decomposition of the example. Multi-core Programming: Basic Concepts

14 Descomposición de los datos
Data Decomposition Descomposición de los datos Conjuntos de datos grandes cuyos elementos pueden computarse de manera independiente Divide datos y asocia la computación entre los hilos Ejemplo: Calificar exámenes Varios profesores con la misma llave ¿Qué sucede si se necesitan diferentes llaves? Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define the concept of data decomposition for multithreaded apps. [Details] The large stack of tests to be graded is the data for the job. In order to cut down on cheating, multiple variations of the test could be created and delivered. Two different versions could be used to alternate exams within a row, and two other versions could be used to alternate exams from one row to the next. Thus, four exam versions would prevent anyone from being able to copy answers from the persons to their left, right, in front, or behind. With four different versions of the exam and four different keys, would this still need a data decomposition or a task decomposition solution. (A: Depends. If each grader has all four keys and know how to determine which key should be used, this is still data decomposition; if graders take a single key, then that would be a task decomposition.) [Background] Task decomposition and data decomposition can often be applied to the same problem. They are not necessarily exclusive. It may just be a matter of perspective on the part of the programmer as to which method is chosen. If there are different types of questions in the exam (multiple choice, true/false, essay, etc.), the job of grading could be divided based on the tasks to specialists in each of those question types. Multi-core Programming: Basic Concepts

15 Agenda Conceptos basicos Conceptos de diseño Conceptos de depuración
Condiciones de concurso y sincronización Interbloqeo Conceptos de rendimiento Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Transition slide to the next set of topics. [Details] Don’t skip transition slides. Give students the chance to be able to switch gears onto new topic set. Multi-core Programming: Basic Concepts

16 Condiciones de concurso
Race Conditions and Synchronization Condiciones de concurso Los hilos “compiten” entre ellos mismos por recursos Se asume el orden de ejecución, pero no se garantiza Lo más común es el conflicto en el almacenamiento Acceso concurrente de la misma dirección de memoria por varios hilos Al menos un hilo está escribiendo Ejemplo: El juego de las sillas Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define the concept of a data race between threads. [Details] The slide build removes chairs one at a time as the children playing the game race to find an empty seat when the music stops. The order of how multiple people land in the same chair determines who continues and who is eliminated. If the chairs were memory locations, the value of a location that had multiple threads trying to write to that location, would be the value that was last written. If the computation depends on one answer over all the others end up in the contended location, the threaded code has an assumed execution order (the serial order), but there has been nothing to guarantee that the desired order is preserved. [Transition] “Now that we know what data races are and how they are commonly caused, how can we make sure these problems don’t appear in our threaded applications?” Multi-core Programming: Basic Concepts

17 Exclusión mutua Región crítica Exclusión mutua
Race Conditions and Synchronization Exclusión mutua Región crítica Porción de código que accesa (lee y escribe) variables compartidas Exclusión mutua Lógica del programa que forza a un hilo para que acceda la sección crítica. Permite corregir estructuras de programación para evitar condiciones de concurso Ejemplo: Depositar en una caja de seguridad Quienes la atienden aseguran la exclusión mutua Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Describe and define the concept of mutual exclusion between threads and a critical region of code within a threaded application. [Details] Unless multiple people arrive as a group, only one person at a time can view a safe deposit box. If another authorized person arrives while the box is “out,” that newly arrived person must wait for the return of the box by the original viewer. [Transition] “And how do we typically enforce or create mutual exclusion on critical regions of code?” Multi-core Programming: Basic Concepts

18 Race Conditions and Synchronization
Sincronización Objetos de sincronización usados para forzar la exclusión mutua Locks, semaforos, secciones críticas, eventos, variables condición, atómicas Un hilo “retiene” objetos de sincronización; otros hilos deben esperar Al término, los hilos que retienen los objetos los liberan; el objeto se le entrega a un hilo que esté esperando Ejemplo: Biblioteca Una persona tiene prestado un libro Otros deben esperar a que el libro regrese Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Introduce and describe the general idea of an object that can be used to synchronize/coordinate execution of threads with each other. [Questions to ask Students] Q: Once the book is returned to the library, who will get to check it out next? A: Depends on policy of library. Could be next person on the list, or someone most important to be moved to top of list (priority), or next patron that asks for the book before anyone on the list has been contacted. Multi-core Programming: Basic Concepts

19 Sincronización por barreras
Race Conditions and Synchronization Sincronización por barreras Los hilos se detienen en un punto de ejecución Los hilos que esperan están ociosos; sobrecarga Cuando los hilos llegan, todos arrancan Ejemplo: Linea de salida en una carrera 9 Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define and introduce the concept of a barrier synchronization. [Details] A barrier synchronization is used when all threads must have completed a portion of the code before proceeding to the next section of code. This is usually done to ensure that all updates in the section of code prior to the barrier have completed before they are used in the code past the barrier. The build of the slide draws the start line; the “racers” come up to the start line; and are let go to continue processing. Multi-core Programming: Basic Concepts

20 Deadlock Interbloqueo Los hilos esperan por un evento o condición que nunca sucede Ejemplo: Intersección de coches Los coches no pueden echarse en reversa ¿Qué es un “Livelock”? Los hilos cambian de estado en respuesta de otros Robin Hood y Pequeño Juan en un puente angosto Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Introduce the concepts of Deadlock and Livelock [Details] This is a simplified definition of deadlock, but it is sufficient to understand the concept. There are four conditions that must be satisfied when threads are contending for resources in order to have a deadlock situation. The four conditions will not be explained in this lecture. The picture shows a traffic deadlock. You may need to have the audience imagine that no driver is willing to back up and that trees, mailboxes, lampposts, or some other obstacles are positioned on the corners that would prevent cars from turning right. Livelock is when threads aren’t making progress on assigned computations, but are not sitting waiting for an event that will not happen. The threads in a livelock situation are trying to overcome some obstacle presented by another thread that is, likely, dong the same thing. Another example is trying to get around someone that you meet in a hallway too narrow to accommodate two people abreast. [Background] Dining Philosophers is a classic problem in deadlock and deadlock avoidance. The four necessary conditions required for deadlock, from Wikipedia article on “Deadlock” (26 JUN 06): Also known as Coffman conditions from their first description in a 1971 article by E. G. Coffman. Mutual exclusion condition: a resource is either assigned to one process or it is available Hold and wait condition: processes already holding resources may request new resources No preemption condition: only a process holding a resource may release it Circular wait condition: two or more processes form a circular chain where each process waits for a resource that the next process in the chain holds Multi-core Programming: Basic Concepts

21 Agenda Conceptos básicos Conceptos de diseño Conceptos de depuración
Conceptos de rendimiento Aceleración y eficiencia Granularidad y balanceo de carga Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Transition slide to the next set of topics. [Details] Don’t skip transition slides. Give students the chance to be able to switch gears onto new topic set. Multi-core Programming: Basic Concepts

22 Speedup and Efficiency
Aceleración (Simple) Medir que tanto se acelera la ejecución de cómputo vs. el mejor código serial Tiempo serial dividido por 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) Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define the concept of speedup as a metric of how well performance improves from serial execution to threaded. [Details] There are several different types of speedup in the literature. We are going to use the most basic, and simple version. The fence used in the example can be any kind of fence that has small atomic units: bricks, slats, stones. Serial preparation time would include things like getting tarps laid out, shaking and opening paint cans, getting brushes out. Serial cleanup time would be putting things away or washed up. [Transition] “If everyone understands the parameters of the example, let’s see how we compute the speedup when using different numbers of painters.” Multi-core Programming: Basic Concepts

23 Calculando Aceleración
Speedup and Efficiency Calculando Aceleración Numero de pintores Tiempo Speedup 1 = 360 1.0X 2 = 210 1.7X 10 = 90 4.0X 100 = 63 5.7X Infinito = 60 6.0X Illustra la ley de Amdahl La aceleración potencial está restringida por la porción serial 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? Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Show how speedup is computed in fence painting example for various numbers of painters. [Details] The fence graphic along the right edge will be automatically put in after 5 seconds. Infinite painters is the theoretical maximum and means that the time to paint the fence can be as close to zero as desired. Build shows box relating discussion to Amdahl’s law. The use of a spray gun introduces a better serial algorithm. Future speedup calculations must then use this serial algorithm timing (since no one would go back to an inferior serial algorithm when given the chance to use something better). The new serial time with the spray gun is then 120 minutes ( ) with the same serial setup and cleanup time. The assumption in the example is that the spray gun cannot be used if there are more than one painter, thus, there is no advantage from the spray gun in the parallel case. The theoretical maximum speed up, in light of the spray gun, is 2.0X with an infinite number of painters (120 / 60 = 2.0). Multi-core Programming: Basic Concepts

24 Speedup and Efficiency
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 = 210 1.7X 85% 10 = 90 4.0X 40% 100 = 63 5.7X 5.7% Infinito = 60 6.0X Muy baja Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define and show how to compute the Efficiency metric for parallel processors (threads). [Details] Efficiency is a measure of how busy the threads are during parallel computations. Low efficiency numbers may prompt the user to run the application on fewer threads/processors and free up resources to run something else (another threaded process, other user’s codes). Build transforms some potential workers into lay-abouts enjoying not having to do much work, but still getting paid for the whole time that the job is being conducted (all the serial time for set up and cleaning). Multi-core Programming: Basic Concepts

25 Granularity and Load Balance
Granularidad Pobremente definido como tasa de computación a sincronización Asegurarse que hay suficiente trabajo que merezca cómputo en paralelo Ejemplo: Dos granjeros dividen un campo. ¿Cuántos granjeros más se pueden agregar? Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Describe and define the concept of Granularity. [Details] Granularity is more difficult to quantify than parallel speedup or efficiency. The ratio of computation to synchronization is only a loose measure. Granularity is better explained by example. The harvest illustration is meant to show that work cannot be divided indefinitely. The problem is initially coarse-grained but becomes successively finer as the field is divided. At some point the partitions become so small that the farmers get in each other’s way. The overhead of synchronizing so many farmers begins to outweigh the benefit of parallelism. Build shows 5 farmers in a large field. Next step is to show 20 more. The idea is that having a half acre per farmer is worth the cost to coordinate, but a square meter of field per farmer is much too small. The effective amount of work (speedup) will be diminished by the overhead of coordinating all the framers to work in parallel. Multi-core Programming: Basic Concepts

26 Granularity and Load Balance
Balanceo de carga La distribución más efectiva es tener la misma cantidad de trabajo por hilo Los primeros hilos que terminan se convierten en ociosos Los hilos deben terminar casi al mismo tiempo Ejemplo: Poner las mesas de un banquete Lo mejor es asignar la misma cantidad de mesas a cada cuadrilla Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Define and illustrate the idea of load balance between threads. [Details] Waiter with more work will keep his other waiter friends from getting to their after-work entertainments as soon as they could. Even with the same number of tables assigned, there may be more work to be done on some tables. For example, some tables may have only had a few diners or other groups were extremely messy and requires more effort. Be careful that the work is divided equally, not just the number of tasks (which may require different amounts of work). Multi-core Programming: Basic Concepts

27 Programacuón Multi-core: Conceptos básicos, ¿Qué se ha cubierto?
Procesos e hilos Paralelismo y concurrencia Conceptos de diseño ¿Paralelizando por tasa de respuesta o tiempo de retorno? ¿Paralelizando por funcionalidad o rendimiento? Descomposición del trabajo Conceptos de depuración Condiciones de concurso y sincronización Interbloqueo Conceptos de rendimiento Aceleración y eficiencia Granularidad y carga de trabajo Multi-core Programming: Basic Concepts Speaker’s Notes [Purpose of this Slide] Summary slide to review all the topics that have been covered. Multi-core Programming: Basic Concepts

28 Multi-core Programming: Basic Concepts
This should always be the last slide of all presentations. Multi-core Programming: Basic Concepts

29 Diapositivas alternativas
Multi-core Programming: Basic Concepts

30 Multi-core Programming: Basic Concepts
Threading for Throughput or Turnaround? Tiempo de retorno Completar una sola tarea en la menor cantidad de tiempo Ejemplo: Decoración de un pastel Betún Uno pone betún arriba, otro hace los lados Decoración Uno hace los bordes Uno pone las flores Uno escribe “Happy Birthday” Multi-core Programming: Basic Concepts

31 Multi-core Programming: Basic Concepts
Threading for Throughput or Turnaround? Tasa de trabajos Completar la mayor cantidad de trabajos en una cantidad de tiempo fija Ejemplo: Decorar pasteles Muchos pasteleros haciendo toda la decoración Linea de ensamble de quienes ponen el betún y los decoradores Multi-core Programming: Basic Concepts

32 Multi-core Programming: Basic Concepts
Threading for Throughput or Turnaround? Tiempo de retorno Completa una sola tarea en la menor cantidad de tiempo Ejemplo: Los padres están por llegar en una hora Hugues limpia la sala Otto limpia el baño Thomas limpia la cocina Multi-core Programming: Basic Concepts

33 Multi-core Programming: Basic Concepts
Threading for Throughput or Turnaround? Tasa de trabajos Completa la mayor cantidad de tareas en un tiempo Example: Producir pines “Una persona traza el alambre, otro lo estira, un tercerlo lo corta, un cuarto le saca la punta, un quinto arregla la parte superior;…” (A. Smith 1776) Multi-core Programming: Basic Concepts

34 Paralelizando por funcionalidad
Threading for Functionality or Performance? Paralelizando por funcionalidad Asignar hilos a funciones separadas El método más sencillo ya que no hay como sobreponer Ejemplo: Dirigiendo un equipo de americano Coach de cabeza, coach de posiciones, coach de equipos especiales Multi-core Programming: Basic Concepts

35 Multi-core Programming: Basic Concepts
Deadlock Interbloqueo Los hilos esperan algún evento o condición que nunca sucederá Ejemplo: Intersección de tráfico Los autos no se pueden echar para atrás ¿Qué es un Livelock? Los hilos cambian de estado en respuesta de otro Robin Hood y el pequeño Juan en un puente angosto Multi-core Programming: Basic Concepts


Descargar ppt "Programación Multi-core: Conceptos básicos"

Presentaciones similares


Anuncios Google