| 1 |
/* { dg-do run } */ |
| 2 |
|
| 3 |
#include <omp.h> |
| 4 |
|
| 5 |
#define N 100 |
| 6 |
|
| 7 |
int |
| 8 |
f (int a[], int run_parallel, int run_static) |
| 9 |
{ |
| 10 |
int is_parallel = 0; |
| 11 |
int is_static = 0; |
| 12 |
|
| 13 |
#pragma omp metadirective \ |
| 14 |
when (user={condition(run_parallel)}: parallel) |
| 15 |
{ |
| 16 |
int i; |
| 17 |
|
| 18 |
if (omp_in_parallel ()) |
| 19 |
is_parallel = 1; |
| 20 |
|
| 21 |
#pragma omp metadirective \ |
| 22 |
when (construct={parallel}, user={condition(!run_static)}: \ |
| 23 |
for schedule(guided) private(is_static)) \ |
| 24 |
when (construct={parallel}: for schedule(static)) |
| 25 |
for (i = 0; i < N; i++) |
| 26 |
{ |
| 27 |
a[i] = i; |
| 28 |
is_static = 1; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
return (is_parallel << 1) | is_static; |
| 33 |
} |
| 34 |
|
| 35 |
int |
| 36 |
main (void) |
| 37 |
{ |
| 38 |
int a[N]; |
| 39 |
|
| 40 |
/* is_static is always set if run_parallel is false. */ |
| 41 |
if (f (a, 0, 0) != 1) |
| 42 |
return 1; |
| 43 |
|
| 44 |
if (f (a, 0, 1) != 1) |
| 45 |
return 1; |
| 46 |
|
| 47 |
if (f (a, 1, 0) != 2) |
| 48 |
return 1; |
| 49 |
|
| 50 |
if (f (a, 1, 1) != 3) |
| 51 |
return 1; |
| 52 |
|
| 53 |
return 0; |
| 54 |
} |