Corrigiendo Errores en la Paralelización con Intel® Parallel Inspector.

Slides:



Advertisements
Presentaciones similares
Cable & Wireless Panamá. Entrar a Inicio, Programas y buscar Windows Live.
Advertisements

Juan F. Velazquez Mayra E. Beltran Jaime Lopez
Metodología de programación paralela
Programación Multi-core: Conceptos básicos
Subrutinas y Funciones Leonel Morales Díaz Ingeniería Simple Disponible en: Copyright.
Como Configurar el Internet
PLEASE READ (hidden slide) This template uses Microsofts corporate font, Segoe Segoe is not a standard font included with Windows, so if you have not.
Quality Management (J07) Overview Argentina
A la izquierda A la derecha Todo recto
You will now learn how to use the subjunctive with verbs and expressions of will and influence. Copyright © 2008 Vista Higher Learning. All rights reserved.
Bases de Datos Espaciales SPATIAL QUERY LANGUAGES
PIPELINING - INTRODUCCION
ARQUITECTURA DE COMPUTADORES - PIPELINING
Conjunctions are words or phrases that connect other words and clauses in sentences. Certain conjunctions commonly introduce adverbial clauses, which describe.
Copyright © 2008 Vista Higher Learning. All rights reserved The past perfect indicative (el pretérito pluscuamperfecto de indicativo) is used to.
Programando con Hilos POSIX* Intel Software College.
Programación con OpenMP* Intel Software College. Copyright © 2006, Intel Corporation. All rights reserved. Intel and the Intel logo are trademarks or.
Hilos Capítulo 5 Silberschatz Galvin. Copyright © 2006, Intel Corporation. All rights reserved. Intel and the Intel logo are trademarks or registered.
Programando con Hilos de Windows* Intel Software College.
Programando con OpenMP*
Corrigiendo Errores de Paralelización con Intel® Thread Checker para Hilos Explícitos Intel Software College.
1 Introducción Seminario sobre las prácticas curriculares en América Central Guatemala, Abril 2006 Xavier ROEGIERS y Alexia PEYSER.
Lenguajes de Programación Soluciones a pruebas de nivel
COMO USAR LA PC POR PIMERA VEZ SARAITH MACHORRO PACHECO 28 JOSE ALBERTO LOPEZ RAMIREZ 27 CAPACITACION DE INFORMATICA GRUPO 302.
Examen FRAD Empezar. 1. ¿Cu á l es la diferencia entre FRAD y FRANAR? 1.FRAD son las siglas de un grupo de trabajo de OCLC y FRANAR las siglas de un grupo.
Microsoft Office Power Point, es una herramienta que nos proporciona Microsoft, para editar presentaciones graficas, de tal forma que se nos feliciten.
Libro de Clases Electrónico Administrativo OTEC
Instrumentación Industrial
LUIS GONZALES SÁNCHEZ RESPONSABLE PROCESO DE REGISTRO DE DNI DE ESTUDIANTES UNIDAD DE GESTIÓN EDUCATIVA LOCAL LAMAS UNIDAD EJECUTORA 305.
Base de datos y Microsoft Access
Entrada y salida Fundamentos de programación/Programación I
ERASMO AGUILAR SIG FARQ UNI
EL SISTEMA OPERATIVO Presentación realizada por Virgilio Marco Aparicio Profesor de Apoyo al Área Práctica. IES Tiempos Modernos. ZARAGOZA.
MATLAB.
XAGUAR AUTOMATION Xaguar Automation es una empresa Mexicana dedicada a la solución de problemáticas, orientadas al sector industrial en el área de automatización.
Visual basic Curso de Habilitación Laboral IV. ¿Qué es Visual Basic Visual Basic es uno de los tantos lenguajes de programación que podemos encontrar.
Un constructor es un método que inicia un objeto inmediatamente después de su creación. De esta forma nos evitamos el tener que iniciar las variables.
Descripción general de Sharpdesk 3.1
Análisis de la Dinámica no Lineal y Cambios de Complejidad en
MS Tutorial de Medidores RQ Consultoría Técnica, S de RL de CV Revisión 27 Septiembre 2008 Este Turorial le ayudará a entender: 1.¿Que es un medidor?
TALLER BÁSICO DE VISUAL BASIC Por: Juan Alfredo Garduño Arias.
CENTRO DE BACHILLERATO TECNOLOGICO INDUSTRIAL Y DE SERVIVCIOS No 3
CONSTRUCCIÓN Y ARQUITECTURA DEL SOFTWARE
Para entrar al sistema GSFS de LG sólo se debe utilizar el Internet Explorer. Ningún otro navegador funciona.
Comunidades emprendedoras e innovadoras Agendas públicas... de desarrollo local Lic. Patricia Alessandroni 22 de marzo de 2011 Mar del Plata.
Tecnológica, posibilidad tecnológica de provisión sobre múltiples redes tanto de los servicios tradicionales de comunicaciones así como de sus innovaciones.
Animaciones en la Web Animación GIF Animación Shockwave Flash
O Skydrive o Características Características o Privacidad Privacidad o App App o Ventajas Ventajas o Desventajas Desventajas o Movie Maker Movie Maker.
Procedimientos Almacenados y Disparadores
Programación Concurrente en Java
Copyright © 2008 SERVIR Project. All rights reserved. SERVIR Data Portal Workshop SERVIR Map Maker Studio - MMS -
$1 Million $500,000 $250,000 $125,000 $64,000 $32,000 $16,000 $8,000 $4,000 $2,000 $1,000 $500 $300 $200 $100 Bienvenidos.
Español II Srta. Forgue El 11 de abril de La clase de hoy El 11 de abril Ahora mismo: Mirar el tutorial de 7.1 Repaso: Corregir INTÉNTALO en la.
Srta. Forgue El 29 de enero de 2011
Srta. Forgue El 14 de febrero
Srta. Forgue El 12 de enero de Ahora mismo Completa los ejercicios con la forma correcta del mandato según el sujeto en paréntesis. Caminar (Uds.)
SRTA. FORGUE EL 14 DE ENERO DE 2011 La clase de español II.
Srta. Forgue El 6 de mayo de 2011
1 SQL Server 2008 : Service Pack 1 SQL-FEST (Spain) Sep 23 rd 2008 Marcos Celada SQL Server Support Engineer Microsoft
Entender qu é es cloud computing Cloud computing seg ú n Microsoft: Azure.NET Services SQL Services Live Services.
Su Negocio Conectado. VisibilidadVisibilidad ColaboraciónColaboración PlanificaciónPlanificación EjecuciónEjecución Build Connections.
para desarrolladores Minimizar el cambio Concentrarse en estabilidad, confiabilidad y rendimiento. Ayudar a mejorar la productividad Reducir la curva.
11 Servidores basados en Arquitectura Intel. 2 * Other names and brands may be claimed as the property of others. Copyright © 2008, Intel Corporation.
ESTRUCTURAS DE CONTROL
1 AA-DG/MKC | 03/2012 | © Robert Bosch GmbH All rights reserved, also regarding any disposal, exploitation, reproduction, editing, distribution,
EL TRANSPORTE FM USBOTQPSUF. ¡A hablar! Responde a las preguntas.
1 Chapter 8 Scope Dale/Weems/Headington. 2 Tópicos del Capítulo 8 l Local Scope vs. Global Scope of an Identifier l Detailed Scope Rules to Determine.
Estructuras de Datos y Algoritmos TDA LISTA. Metáfora del TDA (repaso) Conjunto de operaciones forman una pared forman una interfase entre los programas.
INTEL CONFIDENTIAL Metodología de programación paralela Intel Software College.
Conceptos básicos de.NET Explorar el entorno de desarrollo Crear un proyecto Visual Basic.NET Use Visual Studio.NET Acceso a datos Depurar e implantar.
Transcripción de la presentación:

