Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
openacc [2016/11/16 14:10] – [Links] adminopenacc [2022/05/24 16:07] (Version actuelle) – admin
Ligne 1: Ligne 1:
 +FIXME Broken 
 +
 ====== OpenACC by example ====== ====== OpenACC by example ======
  
Ligne 23: Ligne 25:
      * Deallocating memory       * Deallocating memory 
      * Queue sequences of operations executed by the device       * Queue sequences of operations executed by the device 
 +
 +<note warning>OpenACC is not GPU Programming\\
 +OpenACC is Expressing Parallelism in your code.</note>
 +
 ===== Directives ===== ===== Directives =====
 OpenACC provides a fairly rich pragma language to annotate **data location**, **data transfer**, and **loop or code block parallelism**. The syntax of OpenACC pragmas (sometimes referred to as OpenACC directives) is: OpenACC provides a fairly rich pragma language to annotate **data location**, **data transfer**, and **loop or code block parallelism**. The syntax of OpenACC pragmas (sometimes referred to as OpenACC directives) is:
Ligne 29: Ligne 35:
      *  Fortran: ''!$acc directive-name [clause [[,] clause]…] new-line''      *  Fortran: ''!$acc directive-name [clause [[,] clause]…] new-line''
  
 +Directives are:
 +  * Regions
 +  * Loops
 +  * Data Structure
 +  * ...
 +
 + 
 ==== Parallel Directive ==== ==== Parallel Directive ====
 Programmer identifies a loop as having parallelism, compiler Programmer identifies a loop as having parallelism, compiler
Ligne 67: Ligne 80:
 A parallel function A parallel function
 that runs on the **GPU**</note> that runs on the **GPU**</note>
-<note>Most often **parallel** will be used as **parallel loop**</note> +<note>Most often **parallel** directive will be used as **parallel loop**</note> 
-==== Kernel Directive ====+==== Kernels Directive ====
 The kernels construct expresses that a region may contain parallelism and the compiler determines what can safely be The kernels construct expresses that a region may contain parallelism and the compiler determines what can safely be
 parallelized. parallelized.
  
-C/C++ ''#pragma acc kernel [clause [,clause]...] new-line  structured block''\\ +C/C++ ''#pragma acc kernels [clause [,clause]...] new-line  structured block''\\ 
-Fortran ''!$acc kernel [clause [[,] clause]…] new-line''+Fortran ''!$acc kernels [clause [[,] clause]…] new-line''
  
 Example Example
Ligne 113: Ligne 126:
 !$acc data !$acc data
 do i=1,n do i=1,n
-a(i) = 0.0 +  a(i) = 0.0 
-b(i) = 1.0 +  b(i) = 1.0 
-c(i) = 2.0+  c(i) = 2.0
 end do end do
 +
 do i=1,n do i=1,n
-a(i) = b(i) + c(i)+  a(i) = b(i) + c(i)
 end do end do
 +
 !$acc end data !$acc end data
 </code> </code>
Ligne 128: Ligne 143:
 === Data clause === === Data clause ===
  
-|''copy (list)''|Allocates memory on GPU and copies data from host to GPU when entering region and copies data to the host when exiting region| +|''copy (list)'' |Allocates memory on GPU and copies data from host to GPU when entering region and copies data to the host when exiting region| 
-|''copyin ( list )''| Allocates memory on GPU and copies data from host to GPU when entering region| +|''copyin ( list )'' | Allocates memory on GPU and copies data from host to GPU when entering region| 
-|''copyout ( list )''|Allocates memory on GPU and copies data to the host when exiting region| +|''copyout ( list )'' |Allocates memory on GPU and copies data to the host when exiting region| 
-|''create ( list )''|Allocates memory on GPU but does not copy| +|''create ( list )'' |Allocates memory on GPU but does not copy| 
-|''present ( list )''|Data is already present on GPU from another containing data region|+|''present ( list )'' |Data is already present on GPU from another containing data region|
  
 ===== Compile & Run===== ===== Compile & Run=====
-We use PGI compiler. First we load compiler using module:+We use PGI compiler. First we load the compiler using module:
 <code bash> <code bash>
 $ module load pgi $ module load pgi
Ligne 158: Ligne 173:
 void saxpy(int n, float a, float *restrict x, float *restrict y) void saxpy(int n, float a, float *restrict x, float *restrict y)
 { {
-    #pragma acc kernels  +    #pragma acc parallel loop
     for (int i = 0; i < n; ++i)     for (int i = 0; i < n; ++i)
               y[i] = a*x[i] + y[i];               y[i] = a*x[i] + y[i];
Ligne 241: Ligne 256:
 $ qsub -q gputest.q acc.sge $ qsub -q gputest.q acc.sge
 </code>  </code> 
 +===== Benchmarks =====
 +We are used Matrix Multiply to compare execution of four executions.
 +
 +Compilation level used is ''-03''
 +
 +^Problem Size^**OpenACC**  ^ OpenMP 8 cores (PGI) ^ Intel Compiler 8 cores^
 +| 1024       |  0.5s   |  2.7s         |  0.2s                |
 +| 2048       |  1.03s  |  24s          |  2s                  |
 +| 4096       |  4.0s   |  2m43s        |  15s                 |
 +| 5120       |  6.7s    |  4mn32        |  30s                 |
 +| 6144       |  10s    |  7mn49        |  50s                 |
 +
 +
 +
 ===== Links===== ===== Links=====
   * https://developer.nvidia.com/openacc   * https://developer.nvidia.com/openacc
   * https://devblogs.nvidia.com/parallelforall/getting-started-openacc/   * https://devblogs.nvidia.com/parallelforall/getting-started-openacc/
   * http://www.training.prace-ri.eu/uploads/tx_pracetmo/DirectiveBasedProgJU.pdf   * http://www.training.prace-ri.eu/uploads/tx_pracetmo/DirectiveBasedProgJU.pdf
 +  * http://www.training.prace-ri.eu/uploads/tx_pracetmo/OpenACCDirectives.pdf
  
  
  • openacc.1479305419.txt.gz
  • Dernière modification : 2016/11/16 14:10
  • de admin