Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Entrambe le parti precedenti la revisione Revisione precedente Prossima revisione | Revisione precedente | ||
roberto.alfieri:pub:openmp [14/10/2020 18:22] roberto.alfieri |
roberto.alfieri:pub:openmp [18/03/2022 16:11] roberto.alfieri [What is openMP] |
||
---|---|---|---|
Linea 1: | Linea 1: | ||
====== OpenMP ====== | ====== OpenMP ====== | ||
+ | ====Tutorials, external links ==== | ||
+ | |||
+ | [[https://hpc-tutorials.llnl.gov/openmp/| LLNL]] | ||
+ | |||
+ | |||
+ | **[[http://didattica-linux.unipr.it/~alfieri/matdid/HPC/openmp/base/ | Exercises repository ]]** | ||
+ | |||
+ | |||
+ | ==== What is openMP ==== | ||
[[http://openmp.org/ | OpenMP]] adds constructs for shared-memory threading to C, C++ and Fortran | [[http://openmp.org/ | OpenMP]] adds constructs for shared-memory threading to C, C++ and Fortran | ||
- | [[https://computing.llnl.gov/tutorials/openMP/#ProgrammingModel | Memory Model:]] | ||
{{:roberto.alfieri:pub:shared_mem.png?200|}} | {{:roberto.alfieri:pub:shared_mem.png?200|}} | ||
Linea 21: | Linea 29: | ||
Version 4.0 (July 2013), 4.5 (Nov 2015 ) and 5.0 (Nov 2018) add support for accelerators (target directives), vectorization (SIMD directives), thread affinity and cancellation. | Version 4.0 (July 2013), 4.5 (Nov 2015 ) and 5.0 (Nov 2018) add support for accelerators (target directives), vectorization (SIMD directives), thread affinity and cancellation. | ||
- | [[https://developers.redhat.com/blog/2019/03/19/whats-new-in-openmp-5-0/ | What's new in OpenMP 5.0 ]] | ||
- | ====Tutorials, external links ==== | ||
- | |||
- | [[https://computing.llnl.gov/tutorials/openMP/ | LLNL]] | ||
- | - | ||
- | [[http://bisqwit.iki.fi/story/howto/openmp/ | Guide into OpenMP: Easy multithreading programming for C++]] | ||
- | |||
- | [[http://didattica-linux.unipr.it/~alfieri/matdid/HPC/openmp/base/ | **Exercises repository** ]] | ||
=== openMP support in the C/C++ Compilers === | === openMP support in the C/C++ Compilers === | ||
- | http://www.openmp.org/resources/openmp-compilers/ | + | https://www.openmp.org/resources/openmp-compilers-tools/ |
GCC: From GCC 6.1, OpenMP 4.5 is fully supported for C and C++ | GCC: From GCC 6.1, OpenMP 4.5 is fully supported for C and C++ | ||
Linea 48: | Linea 47: | ||
</note> | </note> | ||
- | INTEL: OpenMP 4.5 C/C++/Fortran supported in version 17.0 compilers | ||
== How to compile with openMP library == | == How to compile with openMP library == | ||
- | Compile with -fopenmp (gcc compiler) or -qopenmp (intel compiler) on Linux | + | Compile with -fopenmp on Linux |
===== Execution model ===== | ===== Execution model ===== | ||
Linea 209: | Linea 207: | ||
A parallel region is a block of code that will be executed by multiple threads. This is the fundamental OpenMP parallel construct. | A parallel region is a block of code that will be executed by multiple threads. This is the fundamental OpenMP parallel construct. | ||
- | Examples: ex1.c ex2.c [[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/parallel2.c | parallel2.c ]] | + | Examples: ex1.c ex2.c parallel-single.c |
Linea 231: | Linea 229: | ||
Or use #pragma omp parallel for | Or use #pragma omp parallel for | ||
- | [[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/ | Examples]]: for.c for2.c | + | Examples: for.c for-schelule.c |
Linea 243: | Linea 241: | ||
All other threads on the team skip this section of code. | All other threads on the team skip this section of code. | ||
- | [[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/ | Examples]]: single.c | + | Examples: parallel-single.c |
==== Sections Directive ==== | ==== Sections Directive ==== | ||
Linea 263: | Linea 261: | ||
There is an implied barrier at the end of a SECTIONS directive | There is an implied barrier at the end of a SECTIONS directive | ||
- | [[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/ | Examples]]: sections.c sections2.c | + | Examples: sections.c |
==== Critical Directive ==== | ==== Critical Directive ==== | ||
Linea 288: | Linea 286: | ||
} | } | ||
</code> | </code> | ||
+ | Examples: ex2.c | ||
Linea 312: | Linea 310: | ||
- | [[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/ | Examples]]: reduction.c | + | Examples: reduction.c |
== Combining FOR and reduce == | == Combining FOR and reduce == | ||
Linea 339: | Linea 337: | ||
- | [[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/ | Examples]]: for2.c | + | Examples: for-schedule.c |