1 /* { dg-options "-fcilkplus" } */
2 /* { dg-do run { target i?86-*-* x86_64-*-* arm*-*-* } } */
3 // { dg-require-effective-target c++11 }
4 /* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* arm*-*-* } } } */
6 #define SECOND_NUMBER 3
16 void foo1(int *array
, int size
)
19 for (int ii
= 0; ii
< size
; ii
++)
20 printf("%2d\t", array
[ii
]);
26 if (array
[0] != FIRST_NUMBER
)
28 if (array
[1] != SECOND_NUMBER
)
33 void foo1_c(const int *array
, int size
)
36 for (int ii
= 0; ii
< size
; ii
++)
37 printf("%2d\t", array
[ii
]);
43 if (array
[0] != FIRST_NUMBER
)
45 if (array
[1] != SECOND_NUMBER
)
52 int main2 (int argc
) {
53 int A
[2] = {FIRST_NUMBER
, SECOND_NUMBER
};
54 int B
[2] = {FIRST_NUMBER
, SECOND_NUMBER
};
55 int main_size
= argc
+1; /* We know argc is 1, and so 1+1 = 2. */
59 auto func0
= [=](){ foo1_c(A
, 2); };
67 auto func1
= [=](int *Aa
){ foo1(Aa
, 2); };
68 _Cilk_spawn
func1 (A
);
75 auto func2
= [=](int *Aa
, int size
){ foo1(Aa
, size
); };
76 _Cilk_spawn
func2 (A
, 2);
83 auto func3
= [=](int *Aa
, int size
){ int new_size
= (size
% 2 + 2);
85 _Cilk_spawn
func3 (A
, 2);
92 auto func4
= [](int *Aa
){ foo1(Aa
, 2); };
93 _Cilk_spawn
func4 (A
);
100 auto func5
= [](int *Aa
, int size
){ foo1(Aa
, size
); };
101 _Cilk_spawn
func5 (A
, 2);
108 auto func6
= [&](int *Aa
){ foo1(Aa
, 2); };
109 _Cilk_spawn
func6 (A
);
116 auto func7
= [&](int *Aa
, int size
){ foo1(Aa
, size
); };
117 _Cilk_spawn
func7 (A
, 2);
124 auto func8
= [&](){ foo1(A
, 2); };
125 _Cilk_spawn
func8 ();
132 /* We ignore the first param here and pass in A from the outer fn. */
133 auto func9
= [&](int *Aa
, int size
){ foo1(A
, size
); };
134 _Cilk_spawn
func9 (A
, 2);
141 auto func10
= [=](){ foo1_c(A
, main_size
); };
142 _Cilk_spawn
func10 ();
149 auto func11
= [&](){ foo1(A
, main_size
); };
150 _Cilk_spawn
func11 ();
157 /* We ignore the first & second param here and pass in A from the
159 auto func12
= [&](int *Aa
, int size
){ foo1(A
, main_size
); };
160 _Cilk_spawn
func12 (A
, 2);
167 _Cilk_spawn
[&](int *Aa
){ foo1(Aa
, 2); }(A
);
174 _Cilk_spawn
[&](int *Aa
, int size
){ foo1(Aa
, size
); }(A
, 2);
181 _Cilk_spawn
[=](int *Aa
){ foo1(Aa
, 2); }(A
);
188 _Cilk_spawn
[=](int *Aa
, int size
){ foo1(Aa
, size
); }(A
, 2);
195 /* We ignore the first param here. */
196 _Cilk_spawn
[=](int *Aa
, int size
){ foo1_c(A
, size
); }(A
, 2);
203 /* We ignore the first and second param here. */
204 _Cilk_spawn
[=](int *Aa
, int size
){ foo1_c(A
, size
); }(B
, 2);
211 _Cilk_spawn
[&](){ foo1(A
, 2); }();
212 [&](){ foo1(A
, 2); }();
218 _Cilk_spawn
[=](){ foo1_c (A
, main_size
); }();
225 _Cilk_spawn
[&](){ foo1(A
, main_size
); }();
226 [&](){ foo1(A
, 2); }();