Patchwork PR 57452

login
register
mail settings
Submitter Iyer, Balaji V
Date May 30, 2013, 9:51 p.m.
Message ID <BF230D13CA30DD48930C31D4099330003A429996@FMSMSX101.amr.corp.intel.com>
Download mbox | patch
Permalink /patch/247801/
State New
Headers show

Comments

Iyer, Balaji V - May 30, 2013, 9:51 p.m.
Hello Everyone,
	One of the test in Cilk Plus array notation execution test for C was wrong. Here is a fixed one:

Here is the Change log entry for it:

2013-05-30  Balaji V. Iyer  <balaji.v.iyer@intel.com>

	PR c/57452
	* c-c++-common/cilk-plus/AN/if_test.c: Fixed out of bounds issue in
	test-case.

Is this OK for trunk?

Thanks,

Balaji V. Iyer.
Richard Guenther - May 31, 2013, 8:25 a.m.
On Thu, May 30, 2013 at 11:51 PM, Iyer, Balaji V
<balaji.v.iyer@intel.com> wrote:
> Hello Everyone,
>         One of the test in Cilk Plus array notation execution test for C was wrong. Here is a fixed one:
>
> Here is the Change log entry for it:
>
> 2013-05-30  Balaji V. Iyer  <balaji.v.iyer@intel.com>
>
>         PR c/57452
>         * c-c++-common/cilk-plus/AN/if_test.c: Fixed out of bounds issue in
>         test-case.
>
> Is this OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
>
> Balaji V. Iyer.

Patch

diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c
old mode 100644
new mode 100755
index b150b18..53ceeec
--- a/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c
@@ -1,6 +1,9 @@ 
 /* { dg-do run } */
 /* { dg-options "-fcilkplus" } */
 
+#if HAVE_IO
+#include <stdio.h>
+#endif
 #include <stdlib.h>
 int main2 (int argc, char **argv);
 int main(int argc, char **argv)
@@ -23,8 +26,9 @@  int main(int argc, char **argv)
 int main2 (int argc, char **argv)
 {
   int x = 3, y, z, array[10], array2[10], TwodArray[10][10], jj,kk,ll ;
-  int array2_check[10];
-  int FourDArray[10][10][10][10];
+  int array2_check[10], array2d_check[10][10], array2d[10][10];
+  int FourDArray[10][10][10][10], array4[10][10][10][10];
+  int array4_check[10][10][10][10];
   int ii = 0; 
 
   for (ii = 0; ii < 10; ii++)
@@ -71,10 +75,6 @@  int main2 (int argc, char **argv)
     if (array2_check[ii] != array2[ii])
       return 3;
   
-
-      
-       
-
   x = atoi (argv[1])-10;
   y = atoi (argv[1])/2;
   z = (atoi (argv[1]))/5;
@@ -110,14 +110,16 @@  int main2 (int argc, char **argv)
     if (array2_check[ii] != array2[ii])
       return 4;
 
-  for (ii = 0; ii < 10; ii++)
+  for (ii = 0; ii < 10; ii++) {
     array2[ii] = 10;
+    array2_check[ii] = 10;
+  }
 
   /* This if loop will change all the 10's to 5's */
-  if (array[atoi(argv[1])-10:atoi(argv[1]): atoi(argv[1])/5])
-    array2[:] = 5;
+  if (array[atoi(argv[1])-10:atoi(argv[1])/2: atoi(argv[1])/5])
+    array2[atoi(argv[1])-10: atoi (argv[1])/2: atoi(argv[1])/5] = 5;
   else
-    array2[:] = 10;
+    array2[atoi(argv[1])-10: atoi (argv[1])/2: atoi(argv[1])/5] = 10;
 
   for (ii = atoi(argv[1])-10; ii < atoi(argv[1]) + (atoi (argv[1])-10);
        ii +=atoi(argv[1])/5)
@@ -127,9 +129,13 @@  int main2 (int argc, char **argv)
       array2_check[ii] = 10;
 
   for (ii = 0; ii < 10; ii++)
-    if (array2_check[ii] != array2[ii])
+    if (array2_check[ii] != array2[ii]) {
+#if HAVE_IO
+      printf("array2[%2d] = %2d array2_check[%2d] = %2d\n", ii, array2[ii],
+	     ii, array2_check[ii]);
+#endif
       return 5;
- 
+    }
 
   for (ii = 0; ii < 10; ii++)
     for (jj = 0; jj < 10; jj++)
@@ -137,29 +143,39 @@  int main2 (int argc, char **argv)
 
 
   for (ii = 0; ii < 10; ii++)
-    {
-      array2[ii] = 10;
-      array2_check[ii] = 10;
+    for (ii = 0; ii < 10; ii++) {
+      array2d[ii][jj] = 10;
+      array2d_check[ii][jj] = 10;
     }
 
   /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
   if (TwodArray[:][:] != 10) 
-    array2[:] = 10; 
+    array2d[:][:] = 10; 
   else
-    array2[:] = 5;
+    array2d[:][:] = 5;
 
   for (ii = 0; ii < 10; ii++) {
     for (jj = 0; jj < 10; jj++) {
       if (TwodArray[ii][jj] != 10)
-	array2_check[ii] = 10;
+	array2d_check[ii][jj] = 10;
+      else
+	array2d_check[ii][jj] = 5;
     }
   }
 
   for (ii = 0; ii < 10; ii++)
-    {
-      array2[ii] = 10;
-      array2_check[ii] = 10;
-    }
+    for (jj = 0; jj < 10; jj++)
+      if (array2d[ii][jj] != array2d_check[ii][jj])
+	return 6;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+	for (ll = 0; ll < 10; ll++)
+	  {
+	    array4[ii][jj][kk][ll] = 10;
+	    array4_check[ii][jj][kk][ll] = 10;
+	  }
 
   for (ii = 0; ii < 10; ii++)
     for (jj = 0; jj < 10; jj++)
@@ -169,26 +185,38 @@  int main2 (int argc, char **argv)
   
   /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
   if (FourDArray[:][:][:][:] != 10) 
-    array2[:] = 10; 
+    array4[:][:][:][:] = 10; 
   else
-    array2[:] = 5;
+    array4[:][:][:][:] = 5;
 
   for (ii = 0; ii < 10; ii++) {
     for (jj = 0; jj < 10; jj++) {
       for (kk = 0; kk < 10; kk++) {
 	for (ll = 0; ll < 10; ll++) {
 	  if (FourDArray[ii][jj][kk][ll] != 10)
-	    array2_check[ii] = 10;
+	    array4_check[ii][jj][kk][ll] = 10;
+	  else
+	    array4_check[ii][jj][kk][ll] = 5;
 	}
       }
     }
   }
-  
+
   for (ii = 0; ii < 10; ii++)
-    {
-      array2[ii] = 10;
-      array2_check[ii] = 10;
-    }
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+	for (ll = 0; ll < 10; ll++)
+	  if (array4_check[ii][jj][kk][ll] != array4[ii][jj][kk][ll])
+	    return 7;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+	for (ll = 0; ll < 10; ll++)
+	  {
+	    array4[ii][jj][kk][ll] = 10;
+	    array4_check[ii][jj][kk][ll] = 10;
+	  }
 
   for (ii = 0; ii < 10; ii++)
     for (jj = 0; jj < 10; jj++)
@@ -197,54 +225,88 @@  int main2 (int argc, char **argv)
 	  FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
   
   /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
-  if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] != 10) 
-    array2[:] = 10; 
+  if (FourDArray[0:10:1][0:5:2][9:10:-1][0:5:2] != 10) 
+    array4[0:10:1][0:5:2][9:10:-1][0:5:2] = 10; 
   else
