Open main menu

CDOT Wiki β

Changes

DPS921/OpenACC vs OpenMP Comparison

1,183 bytes added, 15:58, 30 November 2020
m
no edit summary
== Code comparison ==
 
'''Explicit conversions'''
<source>
Explicit conversionsOpenACC OpenMP
OpenACC OpenMP#pragma acc kernels #pragma omp target { { #pragma acc loop worker #pragma omp parallel for private(tmp) for(int i = 0; i < N; i++){ for(int i = 0; i < N; i++){ tmp = …; tmp = …; array[i] = tmp * …; array[i] = tmp * …; } } #pragma acc loop vector #pragma omp simd for(int i = 0; i < N; i++) for(int i = 0; i < N; i++) array2[i] = …; array2[i] = …;} }
#pragma acc kernels #pragma omp target { { #pragma acc loop worker #pragma omp parallel for private(tmp) for(int i = 0; i < N; i++){ for(int i = 0; i < N; i++){ tmp = …; tmp = …; array[i] = tmp * …; array[i] = tmp * …; } } #pragma acc loop vector #pragma omp simd for(int i = 0; i < N; i++) for(int i = 0; i < N; i++) array2[i] = …; array2[i] = …;} }/source>
</source>'''ACC parallel''' <source>ACC parallel OpenACC OpenMP
OpenACC OpenMP#pragma acc parallel #pragma omp target{ #pragma omp parallel #pragma acc loop { for(int i = 0; i < N; i++){ #pragma omp for private(tmp) nowait tmp = …; for(int i = 0; i < N; i++){ array[i] = tmp * …; tmp = …; } array[i] = tmp * …; #pragma acc loop } for(int i = 0; i < N; i++) #pragma omp for simd array2[i] = …; for(int i = 0; i < N; i++)} array2[i] = …; }
#pragma acc parallel #pragma omp target{ #pragma omp parallel #pragma acc loop { for(int i = 0; i < N; i++){ #pragma omp for private(tmp) nowait tmp = …; for(int i = 0; i < N; i++){ array[i] = tmp * …; tmp = …; /source> } array[i] = tmp * …;'''ACC Kernels''' #pragma acc loop } for(int i = 0; i < N; i++) #pragma omp for simd array2[i] = …; for(int i = 0; i < N; i++)} array2[i] = …;source> }OpenACC OpenMP
#pragma acc kernels #pragma omp target{ #pragma omp parallelfor(int i = 0; i </source>N; i++){ { tmp = …; #pragma omp for private(tmp) array[i] = tmp * …; for(int i = 0; i <source>N; i++){for(int i = 0; i < N; i++) tmp = …; array2[i] = … array[i] = tmp * …; } } #pragma omp for simd for(int i = 0; i < N; i++) array2[i] = … }
ACC Kernels  OpenACC OpenMP #pragma acc kernels #pragma omp target{ #pragma omp parallelfor(int i = 0; i < N; i++){ { tmp = …; #pragma omp for private(tmp) array[i] = tmp * …; for(int i = 0; i < N; i++){for(int i = 0; i < N; i++) tmp = …; array2[i] = … array[i] = tmp * …; } } #pragma omp for simd for(int i = 0; i < N; i++) array2[i] = … } </source><source> '''Copy vs. PCopy'''<source>OpenACC OpenMP
int x[10],y[10]; int x[10],y[10];#pragma acc data copy(x) pcopy(y) #pragma omp target data map(x,y){ { ... ... #pragma acc kernels copy(x) pcopy(y) #pragma omp target update to(x) { #pragma omp target map(y) // Accelerator Code { ... // Accelerator Code } ... ... }} }
</source>
36
edits