1 / 19

OpenMP

OpenMP. Open specifications for Multi Processing. ¿Qué es OpenMP?. Open specifications for Multi Processing API para programar explícitamente en aplicaciones paralelas multi-threaded. Estándar definido para Fortran y C/C++ http://www.openmp.org. Estándar OpenMP.

hilda
Download Presentation

OpenMP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenMP Open specifications for Multi Processing

  2. ¿Qué es OpenMP? • Open specifications for Multi Processing • API para programar explícitamente en aplicaciones paralelas multi-threaded. • Estándar definido para Fortran y C/C++ • http://www.openmp.org

  3. Estándar OpenMP • Empresas/Organizaciones involucradas: • Compaq / Digital • Hewlett-Packard Company • Intel Corporation • International Business Machines (IBM) • Kuck & Associates, Inc. (KAI) • Silicon Graphics, Inc. • Sun Microsystems, Inc. • U.S. Department of Energy ASC program • Otras…

  4. Arquitectura (MPI)

  5. Arquitectura (OpenMP)

  6. Programming Model • Memoria compartida. • Paralelismo explícito • Fork – Join

  7. API • Directivas de compilador • #pragma omp • Bibliotecas de rutina en tiempo de ejecucción • Variables de entorno • OMP_NUM_THREADS • I/O • No está especificado NADA!

  8. Directivas • Parallel • Sección de código a ejecutar en paralelo. • Sections • Secciones independientes en paralelo • For • Ciclo subdividido en paralelo • Single • Código ejecutado por un único thread

  9. Directivas de compilador • #pragma omp directive-name [clause, ...] • PARALLEL • Sección de código ejecutada por varios threads

  10. Ejemplos #include <omp.h> main () { Código Serial . . . #pragma omp parallel { Código ejecutado por TODOS los threads } Código Serial . . . }

  11. Sections • Directiva para paralelizar trabajo “no iterativo” • #pragma omp sections [clause ...] • private (list) • firstprivate (list) • lastprivate (list) • reduction (operator: list) • nowait

  12. For • Directiva para paralelizar ciclos • #pragma omp for [clause ...] • schedule (type [,chunk])  static | dynamic • ordered • private (list) • firstprivate (list) • lastprivate (list) • shared (list) • reduction (operator: list) • nowait • Restricciones: • Sólo paraleliza “for” con variables de iteración escalares, no está permitido “while”. • La correctitud no puede depender por cuáles iteraciones ejecuta cada thread • “chunk” debe ser invariante durante el ciclo.

  13. Ejemplos . . . #pragma omp parallel shared(a,b,c) private(i) { #pragma omp sections nowait { #pragma omp section for (i=0; i < N/2; i++) c[i] = a[i] + b[i]; #pragma omp section for (i=N/2; i < N; i++) c[i] = a[i] + b[i]; } } }

  14. Ejemplos . . . #pragma omp parallel shared(a,b,c,chunk) private(i) { #pragma omp for schedule(dynamic,chunk) nowait { for (i=0; i < N; i++) c[i] = a[i] + b[i]; } }

  15. parallel for… • #pragma omp parallel for [clause ...] newline • schedule (type [,chunk]) • ordered • private (list) • firstprivate (list) • lastprivate (list) • shared (list) • reduction (operator: list) • nowait

  16. Ejemplos . . . #pragma omp parallel for \ shared(a,b,c,chunk) private(i) \ schedule(static,chunk) for (i=0; i < n; i++) c[i] = a[i] + b[i]; . . .

  17. Concurrencia • Memoria compartida  Secciones críticas • Directivas • MASTER • CRITICAL • ATOMIC • Locks • OMP_INIT_LOCK • OMP_DESTROY_LOCK • OMP_SET_LOCK • OMP_UNSET_LOCK • OMP_TEST_LOCK

  18. Funciones Runtime • OMP_SET_NUM_THREADS • OMP_GET_NUM_THREADS • OMP_GET_MAX_THREADS • OMP_GET_THREAD_NUM • OMP_GET_NUM_PROCS • OMP_IN_PARALLEL

  19. Varios • Performance: igual a MPI • OMP_GET_WTIME • OMP_GET_WTICK • Variables de entorno • OMP_SCHEDULE • OMP_NUM_THREADS

More Related