1 /* { dg-options "-fcilkplus" } */
2 /* { dg-do run { target i?86-*-* x86_64-*-* arm*-*-* } } */
3 /* { dg-options "-std=c++11 -fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* arm*-*-* } } } */
5 #define SECOND_NUMBER 3
15 void foo1(int *array
, int size
)
18 for (int ii
= 0; ii
< size
; ii
++)
19 printf("%2d\t", array
[ii
]);
25 if (array
[0] != FIRST_NUMBER
)
27 if (array
[1] != SECOND_NUMBER
)
32 void foo1_c(const int *array
, int size
)
35 for (int ii
= 0; ii
< size
; ii
++)
36 printf("%2d\t", array
[ii
]);
42 if (array
[0] != FIRST_NUMBER
)
44 if (array
[1] != SECOND_NUMBER
)
51 int main2 (int argc
) {
52 int A
[2] = {FIRST_NUMBER
, SECOND_NUMBER
};
53 int B
[2] = {FIRST_NUMBER
, SECOND_NUMBER
};
54 int main_size
= argc
+1; /* We know argc is 1, and so 1+1 = 2. */
58 auto func0
= [=](){ foo1_c(A
, 2); };
66 auto func1
= [=](int *Aa
){ foo1(Aa
, 2); };
67 _Cilk_spawn
func1 (A
);
74 auto func2
= [=](int *Aa
, int size
){ foo1(Aa
, size
); };
75 _Cilk_spawn
func2 (A
, 2);
82 auto func3
= [=](int *Aa
, int size
){ int new_size
= (size
% 2 + 2);
84 _Cilk_spawn
func3 (A
, 2);
91 auto func4
= [](int *Aa
){ foo1(Aa
, 2); };
92 _Cilk_spawn
func4 (A
);
99 auto func5
= [](int *Aa
, int size
){ foo1(Aa
, size
); };
100 _Cilk_spawn
func5 (A
, 2);
107 auto func6
= [&](int *Aa
){ foo1(Aa
, 2); };
108 _Cilk_spawn
func6 (A
);
115 auto func7
= [&](int *Aa
, int size
){ foo1(Aa
, size
); };
116 _Cilk_spawn
func7 (A
, 2);
123 auto func8
= [&](){ foo1(A
, 2); };
124 _Cilk_spawn
func8 ();
131 /* We ignore the first param here and pass in A from the outer fn. */
132 auto func9
= [&](int *Aa
, int size
){ foo1(A
, size
); };
133 _Cilk_spawn
func9 (A
, 2);
140 auto func10
= [=](){ foo1_c(A
, main_size
); };
141 _Cilk_spawn
func10 ();
148 auto func11
= [&](){ foo1(A
, main_size
); };
149 _Cilk_spawn
func11 ();
156 /* We ignore the first & second param here and pass in A from the
158 auto func12
= [&](int *Aa
, int size
){ foo1(A
, main_size
); };
159 _Cilk_spawn
func12 (A
, 2);
166 _Cilk_spawn
[&](int *Aa
){ foo1(Aa
, 2); }(A
);
173 _Cilk_spawn
[&](int *Aa
, int size
){ foo1(Aa
, size
); }(A
, 2);
180 _Cilk_spawn
[=](int *Aa
){ foo1(Aa
, 2); }(A
);
187 _Cilk_spawn
[=](int *Aa
, int size
){ foo1(Aa
, size
); }(A
, 2);
194 /* We ignore the first param here. */
195 _Cilk_spawn
[=](int *Aa
, int size
){ foo1_c(A
, size
); }(A
, 2);
202 /* We ignore the first and second param here. */
203 _Cilk_spawn
[=](int *Aa
, int size
){ foo1_c(A
, size
); }(B
, 2);
210 _Cilk_spawn
[&](){ foo1(A
, 2); }();
211 [&](){ foo1(A
, 2); }();
217 _Cilk_spawn
[=](){ foo1_c (A
, main_size
); }();
224 _Cilk_spawn
[&](){ foo1(A
, main_size
); }();
225 [&](){ foo1(A
, 2); }();