From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35614 invoked by alias); 28 Sep 2016 15:21:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 35600 invoked by uid 89); 28 Sep 2016 15:21:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS,URIBL_RED autolearn=no version=3.3.2 spammy=1511, 1817, Deal, 2367 X-HELO: mail-qk0-f180.google.com Received: from mail-qk0-f180.google.com (HELO mail-qk0-f180.google.com) (209.85.220.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Sep 2016 15:20:51 +0000 Received: by mail-qk0-f180.google.com with SMTP id g67so50287089qkd.0 for ; Wed, 28 Sep 2016 08:20:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to; bh=dcRrZQQQnrZny/4VWh6H8JqNQrtH7XH+5M+zU8tBVAY=; b=XeuGrtJLq1YfFX6n3a4jNvhdvmNMn8TrDlOBO4sWnml8yD5TH6tFqGKMpcPDn5gAN9 c5/k4A8dmdj8o8r0g81i/bM3otvoDvzmbi8ZMBbAbnMAOdKNG0HlbL1a8yvFIJUxMxSl pNKHxQz3q84RYc5i3I7ji0nLhNH7+pli50fGpOyOOq6E6Mpt6MkOFJSDPmoDYTW31w1I +O7AiOIr0cbn0ZhRcBxRw7KKYqSIhVxjQoW9U3OSEpAX8yRiFnx58QlNRCES1CJ0nZCm CEuXHipBMfm1pP+SuHnHkNDOn1f0htYbc9oo7q1Odm2vTzSwJt7U/qZ54mKFPzwu3BCs jD0Q== X-Gm-Message-State: AA6/9Rmd55iuGPUmflMcCrWvO9btWx9smbahA5ThidRU8XAueQR3IyGfbfATD7kdiAnoIA== X-Received: by 10.55.104.15 with SMTP id d15mr3249211qkc.126.1475076050221; Wed, 28 Sep 2016 08:20:50 -0700 (PDT) Received: from ?IPv6:2601:181:c003:1930:3fe6:c217:b86a:6e86? ([2601:181:c003:1930:3fe6:c217:b86a:6e86]) by smtp.googlemail.com with ESMTPSA id u63sm4100059qkd.16.2016.09.28.08.20.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2016 08:20:49 -0700 (PDT) Subject: Re: [gomp4] more tile parsing To: GCC Patches References: <7d421600-1a8c-4944-4f93-53846999bcc0@acm.org> From: Nathan Sidwell Message-ID: <8da1b449-69f7-b92f-8c5e-69e3b5d5af73@acm.org> Date: Wed, 28 Sep 2016 15:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <7d421600-1a8c-4944-4f93-53846999bcc0@acm.org> Content-Type: multipart/mixed; boundary="------------A0F68BD6CC3684B8AAEA24B2" X-SW-Source: 2016-09/txt/msg02141.txt.bz2 This is a multi-part message in MIME format. --------------A0F68BD6CC3684B8AAEA24B2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 9 ENOPATCH --------------A0F68BD6CC3684B8AAEA24B2 Content-Type: text/x-patch; name="tile-parse-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tile-parse-2.patch" Content-length: 9288 2016-09-28 Nathan Sidwell c/ * c-parser.c (c_parser_omp_for_tiling): Accept tiling constructs. cp/ * parser.c (cp_parser_omp_for_loop): Deal with tile clause. Don't emit a parse error about missing for after already emitting one. Use more conventional for idiom for unbounded loop. * semantics.c (finish_omp_for): Deal with tile clause. testsuite/ * c-c++-common/goacc/tile-2.c: New. * c-c++-common/goacc/tile.c: Fix. Index: c/c-parser.c =================================================================== --- c/c-parser.c (revision 240524) +++ c/c-parser.c (working copy) @@ -14920,11 +14920,17 @@ c_parser_omp_for_loop (location_t loc, c bool fail = false, open_brace_parsed = false; int i, collapse = 1, ordered = 0, count, nbraces = 0; location_t for_loc; + bool tiling = false; vec *for_block = make_tree_vector (); for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl)) if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE) collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (cl)); + else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_TILE) + { + tiling = true; + collapse = list_length (OMP_CLAUSE_TILE_LIST (cl)); + } else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_ORDERED && OMP_CLAUSE_ORDERED_EXPR (cl)) { @@ -14954,7 +14960,7 @@ c_parser_omp_for_loop (location_t loc, c pc = &OMP_CLAUSE_CHAIN (*pc); } - gcc_assert (collapse >= 1 && ordered >= 0); + gcc_assert (tiling || (collapse >= 1 && ordered >= 0)); count = ordered ? ordered : collapse; declv = make_tree_vec (count); Index: cp/parser.c =================================================================== --- cp/parser.c (revision 240524) +++ cp/parser.c (working copy) @@ -33660,10 +33660,16 @@ cp_parser_omp_for_loop (cp_parser *parse int i, collapse = 1, ordered = 0, count, nbraces = 0; vec *for_block = make_tree_vector (); auto_vec orig_inits; + bool tiling = false; for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl)) if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE) collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (cl)); + else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_TILE) + { + tiling = true; + collapse = list_length (OMP_CLAUSE_TILE_LIST (cl)); + } else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_ORDERED && OMP_CLAUSE_ORDERED_EXPR (cl)) { @@ -33693,7 +33699,7 @@ cp_parser_omp_for_loop (cp_parser *parse pc = &OMP_CLAUSE_CHAIN (*pc); } - gcc_assert (collapse >= 1 && ordered >= 0); + gcc_assert (tiling || (collapse >= 1 && ordered >= 0)); count = ordered ? ordered : collapse; declv = make_tree_vec (count); @@ -33712,13 +33718,15 @@ cp_parser_omp_for_loop (cp_parser *parse if (code != CILK_FOR && !cp_lexer_next_token_is_keyword (parser->lexer, RID_FOR)) { - cp_parser_error (parser, "for statement expected"); + if (!collapse_err) + cp_parser_error (parser, "for statement expected"); return NULL; } if (code == CILK_FOR && !cp_lexer_next_token_is_keyword (parser->lexer, RID_CILK_FOR)) { - cp_parser_error (parser, "_Cilk_for statement expected"); + if (!collapse_err) + cp_parser_error (parser, "_Cilk_for statement expected"); return NULL; } loc = cp_lexer_consume_token (parser->lexer)->location; @@ -33878,7 +33886,7 @@ cp_parser_omp_for_loop (cp_parser *parse nested. Hopefully the final version clarifies this. For now handle (multiple) {'s and empty statements. */ cp_parser_parse_tentatively (parser); - do + for (;;) { if (cp_lexer_next_token_is_keyword (parser->lexer, RID_FOR)) break; @@ -33893,14 +33901,13 @@ cp_parser_omp_for_loop (cp_parser *parse else { loc = cp_lexer_peek_token (parser->lexer)->location; - error_at (loc, "not enough collapsed for loops"); + error_at (loc, "not enough for loops to collapse"); collapse_err = true; cp_parser_abort_tentative_parse (parser); declv = NULL_TREE; break; } } - while (1); if (declv) { Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 240524) +++ cp/semantics.c (working copy) @@ -7986,11 +7986,19 @@ finish_omp_for (location_t locus, enum t gcc_assert (TREE_VEC_LENGTH (declv) == TREE_VEC_LENGTH (incrv)); if (TREE_VEC_LENGTH (declv) > 1) { - tree c = find_omp_clause (clauses, OMP_CLAUSE_COLLAPSE); + tree c; + + c = find_omp_clause (clauses, OMP_CLAUSE_TILE); if (c) - collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); - if (collapse != TREE_VEC_LENGTH (declv)) - ordered = TREE_VEC_LENGTH (declv); + collapse = list_length (OMP_CLAUSE_TILE_LIST (c)); + else + { + c = find_omp_clause (clauses, OMP_CLAUSE_COLLAPSE); + if (c) + collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); + if (collapse != TREE_VEC_LENGTH (declv)) + ordered = TREE_VEC_LENGTH (declv); + } } for (i = 0; i < TREE_VEC_LENGTH (declv); i++) { Index: testsuite/c-c++-common/goacc/tile-2.c =================================================================== --- testsuite/c-c++-common/goacc/tile-2.c (nonexistent) +++ testsuite/c-c++-common/goacc/tile-2.c (working copy) @@ -0,0 +1,21 @@ +int main () +{ +#pragma acc parallel + { +#pragma acc loop tile (*,*) + for (int ix = 0; ix < 30; ix++) + ; /* { dg-error "not enough" } */ + +#pragma acc loop tile (*,*) + for (int ix = 0; ix < 30; ix++) + for (int jx = 0; jx < ix; jx++) /* { dg-error "condition expression" } */ + ; + +#pragma acc loop tile (*) + for (int ix = 0; ix < 30; ix++) + for (int jx = 0; jx < ix; jx++) /* OK */ + ; + + } + return 0; +} Index: testsuite/c-c++-common/goacc/tile.c =================================================================== --- testsuite/c-c++-common/goacc/tile.c (revision 240524) +++ testsuite/c-c++-common/goacc/tile.c (working copy) @@ -3,7 +3,7 @@ int main () { - int i, *a, b; + int i, j, k, *a, b; #pragma acc parallel loop tile (10) for (i = 0; i < 100; i++) @@ -15,11 +15,14 @@ main () #pragma acc parallel loop tile (10, *) for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + ; #pragma acc parallel loop tile (10, *, i) // { dg-error "" } for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + for (k = 0; k < 100; k++) + ; #pragma acc parallel loop tile // { dg-error "expected '\\\('" } for (i = 0; i < 100; i++) @@ -47,27 +50,34 @@ main () #pragma acc parallel loop tile (10,-3) // { dg-error "'tile' argument needs" } for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + ; #pragma acc parallel loop tile (-100,10,5) // { dg-error "'tile' argument needs" } for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + for (k = 0; k < 100; k++) + ; #pragma acc parallel loop tile (1,true) for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + ; #pragma acc parallel loop tile (*a, 1) // { dg-error "" } for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + ; #pragma acc parallel loop tile (1, b) // { dg-error "" } for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + ; #pragma acc parallel loop tile (b, 1) // { dg-error "" } for (i = 0; i < 100; i++) - ; + for (j = 0; j < 100; j++) + ; return 0; } @@ -75,7 +85,7 @@ main () void par (void) { - int i, j; + int i, j, k; #pragma acc parallel { @@ -107,12 +117,12 @@ void par (void) for (i = 1; i < 3; i++) { for (j = 4; j < 6; j++) - { } + for (k = 0; k< 100; k++); } #pragma acc loop tile(2, 2) for (i = 1; i < 5; i+=2) { - for (j = i + 1; j < 7; j+=i) + for (j = i + 1; j < 7; j+=i) // { dg-error "initializer expression" } { } } #pragma acc loop vector tile(*) @@ -171,7 +181,7 @@ void p3 (void) ; #pragma acc parallel loop tile(2, 2) for (i = 1; i < 5; i+=2) - for (j = i + 1; j < 7; j++) + for (j = i + 1; j < 7; j++) // { dg-error "initializer expression" } { } #pragma acc parallel loop vector tile(*) for (i = 0; i < 10; i++) @@ -226,7 +236,7 @@ kern (void) #pragma acc loop tile(*, 1) for (i = 0; i < 10; i++) { - for (j = 0; j < 10; i++) + for (j = 0; j < 10; i++) /* { dg-error "increment expression" } */ { } } #pragma acc loop tile(-2) // { dg-error "'tile' argument needs" } @@ -237,11 +247,12 @@ kern (void) { } #pragma acc loop tile(2, 2, 1) for (i = 2; i < 4; i++) - for (i = 4; i < 6; i++) + for (j = 4; j < 6; j++) + for (int k = 4; k < 6; k++) { } #pragma acc loop tile(2, 2) for (i = 1; i < 5; i+=2) - for (j = i+1; j < 7; i++) + for (j = i+1; j < 7; j++) /* { dg-error "initializer expression" } */ { } #pragma acc loop vector tile(*) for (i = 0; i < 10; i++) @@ -301,7 +312,7 @@ void k3 (void) #pragma acc kernels loop tile(2, 2) for (i = 1; i < 5; i++) { - for (j = i + 1; j < 7; j += i) + for (j = i + 1; j < 7; j += i) /* { dg-error "initializer expression" } */ { } } #pragma acc kernels loop vector tile(*) --------------A0F68BD6CC3684B8AAEA24B2--