| 1 |
int g1() { return 100; } |
| 2 |
int g2() { return 200; } |
| 3 |
|
| 4 |
#pragma omp declare variant (g1) match (construct={dispatch},user={condition(1)}) |
| 5 |
#pragma omp declare variant (g2) match (user={condition(1)}) |
| 6 |
int g() { return 300; } |
| 7 |
|
| 8 |
|
| 9 |
int f1(int x) { return 1 + x; } |
| 10 |
int f2(int x) { return 2 + x; } |
| 11 |
|
| 12 |
#pragma omp declare variant (f1) match (construct={dispatch},user={condition(1)}) |
| 13 |
#pragma omp declare variant (f2) match (user={condition(1)}) |
| 14 |
int f(int x) { return 3 + x; } |
| 15 |
|
| 16 |
|
| 17 |
void |
| 18 |
test () |
| 19 |
{ |
| 20 |
int res; |
| 21 |
|
| 22 |
// Call f2(g2()) due to user condition(1) |
| 23 |
res = f (g ()); |
| 24 |
__builtin_printf("%d\n", res); |
| 25 |
if (res != 202) |
| 26 |
__builtin_abort (); |
| 27 |
|
| 28 |
// Call 'f1(g1())' due to construct 'dispatch' and user conditional(1) |
| 29 |
#pragma omp dispatch |
| 30 |
res = f (g ()); |
| 31 |
__builtin_printf("%d\n", res); |
| 32 |
if (res != 101) |
| 33 |
__builtin_abort (); |
| 34 |
|
| 35 |
// Call 'f2(g2())' due to nocontext (i.e. ignore construct 'dispatch') and user conditional(1) |
| 36 |
#pragma omp dispatch nocontext(1) |
| 37 |
res = f (g ()); |
| 38 |
__builtin_printf("%d\n", res); |
| 39 |
if (res != 202) |
| 40 |
__builtin_abort (); |
| 41 |
|
| 42 |
// Call 'f' due to 'novariants' |
| 43 |
// Call 'g1' due to construct 'dispatch' and user conditional(1) |
| 44 |
#pragma omp dispatch novariants(1) |
| 45 |
res = f (g ()); |
| 46 |
__builtin_printf("%d\n", res); /* ACTUAL RESULT: 303, i.e. 'g' and not 'g1' was called */ |
| 47 |
if (res != 103) |
| 48 |
__builtin_abort (); |
| 49 |
|
| 50 |
// Call 'f' due to 'novariants' |
| 51 |
// Call 'g2' due to nocontext (i.e. ignore construct 'dispatch') and user conditional(1) |
| 52 |
#pragma omp dispatch novariants(1) nocontext(1) |
| 53 |
res = f (g ()); |
| 54 |
__builtin_printf("%d\n", res); /* ACTUAL RESULT: 303, i.e. 'g' and not 'g2' was called */ |
| 55 |
if (res != 203) |
| 56 |
__builtin_abort (); |
| 57 |
} |
| 58 |
|
| 59 |
int |
| 60 |
main () |
| 61 |
{ |
| 62 |
test (); |
| 63 |
} |