Strumenti Utente

Strumenti Sito


roberto.alfieri:pub:openmp

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisioneRevisione precedente
Prossima revisione
Revisione precedente
Prossima revisioneEntrambe le parti successive la revisione
roberto.alfieri:pub:openmp [09/05/2019 12:28] roberto.alfieriroberto.alfieri:pub:openmp [18/03/2022 15:43] roberto.alfieri
Linea 1: Linea 1:
 ====== OpenMP ====== ====== OpenMP ======
  
-[[http://openmp.org/wp/ | OpenMP]] adds constructs for shared-memory threading to CC++ and Fortran+====Tutorialsexternal links ====
  
 +[[https://hpc-tutorials.llnl.gov/openmp/| LLNL]]
  
-[[https://computing.llnl.gov/tutorials/openMP/#ProgrammingModel | Memory Model:]] 
  
-{{roberto.alfieri:user:shared_mem.png?150|}}+**[[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 
 + 
 + 
 + 
 +{{:roberto.alfieri:pub:shared_mem.png?200|}}
  
-{{  https://computing.llnl.gov/tutorials/openMP/images/shared_mem.gif }} 
  
 Fork--Join Model: Fork--Join Model:
  
-{{:roberto.alfieri:user:fork_join2.gif?400|}}+{{:roberto.alfieri:pub:fork_join2.gif?400|}}
  
  
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]] 
-- 
-[[https://docs.loni.org/wiki/Introduction_to_OpenMP | LONI]] 
-- 
-[[http://bisqwit.iki.fi/story/howto/openmp/ | Guide into OpenMP: Easy multithreading programming for C++]] 
  
 === openMP support in the C/C++ Compilers === === openMP support in the C/C++ Compilers ===
Linea 209: Linea 209:
 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 231:
   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 243:
 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 263:
 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 288:
 } }
 </code> </code>
 +Examples: ex2.c
  
  
Linea 312: Linea 312:
  
  
-[[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 339:
  
  
-[[http://www.fis.unipr.it/home/roberto.alfieri/didattica/matdid/prog/omp/esempi/Examples]]for2.c+ Examples: for-schedule.c
  
  
Linea 347: Linea 347:
  
  
-==== Esempio LIFE ==== 
- 
-Parallelizzazione con openMP di 
-[[http://www.fis.unipr.it/dokuwiki/doku.php?id=roberto.alfieri:user:prog_seq#simulazioni_di_sistemi_dinamici_discreti 
-| life-ser.c]] 
- 
-== Metodo 1 == 
-Parallelizzazione dei cicli for per l'aggiornamento delle funzioni do_step() e grid_copy() 
-<code> 
-void do_step(..) { 
-#pragma omp parallel for private (i,j) 
-for (i=1;i<=nrows;i++)  
-  for (j=1;j<=nrows;j++)  
-      update(i,j); 
-} 
- 
-void grid_copy(..) { 
-#pragma omp parallel for private (i) 
-for (i=1;i<=nrows;i++)  
-  memcpy(..); // copia riga 
-} 
-</code> 
- 
-== Metodo 2 == 
- 
-Matrice suddivisa in N righe. Ogni riga e' gestita da un thread. 
- 
-{{  roberto.alfieri:pub:life-omp.png?100|}} 
- 
- 
-<code> 
-init(lattice); 
-omp_set_num_threads(NUM_THREADS); 
-#pragma omp parallel 
-for(step=0; step<max; step++) 
- { 
-  do_step(); 
-  copy_row(); 
-  #pragma omp barrier 
-  #pragma omp single 
-    
-    cp_border();   
-   } 
- } 
-save("lattice.dat"); 
-</code> 
  
roberto.alfieri/pub/openmp.txt · Ultima modifica: 18/03/2022 16:11 da roberto.alfieri

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki