]>
Commit | Line | Data |
---|---|---|
572f8300 | 1 | /* { dg-do run } */ |
2 | /* { dg-require-effective-target cilkplus_runtime } */ | |
d037099f | 3 | /* { dg-options "-fcilkplus" } */ |
d037099f | 4 | |
4abd9410 | 5 | #ifdef __cplusplus |
6 | extern "C" { | |
7 | #endif | |
8 | ||
9 | extern int __cilkrts_set_param (const char *, const char *); | |
10 | ||
11 | #ifdef __cplusplus | |
12 | } | |
13 | #endif | |
14 | ||
15 | ||
d037099f | 16 | void f0(volatile int *steal_flag) |
17 | { | |
18 | int i = 0; | |
19 | /* Wait for steal_flag to be set */ | |
20 | while (!*steal_flag) | |
21 | ; | |
22 | } | |
23 | ||
24 | int f1() | |
25 | { | |
26 | ||
27 | volatile int steal_flag = 0; | |
28 | _Cilk_spawn f0(&steal_flag); | |
29 | steal_flag = 1; // Indicate stolen | |
30 | _Cilk_sync; | |
31 | return 0; | |
32 | } | |
33 | ||
34 | void f2(int q) | |
35 | { | |
36 | q = 5; | |
37 | } | |
38 | ||
39 | void f3() | |
40 | { | |
41 | _Cilk_spawn f2(f1()); | |
42 | } | |
43 | ||
44 | int main() | |
45 | { | |
4abd9410 | 46 | /* Ensure more than one worker. */ |
47 | if (__cilkrts_set_param("nworkers", "2") != 0) | |
48 | __builtin_abort(); | |
49 | ||
d037099f | 50 | f3(); |
51 | return 0; | |
52 | } |