| 1 |
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ |
| 2 |
/* { dg-additional-options "-mavx2" } */ |
| 3 |
|
| 4 |
typedef float __v4sf __attribute__((vector_size (16))); |
| 5 |
typedef int __v4si __attribute__((vector_size (16))); |
| 6 |
typedef float __v8sf __attribute__((vector_size (32))); |
| 7 |
typedef int __v8si __attribute__((vector_size (32))); |
| 8 |
__v4si f1 (__v4sf, __v4sf, float *); |
| 9 |
__v8si f2 (__v8sf, __v8sf, float *); |
| 10 |
__v4si f3 (__v4si, int, __v4si); |
| 11 |
|
| 12 |
#pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))}) |
| 13 |
#pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)}) |
| 14 |
int f4 (float x, float y, float *z); |
| 15 |
|
| 16 |
#pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))}) |
| 17 |
int f5 (int x, int y); |
| 18 |
|
| 19 |
void |
| 20 |
test (int *x, float *y, float *z, float *w) |
| 21 |
{ |
| 22 |
#pragma omp parallel |
| 23 |
#pragma omp for simd aligned (w:4 * sizeof (float)) |
| 24 |
for (int i = 0; i < 1024; i++) |
| 25 |
x[i] = f4 (y[i], z[i], w); |
| 26 |
#pragma omp parallel for simd aligned (w:4 * sizeof (float)) simdlen(4) |
| 27 |
for (int i = 1024; i < 2048; i++) |
| 28 |
x[i] = f4 (y[i], z[i], w); |
| 29 |
#pragma omp simd aligned (w:4 * sizeof (float)) |
| 30 |
for (int i = 2048; i < 4096; i++) |
| 31 |
x[i] = f4 (y[i], z[i], w); |
| 32 |
#pragma omp simd |
| 33 |
for (int i = 4096; i < 8192; i++) |
| 34 |
if (x[i] > 10) |
| 35 |
x[i] = f5 (x[i], i); |
| 36 |
} |