From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72079 invoked by alias); 13 Oct 2015 07:21:38 -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 72065 invoked by uid 89); 13 Oct 2015 07:21:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 13 Oct 2015 07:21:36 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 20756319AE4 for ; Tue, 13 Oct 2015 07:21:35 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-53.ams2.redhat.com [10.36.116.53]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9D7LXYm018511 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 13 Oct 2015 03:21:34 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id t9D7LVCP030464 for ; Tue, 13 Oct 2015 09:21:32 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id t9D7LVlS030463 for gcc-patches@gcc.gnu.org; Tue, 13 Oct 2015 09:21:31 +0200 Date: Tue, 13 Oct 2015 07:21:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [gomp4.1] Fixup nesting diagnostics for ordered depend, allow ordered without param on for simd Message-ID: <20151013072131.GD478@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg01188.txt.bz2 Hi! For ordered depend we unfortunately need to diagnose incorrect length or contents of the sink vec before OpenMP region nesting is diagnosed, so this patch diagnoses the incorrect nesting before the diagnostics, to avoid confusing errors. Also the patch allows ordered clause on for simd, but only if ordered has no parameter. To be used with #pragma omp ordered threads simd construct. 2015-10-13 Jakub Jelinek * gimplify.c (gimplify_omp_ordered): Diagnose ordered depend inside loop without ordered(n) clause. * omp-low.c (check_omp_nesting_restrictions): Use a different wording if ordered clause is present, but without parameter. c/ * c-parser.c (c_parser_omp_simd): Allow ordered clause on for simd, but ensure no parameter is specified for it. cp/ * parser.c (cp_parser_omp_simd): Allow ordered clause on for simd, but ensure no parameter is specified for it. testsuite/ * c-c++-common/gomp/ordered-3.c: New test. --- gcc/gimplify.c.jj 2015-10-12 12:37:32.000000000 +0200 +++ gcc/gimplify.c 2015-10-12 13:43:30.732469344 +0200 @@ -8749,7 +8749,18 @@ gimplify_omp_ordered (tree expr, gimple_ if (gimplify_omp_ctxp) for (c = OMP_ORDERED_CLAUSES (expr); c; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND - && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK) + && gimplify_omp_ctxp->loop_iter_var.is_empty () + && (OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK + || OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SOURCE)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "% clause must be closely nested " + "inside a loop with % clause with " + "a parameter"); + failures++; + } + else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND + && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_SINK) { bool fail = false; for (decls = OMP_CLAUSE_DECL (c), i = 0; --- gcc/omp-low.c.jj 2015-10-12 12:21:32.000000000 +0200 +++ gcc/omp-low.c 2015-10-12 13:40:39.750083213 +0200 @@ -3375,14 +3375,21 @@ check_omp_nesting_restrictions (gimple s || gimple_code (ctx->stmt) != GIMPLE_OMP_FOR || (oclause = find_omp_clause (gimple_omp_for_clauses (ctx->stmt), - OMP_CLAUSE_ORDERED)) == NULL_TREE - || OMP_CLAUSE_ORDERED_EXPR (oclause) == NULL_TREE) + OMP_CLAUSE_ORDERED)) == NULL_TREE) { error_at (OMP_CLAUSE_LOCATION (c), "% clause must be closely nested " "inside an ordered loop"); return false; } + else if (OMP_CLAUSE_ORDERED_EXPR (oclause) == NULL_TREE) + { + error_at (OMP_CLAUSE_LOCATION (c), + "% clause must be closely nested " + "inside a loop with % clause with " + "a parameter"); + return false; + } } else { --- gcc/c/c-parser.c.jj 2015-10-09 09:26:12.000000000 +0200 +++ gcc/c/c-parser.c 2015-10-12 13:26:52.275752160 +0200 @@ -14009,13 +14009,21 @@ c_parser_omp_simd (location_t loc, c_par strcat (p_name, " simd"); mask |= OMP_SIMD_CLAUSE_MASK; - mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDERED); clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL); if (cclauses) { omp_split_clauses (loc, OMP_SIMD, mask, clauses, cclauses); clauses = cclauses[C_OMP_CLAUSE_SPLIT_SIMD]; + tree c = find_omp_clause (cclauses[C_OMP_CLAUSE_SPLIT_FOR], + OMP_CLAUSE_ORDERED); + if (c && OMP_CLAUSE_ORDERED_EXPR (c)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "% clause with parameter may not be specified " + "on %qs construct", p_name); + OMP_CLAUSE_ORDERED_EXPR (c) = NULL_TREE; + } } block = c_begin_compound_stmt (true); --- gcc/cp/parser.c.jj 2015-10-09 09:27:22.000000000 +0200 +++ gcc/cp/parser.c 2015-10-12 13:27:43.600966307 +0200 @@ -32527,7 +32527,6 @@ cp_parser_omp_simd (cp_parser *parser, c strcat (p_name, " simd"); mask |= OMP_SIMD_CLAUSE_MASK; - mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDERED); clauses = cp_parser_omp_all_clauses (parser, mask, p_name, pragma_tok, cclauses == NULL); @@ -32535,6 +32534,15 @@ cp_parser_omp_simd (cp_parser *parser, c { cp_omp_split_clauses (loc, OMP_SIMD, mask, clauses, cclauses); clauses = cclauses[C_OMP_CLAUSE_SPLIT_SIMD]; + tree c = find_omp_clause (cclauses[C_OMP_CLAUSE_SPLIT_FOR], + OMP_CLAUSE_ORDERED); + if (c && OMP_CLAUSE_ORDERED_EXPR (c)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "% clause with parameter may not be specified " + "on %qs construct", p_name); + OMP_CLAUSE_ORDERED_EXPR (c) = NULL_TREE; + } } sb = begin_omp_structured_block (); --- gcc/testsuite/c-c++-common/gomp/ordered-3.c.jj 2015-10-12 12:49:11.166229129 +0200 +++ gcc/testsuite/c-c++-common/gomp/ordered-3.c 2015-10-12 13:44:50.349252214 +0200 @@ -0,0 +1,91 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +void +foo (void) +{ + int i; + #pragma omp for ordered + for (i = 0; i < 64; i++) + { + #pragma omp ordered + ; + } + #pragma omp for ordered + for (i = 0; i < 64; i++) + { + #pragma omp ordered threads + ; + } + #pragma omp for ordered + for (i = 0; i < 64; i++) + { + #pragma omp ordered threads threads /* { dg-error "too many .threads. clauses" } */ + ; + } + #pragma omp simd + for (i = 0; i < 64; i++) + { + #pragma omp ordered simd + ; + } + #pragma omp simd + for (i = 0; i < 64; i++) + { + #pragma omp ordered simd simd /* { dg-error "too many .simd. clauses" } */ + ; + } + #pragma omp for simd ordered + for (i = 0; i < 64; i++) + { + #pragma omp ordered threads, simd + ; + } + #pragma omp for simd ordered + for (i = 0; i < 64; i++) + { + #pragma omp ordered threads, simd, threads, simd /* { dg-error "too many .threads. clauses" } */ + ; /* { dg-error "too many .simd. clauses" "" { target *-*-* } 47 } */ + } + #pragma omp for simd ordered(1) /* { dg-error ".ordered. clause with parameter may not be specified on .#pragma omp for simd. construct" } */ + for (i = 0; i < 64; i++) + { + #pragma omp ordered depend(sink: i - 1) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */ + #pragma omp ordered depend(source) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */ + } + #pragma omp parallel for simd ordered(1) /* { dg-error ".ordered. clause with parameter may not be specified on .#pragma omp parallel for simd. construct" } */ + for (i = 0; i < 64; i++) + { + #pragma omp ordered depend(sink: i - 1) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */ + #pragma omp ordered depend(source) /* { dg-error "clause must be closely nested inside a loop with .ordered. clause with a parameter" } */ + } +} + +void +bar (int x) +{ + switch (x) + { + case 0: + #pragma omp ordered + ; + break; + case 1: + #pragma omp ordered threads + ; + break; + case 2: + #pragma omp ordered threads, threads /* { dg-error "too many .threads. clauses" } */ + ; + break; + } +} + +void +baz (void) +{ + #pragma omp ordered simd + ; + #pragma omp ordered simd, simd /* { dg-error "too many .simd. clauses" } */ + ; +} Jakub