[GSoC] Elimination of CLooG library installation dependency

Roman Gareev gareevroman@gmail.com
Fri Aug 8 13:11:00 GMT 2014


> I think this is fine. On the other side, I think the test case itself
> is unnecessarily large. I would assume the majority of the code could
> be deleted while still triggering the bug. Could you give it a shot.

I've attached an improved version of the patch.

> Is there anything else you still would like to do?

I wanted to make the current code available to be able to fix all new
possible bugs before 'pencils down'. If I have free time, I'll try to
improve the performance of the generation.

>Otherwise, I believe fixing the last remaining bugs is of high importance, as we want to enable
> this code as soon as possible to avoid future bitrot.
>
> I understand that reducing this may require some work, but I don't think it
> is that hard. Specifically, you could first compile the individual *.cpp
> files to .o files once using once graphite once not.

I've found out that btCollisionWorld.cpp, btCollisionDispatcher.cpp
and btDiscreteDynamicsWorld.llvm.cpp cause “Segmentation fault”. All
of them produce similar ASTs:

btCollisionWorld.cpp:

CLAST generated by CLooG:

if (8*T_45 >= -T_44+9) {
  for (scat_1=0;scat_1<=T_45-1;scat_1++) {
    if ((8*scat_1+T_44+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
      (scat_1);
    }
  }
}

isl_codegen:

[P_45, P_44] -> { S_12[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_45)/4294967296), e1 = floor((P_44 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_45 and 4294967296e0 >= -4294967296 +
P_45 and 4294967296e0 <= -1 + P_45 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_44 + 8i0 and
18446744073709551616e1 <= -1 + P_44 + 8i0) }

[P_45, P_44] -> {  : exists (e0 = floor((-1 + P_45)/4294967296):
4294967296e0 <= -1 + P_45 and 4294967296e0 >= -2147483647 + P_45 and
P_45 >= -2147483648 and P_45 <= 2147483647 and P_44 >= 0 and P_44 <=
18446744073709551615) }

[P_45, P_44] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_45; c1 += 1)
  if ((P_44 + 8 * c1) % 18446744073709551616 >= 1)
    S_12(c1);

btCollisionDispatcher.cpp:

CLAST generated by CLooG:

if (8*T_81 >= -T_80+9) {
  for (scat_1=0;scat_1<=T_81-1;scat_1++) {
    if ((8*scat_1+T_80+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
      (scat_1);
    }
  }
}

isl_codegen:

[P_81, P_80] -> { S_22[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_81)/4294967296), e1 = floor((P_80 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_81 and 4294967296e0 >= -4294967296 +
P_81 and 4294967296e0 <= -1 + P_81 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_80 + 8i0 and
18446744073709551616e1 <= -1 + P_80 + 8i0) }

[P_81, P_80] -> {  : exists (e0 = floor((-1 + P_81)/4294967296):
4294967296e0 <= -1 + P_81 and 4294967296e0 >= -2147483647 + P_81 and
P_81 >= -2147483648 and P_81 <= 2147483647 and P_80 >= 0 and P_80 <=
18446744073709551615) }

[P_81, P_80] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_81; c1 += 1)
  if ((P_80 + 8 * c1) % 18446744073709551616 >= 1)
    S_22(c1);

btDiscreteDynamicsWorld.llvm.cpp:

CLAST generated by CLooG:

if (8*T_24 >= -T_23+9) {
  for (scat_1=0;scat_1<=T_24-1;scat_1++) {
    if ((8*scat_1+T_23+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
      (scat_1);
    }
  }
}

isl_codegen:

[P_24, P_23] -> { S_13[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_24)/4294967296), e1 = floor((P_23 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_24 and 4294967296e0 >= -4294967296 +
P_24 and 4294967296e0 <= -1 + P_24 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_23 + 8i0 and
18446744073709551616e1 <= -1 + P_23 + 8i0) }

[P_24, P_23] -> {  : exists (e0 = floor((-1 + P_24)/4294967296):
4294967296e0 <= -1 + P_24 and 4294967296e0 >= -2147483647 + P_24 and
P_24 >= -2147483648 and P_24 <= 2147483647 and P_23 >= 0 and P_23 <=
18446744073709551615) }

[P_24, P_23] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_24; c1 += 1)
  if ((P_23 + 8 * c1) % 18446744073709551616 >= 1)
    S_13(c1);

CLAST generated by CLooG:

if (8*T_46 >= -T_45+9) {
  for (scat_1=0;scat_1<=T_46-1;scat_1++) {
    if ((8*scat_1+T_45+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
      (scat_1);
    }
  }
}

isl_codegen:

[P_46, P_45] -> { S_16[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_46)/4294967296), e1 = floor((P_45 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_46 and 4294967296e0 >= -4294967296 +
P_46 and 4294967296e0 <= -1 + P_46 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_45 + 8i0 and
18446744073709551616e1 <= -1 + P_45 + 8i0) }

[P_46, P_45] -> {  : exists (e0 = floor((-1 + P_46)/4294967296):
4294967296e0 <= -1 + P_46 and 4294967296e0 >= -2147483647 + P_46 and
P_46 >= -2147483648 and P_46 <= 2147483647 and P_45 >= 0 and P_45 <=
18446744073709551615) }

[P_46, P_45] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_46; c1 += 1)
  if ((P_45 + 8 * c1) % 18446744073709551616 >= 1)
    S_16(c1);

