Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| openacc [2016/11/16 18:43] – [OpenACC by example] admin | openacc [2022/05/24 16:07] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | FIXME Broken | ||
| + | |||
| ====== OpenACC by example ====== | ====== OpenACC by example ====== | ||
| Ligne 33: | Ligne 35: | ||
| | | ||
| + | Directives are: | ||
| + | * Regions | ||
| + | * Loops | ||
| + | * Data Structure | ||
| + | * ... | ||
| + | |||
| + | |||
| ==== Parallel Directive ==== | ==== Parallel Directive ==== | ||
| Programmer identifies a loop as having parallelism, | Programmer identifies a loop as having parallelism, | ||
| Ligne 71: | Ligne 80: | ||
| A parallel function | A parallel function | ||
| that runs on the **GPU**</ | that runs on the **GPU**</ | ||
| - | < | + | < |
| ==== Kernels 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 | ||
| Ligne 117: | Ligne 126: | ||
| !$acc data | !$acc data | ||
| do i=1,n | do i=1,n | ||
| - | 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) | + | |
| end do | end do | ||
| + | |||
| !$acc end data | !$acc end data | ||
| </ | </ | ||
| Ligne 132: | Ligne 143: | ||
| === Data clause === | === Data clause === | ||
| - | |'' | + | |'' |
| - | |'' | + | |'' |
| - | |'' | + | |'' |
| - | |'' | + | |'' |
| - | |'' | + | |'' |
| ===== 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 162: | 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 245: | Ligne 256: | ||
| $ qsub -q gputest.q acc.sge | $ qsub -q gputest.q acc.sge | ||
| </ | </ | ||
| + | ===== Benchmarks ===== | ||
| + | We are used Matrix Multiply to compare execution of four executions. | ||
| + | |||
| + | Compilation level used is '' | ||
| + | |||
| + | ^Problem Size^**OpenACC** | ||
| + | | 1024 | ||
| + | | 2048 | ||
| + | | 4096 | ||
| + | | 5120 | ||
| + | | 6144 | ||
| + | |||
| + | |||
| + | |||
| ===== Links===== | ===== Links===== | ||
| * https:// | * https:// | ||