diff options
author | bviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 14:55:46 +0000 |
---|---|---|
committer | bviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 14:55:46 +0000 |
commit | 8374efba8b611408debe7b47916ca9c814e3c454 (patch) | |
tree | ef8651daa209b4ca62223e3c3d964ca2958257f7 /gcc/testsuite/c-c++-common/cilk-plus/CK | |
parent | 125ac0ea33df49b7a5ad7114d44da060ce395775 (diff) | |
download | gcc-8374efba8b611408debe7b47916ca9c814e3c454.tar.gz |
2013-11-05 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-c++-common/cilk-plus/CK/fib.c: Reduced the iteration from
40 to 30. Replaced iteration variable with a #define. Instead of
returning non-zero value for error, called __builtin_abort (). Fixed
a bug of calling fib_serial in serial case instead of fib.
* c-c++-common/cilk-plus/CK/fib_init_expr_xy.c: Likewise.
* c-c++-common/cilk-plus/CK/fib_no_return.c: Likewise.
* c-c++-common/cilk-plus/CK/fib_no_sync.c: Likewise.
* gcc.dg/cilk-plus/cilk-plus.exp: Removed duplicate/un-necessary
compiler flag testing.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204457 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/c-c++-common/cilk-plus/CK')
4 files changed, 68 insertions, 51 deletions
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c index 6612936a05c..a8849fb9e6c 100644 --- a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c @@ -9,41 +9,34 @@ int fib (int); int fib_serial (int); +#define FIB_ITERATION 30 + int main(void) { - int ii = 0, error = 0; - int fib_result[41], fib_serial_result[41]; + int ii = 0; + int fib_result[FIB_ITERATION+1], fib_serial_result[FIB_ITERATION+1]; #if HAVE_IO - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) printf("fib (%2d) = %10d\n", ii, fib (ii)); #else - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) { fib_result[ii] = fib (ii); - fib_serial_result[ii] = fib_serial (ii); } - for (ii = 0; ii <= 40; ii++) + fib_serial_result[0] = 0; + fib_serial_result[1] = 1; + for (ii = 2; ii <= FIB_ITERATION; ii++) + fib_serial_result[ii] = fib_serial_result[ii-1] + fib_serial_result[ii-2]; + + for (ii = 0; ii <= FIB_ITERATION; ii++) { if (fib_result[ii] != fib_serial_result[ii]) - error = 1; + __builtin_abort (); } #endif - return error; -} - -int fib_serial (int n) -{ - int x = 0, y = 0; - if (n < 2) - return n; - else - { - x = fib (n-1); - y = fib (n-2); - return (x+y); - } + return 0; } int fib(int n) diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c index 6b09918a420..0196a8daba8 100644 --- a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c @@ -9,28 +9,36 @@ int fib (int); int fib_serial (int); +#define FIB_ITERATION 30 + int main(void) { - int ii = 0, error = 0; - int fib_result[41], fib_serial_result[41]; + int ii = 0; + int fib_result[FIB_ITERATION+1], fib_serial_result[FIB_ITERATION+1]; #if HAVE_IO - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) printf("fib (%2d) = %10d\n", ii, fib (ii)); #else - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) { fib_result[ii] = fib (ii); - fib_serial_result[ii] = fib_serial (ii); } - for (ii = 0; ii <= 40; ii++) + fib_serial_result[0] = 0; + fib_serial_result[1] = 1; + + for (ii = 2; ii <= FIB_ITERATION; ii++) + fib_serial_result[ii] = fib_serial_result[ii-1] + fib_serial_result[ii-2]; + + for (ii = 0; ii <= FIB_ITERATION; ii++) { if (fib_result[ii] != fib_serial_result[ii]) - error = 1; + __builtin_abort (); } + #endif - return error; + return 0; } int fib_serial (int n) @@ -40,8 +48,8 @@ int fib_serial (int n) return n; else { - x = fib (n-1); - y = fib (n-2); + x = fib_serial (n-1); + y = fib_serial (n-2); return (x+y); } } diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c index 2adf3a2f6e1..47ebef52030 100644 --- a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c @@ -6,35 +6,43 @@ #include <stdio.h> #endif +#define FIB_ITERATION 30 + void fib (int *, int); int fib_serial (int); int main(void) { int ii = 0, error = 0; - int fib_result[41], fib_serial_result[41]; + int fib_result[FIB_ITERATION+1], fib_serial_result[FIB_ITERATION+1]; #if HAVE_IO - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) { int result = 0; fib (&result, ii); printf("fib (%2d) = %10d\n", ii, result); } #else - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) { fib (&fib_result[ii], ii); - fib_serial_result[ii] = fib_serial (ii); } - - for (ii = 0; ii <= 40; ii++) + + fib_serial_result[0] = 0; + fib_serial_result[1] = 1; + + for (ii = 2; ii <= FIB_ITERATION; ii++) + fib_serial_result[ii] = fib_serial_result[ii-1] + fib_serial_result[ii-2]; + + for (ii = 0; ii <= FIB_ITERATION; ii++) { if (fib_result[ii] != fib_serial_result[ii]) - error = 1; + __builtin_abort (); } #endif - return error; + + return 0; } int fib_serial (int n) @@ -44,8 +52,8 @@ int fib_serial (int n) return n; else { - fib (&x, n-1); - fib (&y, n-2); + x = fib_serial (n-1); + y = fib_serial (n-2); return (x+y); } } diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c index 9de70be7584..a23051d4819 100644 --- a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c @@ -6,31 +6,39 @@ #include <stdio.h> #endif +#define FIB_ITERATION 30 + int fib (int); int fib_serial (int); int main(void) { - int ii = 0, error = 0; - int fib_result[41], fib_serial_result[41]; + int ii = 0; + int fib_result[FIB_ITERATION+1], fib_serial_result[FIB_ITERATION+1]; #if HAVE_IO - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) printf("fib (%2d) = %10d\n", ii, fib (ii)); #else - for (ii = 0; ii <= 40; ii++) + for (ii = 0; ii <= FIB_ITERATION; ii++) { fib_result[ii] = fib (ii); - fib_serial_result[ii] = fib_serial (ii); } - for (ii = 0; ii <= 40; ii++) + fib_serial_result[0] = 0; + fib_serial_result[1] = 1; + + for (ii = 2; ii <= FIB_ITERATION; ii++) + fib_serial_result[ii] = fib_serial_result[ii-1] + fib_serial_result[ii-2]; + + for (ii = 0; ii <= FIB_ITERATION; ii++) { if (fib_result[ii] != fib_serial_result[ii]) - error = 1; + __builtin_abort (); } + #endif - return error; + return 0; } int fib_serial (int n) @@ -40,8 +48,8 @@ int fib_serial (int n) return n; else { - x = fib (n-1); - y = fib (n-2); + x = fib_serial (n-1); + y = fib_serial (n-2); return (x+y); } } |