Corrigiendo Errores en la Paralelización con Intel® Parallel Inspector

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. 2 Intel® Parallel Inspector Objetivos Al término de este módulo, será capaz de: Usar Parallel Inspector para detectar e identificar una variedad de problemas de correctud de la paralelización en aplicaciones con hilos Determinar si las funciones de librería son thread-safe

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. 3 Intel® Parallel Inspector Agenda ¿Qué es Intel® Parallel Inspector? Detectando condiciones de concurso Detectando interbloqueos potenciales Verificar si las librerías son thread-safety

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. Motivación Desarrollar aplicaciones con hilos puede ser una tarea completa Nuevos problemas a causa de la interacción entre hilos concurrentes Condiciones de concurso o conflictos en el almacenamiento Más de un hilo accede memoria sin sincronización Deadlocks Un hilo espera un evento que nunca sucederá

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. 5 Intel® Parallel Inspector Herramienta de depuración para software multihilos Complemento de Microsoft* Visual Studio* Encuentra errores en software multihilos Localiza los errores rápidamente que pueden llevar días usando métodos y herramientas tradicionales Aísla problemas, no los síntomas Un error no tiene que ocurrir para encontrarlo

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. Características de Intel® Parallel Inspector Soporta diferentes compiladores GNU C Microsoft* Visual* C++.NET* Intel Parallel Composer Ver código fuente para diagnósticos Ayuda de Un-click para diagnósticos Posibles causas y sugerencias para solucionarlo 6 Intel® Parallel Inspector

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. 7 Intel® Parallel Inspector Parallel Inspector: Análisis Dinámico como se ejecuta el software Datos (workload) – arrojados por la ejecución Incluye monitoreo de: Hilos y APIs de Sincronización usadas Orden de ejecución de hilos El planificador impacta en los resultados Accesos a memoria entre hilos El código debe ejecutarse para ser analizado

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. Parallel Inspector: Antes de Comenzar Instrumentación: background Añade llamadas a la librería para registrar información Hilos y APIs de sincronización Accesos a memoria Incrementa el tiempo y tamaño de ejecución Usar conjuntos de datos pequeños El tiempo y espacio de ejecución se expande Múltiples ejecuciones sobre diferentes rutas dan mejores resultados La selección de carga de trabajo es importante

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. Consejos para la Carga de Trabajo Ejecutar el código problema una vez por hilo a identificarse Utilizar el conjunto de datos de trabajo lo más pequeño posible Minimizar el tamaño del conjunto de datos Tamaños de imágenes más pequeños Minimizar iteraciones de ciclos o escalas de tiempo Simula minutos en vez de días Minimizar tasas de actualización Menos cuadros por segundo Encuentra errores de paralelización 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. 10 Intel® Parallel Inspector Compilando para el Parallel Inspector Compilar Genera información simbólica ( -g ) Deshabilita optimizaciones ( -O0 )

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. 11 Intel® Parallel Inspector Instrumentación binaria Construir binario con un compilador soportado Ejecutando la aplicación Debe ejecutarse dentro del Parallel Inspector La aplicación es instrumentada cuando se ejecuta

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. Iniciando con Parallel Inspector Construye la versión Debug de la aplicación estableciendo las banderas apropiadamente 12 Intel® Parallel Inspector

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. Iniciando con Parallel Inspector Selecciona Parallel Inspector del menú de herramientas 13 Intel® Parallel Inspector Puedes seleecionar para buscar Errores de la memoria Errores 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. Iniciando con Parallel Inspector Aparece la ventana de Configración del Análisis 14 Intel® Parallel Inspector Selecciona el nivel de análisis que será llevado a cabo por Parallel Inspector El análisis más profundo, el más completo en resultados y el más largo en tiempo de ejecución Click en Run Analysis

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. Iniciando con Parallel Inspector Los resultados iniciales (crudos) vienen después del análisis 15 Intel® Parallel Inspector Haz click en el botón Interpret Results para filtrar los datos crudos en resultados más entendibles

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. Iniciando con Parallel Inspector Los resultados del análisis se reúnen en categorías relacionadas 16 Intel® Parallel Inspector Haz Doble-click en una linea del pánel de conjuntos de problemas para ver el código fuente que generó el diagnóstico

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. Iniciando con Parallel Inspector Se pueden ver las líneas del código fuente involucradas en la condición de concurso 17 Intel® Parallel Inspector

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. Actividad 1a – Energía Potencial Crear y ejecutar la versión serial Crear la versión paralelizada Ejecutar la aplicación en el Parallel Inspector para identificar problemas con 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. Condiciones de Concurso El orden de ejecución se asume pero no puede garantizarse Acceso concurrente a la misma variable por varios hilos El error más común en programas multihilos No siempre obvios

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. Resolviendo Condiciones de Concurso Solución: Variables locales en los hilos Cuando usarlas Valor calculado no se usa fuera de la región paralela Variables temporales o de trabajo Cómo implementar OpenMP cláusulas ( private, shared ) Declara variables dentro de las funciones de los hilos Asigna las variables dentro del stack del hilo TLS (Thread Local Storage) API

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. Resolviendo Condiciones de Concurso Solución: Controla el acceso compartido con regiones críticas Cuando usar El valor calculado se usa fuera de la región paralela El valor compartido es requerido por cada hilo Cómo implementar Exclusión mutua y sincronización Locks, semáforos, eventos, secciones críticas, operaciones atómicas… Regla del pulgar: Usar un lock por elemento 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. 22 Intel® Parallel Inspector Actividad 1b – Energía Potencial Arreglar los errores encontrados con el Parallel Inspector

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. Deadlock (interbloqueo) Causado por un hilo que espera un evento que nunca ocurrirá La causa más común es jerarquía en los bloqueos Siempre bloquea y desbloquea en el mismo orden Evita jererquías si es posible void *threadA(void *arg) { pthread_mutex_lock(&L1); pthread_mutex_lock(&L2); processA(data1, data2); pthread_mutex_unlock(&L2); pthread_mutex_unlock(&L1); return(0); } void *threadB(void *arg) { pthread_mutex_lock(&L2); pthread_mutex_lock(&L2); (&L1); pthread_mutex_lock(&L1); processB(data2, data1) ; processB(data2, data1) ; pthread_mutex_unlock(&L1); pthread_mutex_unlock(&L1);pthread_mutex_unlock(&L2); return(0); return(0);} ThreadA: L1, después L2 ThreadB: L2, después L1

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. Deadlock (interbloqueo) Añade un lock por elemento Bloquea solo elementos, no todo el arreglo de elementos void swap (shape_t a, shape_t b) { lock(a.mutex); lock(b.mutex); // Swap data between a & b unlock(b.mutex); unlock(a.mutex); } typedef struct { // some data things SomeLockType mutex; } shape_t; shape_t Q[1024]; swap(Q[986], Q[34]); Hilo 4 swap(Q[34], Q[986]); Hilo 1 Tomar mutex 34 Tomar mutex 986

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. Sección Crítica en Windows* Ligero, entre procesos solo mutex El más útil y más usado Nuevo tipo CRITICAL_SECTION cs; Operaciones de crear y destruir InitializeCriticalSection(&cs) DeleteCriticalSection(&cs);

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. Sección Crítica en Windows* CRITICAL_SECTION cs ; Intenta entrar al código protegido EnterCriticalSection(&cs) Se bloquea si otro hilo está en la sección crítica Regresa cuando no hay hilos en la sección crítica Al salir de la sección crítica LeaveCriticalSection(&cs) Debe ser desde el hilo que la obtiene

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. Ejemplo: Sección Crítica #define NUMTHREADS 4 CRITICAL_SECTION g_cs; // ¿ Por qu é tiene que ser global? int g_sum = 0; DWORD WINAPI threadFunc(LPVOID arg ) { int mySum = bigComputation(); EnterCriticalSection(&g_cs); g_sum += mySum;// Los hilos acceden una a la vez LeaveCriticalSection(&g_cs); return 0; } main() { HANDLE hThread[NUMTHREADS]; InitializeCriticalSection(&g_cs); for (int i = 0; i < NUMTHREADS; i++) hThread[i] = CreateThread(NULL,0,threadFunc,NULL,0,NULL); WaitForMultipleObjects(NUMTHREADS, hThread, TRUE, INFINITE); DeleteCriticalSection(&g_cs); }

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. Actividad 2 - Deadlock Use Intel® Thread Checker para encontrar y corregir el problema potencial de deadlock.

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. Rutinas Thread Safe Todas las rutinas llamadas concurrentemente de múltiples hilos deben ser thread safe ¿Cómo podemos probar thread safety? Use OpenMP y Parallel Inspector para el análisis Use secciones para crear ejecución concurrente

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. Ejemplo Thread Safety Verificar problemas de seguridad entre Múltiples instancias de routine1() Instancias de routine1() y routine2() Establece secciones para probar todas las permutaciones Aun se requiere proveer conjuntos de datos para ejercitar porciones relevantes de código #pragma omp parallel sections { #pragma omp section routine1(&data1); #pragma omp section routine1(&data2); #pragma omp section routine2(&data3); }

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. Es mejor hacer una rutina reentrante que agregar sincronización Evita potencial sobrecarga Dos Formas de Asegurar Thread Safety Las rutinas pueden escribirse para ser reentrantes Cualquiera de las variables modificadas por la rutina deben ser locales cada vez que se invoquen No modificar variables globalmente compartidas Las rutinas pueden usar exclusión mutua para evitar conflictos con otros hilos Si no se puede evitar el acceso a variables compartidas ¿Qué sucede si librerías de terceros no son thread safe? Sería como necesitar controlar a los hilos en el acceso a la librería

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. Actividad 3 – Thread Safety Usar OpenMP para llamar funciones de librería concurrentemente Tres llamadas de librería = 6 combinaciones por probar A:A, B:B, C:C, A:B, A:C, B:C

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. 33 Intel® Parallel Inspector Intel® Parallel Inspector Lo Que se Cubrió Los errores de paralelización son fáciles de introducir Depurar esos errores por técnicas tradicionales es difícil Intel® Parallel Inspector encuentra esos errores Los errores no tienen que ocurrir para detectarse Reduce gratamente el tiempo de depuración Mejora la robustez de la aplicació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. 34 Intel® Parallel Inspector