CLAST generated by CLooG:

if (8*T_18 >= -T_17+9) {
  for (scat_1=0;scat_1<=T_18-1;scat_1++) {
    if ((8*scat_1+T_17+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
      (scat_1);
    }
  }
}

isl_codegen:

[P_18, P_17] -> { S_12[i0] -> [0, i0, 0] : exists (e0 = floor((-1 +
P_18)/4294967296), e1 = floor((P_17 + 8i0)/18446744073709551616): i0
>= 0 and 4294967296e0 <= -1 + P_18 and 4294967296e0 >= -4294967296 +
P_18 and 4294967296e0 <= -1 + P_18 - i0 and i0 <= 2147483646 and
18446744073709551616e1 >= -18446744073709551615 + P_17 + 8i0 and
18446744073709551616e1 <= -1 + P_17 + 8i0) }

[P_18, P_17] -> {  : exists (e0 = floor((-1 + P_18)/4294967296):
4294967296e0 <= -1 + P_18 and 4294967296e0 >= -2147483647 + P_18 and
P_18 >= -2147483648 and P_18 <= 2147483647 and P_17 >= 0 and P_17 <=
18446744073709551615) }

[P_18, P_17] -> { [i0, i1, i2] -> separate[o0] }

ISL AST generated by ISL:

for (int c1 = 0; c1 < P_18; c1 += 1)
  if ((P_17 + 8 * c1) % 18446744073709551616 >= 1)
    S_12(c1);

I think that, for example, the following code

if (8*T_45 >= -T_44+9) {
  for (scat_1=0;scat_1<=T_45-1;scat_1++) {
    if ((8*scat_1+T_44+18446744073709551615)%18446744073709551616 <=
18446744073709551614) {
      (scat_1);
    }
  }
}

is equivalent to

if (8*T_45 >= -T_44+9) {
  for (scat_1=0;scat_1<=T_45-1;scat_1++) {
    if ((8*scat_1+T_44)%18446744073709551616 <= -1) {
      (scat_1);
    }
  }
}

If I'm not mistaken it's not equivalent to

for (int c1 = 0; c1 < P_45; c1 += 1)
  if ((P_44 + 8 * c1) % 18446744073709551616 >= 1)
    S_12(c1);

Maybe the ISL generator generates wrong code. What do you think about this?



-- 
                                    Cheers, Roman Gareev.
-------------- next part --------------
2014-08-07  Roman Gareev  <gareevroman@gmail.com>

[gcc/]

	* graphite-isl-ast-to-gimple.c:
	(translate_isl_ast_node_user): Use nb_loops instead of loop->num + 1.

[gcc/testsuite]

	* gcc.dg/graphite/isl-ast-gen-user-1.c: New testcase.
-------------- next part --------------
Index: gcc/graphite-isl-ast-to-gimple.c
===================================================================
--- gcc/graphite-isl-ast-to-gimple.c	(revision 213690)
+++ gcc/graphite-isl-ast-to-gimple.c	(working copy)
@@ -632,9 +632,9 @@
   gcc_assert (GBB_BB (gbb) != ENTRY_BLOCK_PTR_FOR_FN (cfun) &&
 	      "The entry block should not even appear within a scop");
 
-  loop_p loop = gbb_loop (gbb);
-  iv_map.create (loop->num + 1);
-  iv_map.safe_grow_cleared (loop->num + 1);
+  int nb_loops = number_of_loops (cfun);
+  iv_map.create (nb_loops);
+  iv_map.safe_grow_cleared (nb_loops);
 
   build_iv_mapping (iv_map, gbb, user_expr, ip, SCOP_REGION (pbb->scop));
   isl_ast_expr_free (user_expr);
Index: gcc/testsuite/gcc.dg/graphite/isl-ast-gen-user-1.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/isl-ast-gen-user-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/graphite/isl-ast-gen-user-1.c	(working copy)
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fgraphite-identity -fgraphite-code-generator=isl" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static const int N = 12;
+
+void Crystal_Cholesky (int nSlip, int a[N][N])
+{
+  int i, j, k, fdot = 0;
+
+  for ( i = 1; i < nSlip; i++)
+    {
+      for ( j = i+1; j < nSlip; j++)
+        {
+          for ( k = 0; k < i; k++)
+            fdot += a[i][k] * a[k][j];
+          a[i][j] = a[i][j] - fdot;
+        }
+   }
+}
+
+
+


More information about the Gcc-patches mailing list