Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-require-effective-target cilkplus_runtime } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdarg.h> +#include <stdlib.h> + + +double compute_total (int no_elements, ...); + +int main(void) +{ + double array[5] = {5.0, 4.0, 9.0, 3.0, 4.0}; + double array2[5] = {5.0, 6.0, 8.0, 6.0}; + double yy=0, xx=0, xx_serial, yy_serial; + + yy = _Cilk_spawn compute_total(5,array[0],array[1],array[2], + array[3], array[4]); + xx= compute_total(4,array2[0],array2[1],array2[2], array2[3]); + + _Cilk_sync; + + yy_serial = compute_total(5,array[0],array[1],array[2], array[3], array[4]); + xx_serial = compute_total(4,array2[0],array2[1],array2[2], array2[3]); + + if ((xx + yy) != (xx_serial + yy_serial)) + return 1; + return 0; + +} + + +double compute_total (int no_elements, ...) +{ + double total = 0; + va_list args; + va_start(args, no_elements); + int ii = 0; + for (ii = 0; ii < no_elements; ii++) + { + total += va_arg(args,double); + } + va_end(args); + + return total; +} +