]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c
[Patch AArch64] Fixup floating point division with -march=armv8-a+nosimd
[thirdparty/gcc.git] / gcc / testsuite / c-c++-common / cilk-plus / CK / varargs_test.c
1 /* { dg-do run } */
2 /* { dg-require-effective-target cilkplus_runtime } */
3 /* { dg-options "-fcilkplus" } */
4
5 #include <stdarg.h>
6 #include <stdlib.h>
7
8
9 double compute_total (int no_elements, ...);
10
11 int main(void)
12 {
13 double array[5] = {5.0, 4.0, 9.0, 3.0, 4.0};
14 double array2[5] = {5.0, 6.0, 8.0, 6.0};
15 double yy=0, xx=0, xx_serial, yy_serial;
16
17 yy = _Cilk_spawn compute_total(5,array[0],array[1],array[2],
18 array[3], array[4]);
19 xx= compute_total(4,array2[0],array2[1],array2[2], array2[3]);
20
21 _Cilk_sync;
22
23 yy_serial = compute_total(5,array[0],array[1],array[2], array[3], array[4]);
24 xx_serial = compute_total(4,array2[0],array2[1],array2[2], array2[3]);
25
26 if ((xx + yy) != (xx_serial + yy_serial))
27 return 1;
28 return 0;
29
30 }
31
32
33 double compute_total (int no_elements, ...)
34 {
35 double total = 0;
36 va_list args;
37 va_start(args, no_elements);
38 int ii = 0;
39 for (ii = 0; ii < no_elements; ii++)
40 {
41 total += va_arg(args,double);
42 }
43 va_end(args);
44
45 return total;
46 }
47