Debian Codegraph @

libgomp/testsuite/libgomp.c++/metadirective-template-3.C

raw
1 # include <stdio.h>
2
3 template <bool tasking>
4 int
5 fib (int n, bool flag)
6 {
7 int i, j;
8 if (n < 2)
9 return n;
10 else if ( tasking && flag && n < 8 ) // serial/taskless cutoff for n<8
11 return fib<false> (n, false);
12 else
13 {
14 #pragma omp metadirective \
15 when (user = {condition (tasking && flag)}: task shared(i)) \
16 when (user = {condition (!tasking && !flag)}: nothing) \
17 otherwise (error at(execution) message("oops 1"))
18 i = fib<tasking> (n - 1, flag);
19 #pragma omp metadirective \
20 when (user = {condition (score(10): tasking && flag)}: task shared(j)) \
21 when (user = {condition (tasking || flag)} : \
22 error at(execution) message ("oops 2"))
23 j = fib<tasking> (n - 2, flag);
24 #pragma omp metadirective \
25 when (user = {condition (tasking && flag)}: taskwait)
26 return i + j;
27 }
28 }
29
30 int
31 main ()
32 {
33 int n = 15, o = 610;
34 #pragma omp parallel
35 #pragma omp single
36 {
37 if (fib<true> (n, true) != o)
38 __builtin_abort ();
39 if (fib<false> (n, false) != o)
40 __builtin_abort ();
41 }
42 return 0;
43 }