-    array2[:] = 5;
+    array4[0:10:1][0:5:2][9:10:-1][0:5:2] = 5;
 
   for (ii = 0; ii < 10; ii++) {
     for (jj = 0; jj < 10; jj += 2) {
       for (kk = 9; kk >= 0; kk--) {
-	for (ll = x; ll < 10; ll = ll += z) {
+	for (ll = 0; ll < 10; ll += 2) {
 	  if (FourDArray[ii][jj][kk][ll] != 10)
-	    array2_check[ii] = 10;
+	    array4_check[ii][jj][kk][ll] = 10;
 	  else
-	    array2_check[ii] = 5;
+	    array4_check[ii][jj][kk][ll] = 5;
 	}
       }
     }
   }
 
   for (ii = 0; ii < 10; ii++)
-    {
-      array2[ii] = 10;
-      array2_check[ii] = 10;
-    }
-
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+	for (ll = 0; ll < 10; ll++)
+	  if (array4_check[ii][jj][kk][ll] != array4[ii][jj][kk][ll]) {
+#if HAVE_IO
+	      printf("array4_check[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll,
+		     array4_check[ii][jj][kk][ll]);
+	      printf("array4[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll,
+		     array4[ii][jj][kk][ll]);
+#endif
+	    return 8;
+	  }
+  
   for (ii = 0; ii < 10; ii++)
     for (jj = 0; jj < 10; jj++)
       for (kk = 0; kk < 10; kk++)
 	for (ll = 0; ll < 10; ll++) 
 	  FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+	for (ll = 0; ll < 10; ll++)
+	  {
+	    array4[ii][jj][kk][ll] = 10;
+	    array4_check[ii][jj][kk][ll] = 10;
+	  }
+
   
   /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
   if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] +
       FourDArray[0:10:1][0:5:2][9:-10:1][x:y:z]  != 20) 
-    array2[:] = 10; 
+    array4[0:10:1][0:5:2][9:10:-1][x:y:z] = 10; 
   else
-    array2[:] = 5;
+    array4[0:10][0:5:2][9:10:-1][x:y:z] = 5;
 
   for (ii = 0; ii < 10; ii++) {
     for (jj = 0; jj < 10; jj += 2) {
       for (kk = 9; kk >= 0; kk--) {
-	for (ll = x; ll < 10; ll = ll += z) {
+	for (ll = 0; ll < 10; ll += 2) {
 	  if (FourDArray[ii][jj][kk][ll] != 10)
-	    array2_check[ii] = 10;
+	    array4_check[ii][jj][kk][ll] = 10;
 	  else
-	    array2_check[ii] = 5;
+	    array4_check[ii][jj][kk][ll] = 5;
 	}
       }
     }
   }
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+	for (ll = 0; ll < 10; ll++)
+	  if (array4_check[ii][jj][kk][ll] != array4[ii][jj][kk][ll]) {
+#if HAVE_IO
+	      printf("array4_check[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll,
+		     array4_check[ii][jj][kk][ll]);
+	      printf("array4[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll,
+		     array4[ii][jj][kk][ll]);
+#endif
+	    return 9; 
+	  }
+
+  
   return 0;
 }