From patchwork Fri Aug 8 13:11:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Gareev X-Patchwork-Id: 378216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 929BD14011E for ; Fri, 8 Aug 2014 23:11:27 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=pv6VOp0DFAN1nbxlU2 CYXpR8Jbbuiyq21EiGsT4YGXCi++UUopTI7NOfRfWmcxwT/uNZ2W3KK8pIj//lCu UXvrinqbdBd7KisD7T8hSW09yjP5HEuThc8hxi6Ca6fpfm34xfqdLWe0/sY+nl4D +TL7y0/izRZ2/nnpqov4z7Fak= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=YiLqGU2OScbDWyOZVqnbaC3T AVI=; b=Y9V7G2D5FnDDjB6ubJBi2aMDjKMroNykywxHP7MW2fWpvierdfjHZxvR nf1R58ls8FYV/0nkQBBJlPdaOjL43G6kuwwXfA3+17DALPu4wMRf5qzB3cCVMHEk 2JJs84/Uqn/Z5q/3dkck5GTw0sGf6yXhDSwDdECFHnjLCRbGVsY= Received: (qmail 11800 invoked by alias); 8 Aug 2014 13:11:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11789 invoked by uid 89); 8 Aug 2014 13:11:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f170.google.com Received: from mail-yk0-f170.google.com (HELO mail-yk0-f170.google.com) (209.85.160.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 08 Aug 2014 13:11:18 +0000 Received: by mail-yk0-f170.google.com with SMTP id 9so3881308ykp.29 for ; Fri, 08 Aug 2014 06:11:16 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.236.14.34 with SMTP id c22mr14058211yhc.97.1407503476339; Fri, 08 Aug 2014 06:11:16 -0700 (PDT) Received: by 10.170.85.194 with HTTP; Fri, 8 Aug 2014 06:11:16 -0700 (PDT) In-Reply-To: <53E3806E.7040903@grosser.es> References: <53E24E47.2090803@grosser.es> <53E3806E.7040903@grosser.es> Date: Fri, 8 Aug 2014 19:11:16 +0600 Message-ID: Subject: Re: [GSoC] Elimination of CLooG library installation dependency From: Roman Gareev To: Tobias Grosser Cc: Mircea Namolaru , gcc-patches@gcc.gnu.org > 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? 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 +#include + +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; + } + } +} + + +