From patchwork Wed Jun 12 13:03:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 250761 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B00B02C0095 for ; Wed, 12 Jun 2013 23:03:53 +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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=IcCi3z3+HknO1ipOI61QhTcKMKqOl2Lu9ntsxJNBq61 eMiP49NDckF323W0s1Zy60dHRhLDxk50sBUP2A4r7wy4hVtLkas5QF20UUDdU48C G51E+SCX303GVESuLZ+Q7pkO09f732BgUJPYNPeinQ3YlTZDZ1ln6TtDaaCgG2jA = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=QlI1UKnNX7EjaBS35YVD8RzpKjg=; b=YlZpqyTpsWDEC3Ypq vfV4uNe6PHKb+II1FXA4juEuA/Qrq0KW3oMdnxOO7HY+mVzaMhWOTe51/gaBTyVO FpNCDD+LwyCqrpA0MACs09CrYjj5vON5tRsheriPiiaI0jReYB4P3t65wu2oDBf8 rn0pz9NqjgdyS8xL/IifwBc5XE= Received: (qmail 12379 invoked by alias); 12 Jun 2013 13:03:47 -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 12360 invoked by uid 89); 12 Jun 2013 13:03:44 -0000 X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL, BAYES_50, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 12 Jun 2013 13:03:44 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5CD3gTw021899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Jun 2013 09:03:42 -0400 Received: from zalov.cz (vpn-52-233.rdu2.redhat.com [10.10.52.233]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5CD3ftc012287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 12 Jun 2013 09:03:42 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r5CD3djn028886 for ; Wed, 12 Jun 2013 15:03:40 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r5CD3dw8028885 for gcc-patches@gcc.gnu.org; Wed, 12 Jun 2013 15:03:39 +0200 Date: Wed, 12 Jun 2013 15:03:37 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [gomp4] Introduce thread_limit clause Message-ID: <20130612130337.GT2336@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! The num_threads clause on the #pragma omp teams construct has been replaced with a new thread_limit clause. Changed for C++ FE thusly: 2013-06-12 Jakub Jelinek * gimplify.c (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_THREAD_LIMIT. * tree-pretty-print.c (dump_omp_clause): Likewise. * tree.c (omp_clause_num_ops, omp_clause_code_name): Add entries for OMP_CLAUSE_THREAD_LIMIT. * tree.h (enum omp_clause_code): Add OMP_CLAUSE_THREAD_LIMIT. (OMP_CLAUSE_THREAD_LIMIT_EXPR): Define. cp/ * semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_THREAD_LIMIT. * parser.c (cp_parser_omp_clause_name): Handle thread_limit clause. (cp_parser_omp_clause_thread_limit): New function. (cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_THREAD_LIMIT. (OMP_TEAMS_CLAUSE_MASK): Replace PRAGMA_OMP_CLAUSE_NUM_THREADS with PRAGMA_OMP_CLAUSE_THREAD_LIMIT. * pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_THREAD_LIMIT. c-family/ * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_THREAD_LIMIT. Jakub --- gcc/gimplify.c.jj 2013-06-12 11:53:15.000000000 +0200 +++ gcc/gimplify.c 2013-06-12 12:16:51.123583143 +0200 @@ -6420,6 +6420,7 @@ gimplify_scan_omp_clauses (tree *list_p, case OMP_CLAUSE_SCHEDULE: case OMP_CLAUSE_NUM_THREADS: case OMP_CLAUSE_NUM_TEAMS: + case OMP_CLAUSE_THREAD_LIMIT: case OMP_CLAUSE_DIST_SCHEDULE: case OMP_CLAUSE_DEVICE: if (gimplify_expr (&OMP_CLAUSE_OPERAND (c, 0), pre_p, NULL, --- gcc/tree.c.jj 2013-06-12 11:53:15.000000000 +0200 +++ gcc/tree.c 2013-06-12 12:15:58.026440954 +0200 @@ -257,6 +257,7 @@ unsigned const char omp_clause_num_ops[] 0, /* OMP_CLAUSE_INBRANCH */ 0, /* OMP_CLAUSE_NOTINBRANCH */ 1, /* OMP_CLAUSE_NUM_TEAMS */ + 1, /* OMP_CLAUSE_THREAD_LIMIT */ 0, /* OMP_CLAUSE_PROC_BIND */ 1, /* OMP_CLAUSE_SAFELEN */ 1, /* OMP_CLAUSE_SIMDLEN */ @@ -298,6 +299,7 @@ const char * const omp_clause_code_name[ "inbranch", "notinbranch", "num_teams", + "thread_limit", "proc_bind", "safelen", "simdlen", @@ -11014,6 +11016,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func case OMP_CLAUSE_UNIFORM: case OMP_CLAUSE_DEPEND: case OMP_CLAUSE_NUM_TEAMS: + case OMP_CLAUSE_THREAD_LIMIT: case OMP_CLAUSE_DEVICE: case OMP_CLAUSE_DIST_SCHEDULE: case OMP_CLAUSE_SAFELEN: --- gcc/cp/semantics.c.jj 2013-06-04 20:55:56.000000000 +0200 +++ gcc/cp/semantics.c 2013-06-12 14:46:18.251419189 +0200 @@ -4779,6 +4779,25 @@ finish_omp_clauses (tree clauses) } break; + case OMP_CLAUSE_THREAD_LIMIT: + t = OMP_CLAUSE_THREAD_LIMIT_EXPR (c); + if (t == error_mark_node) + remove = true; + else if (!type_dependent_expression_p (t) + && !INTEGRAL_TYPE_P (TREE_TYPE (t))) + { + error ("% expression must be integral"); + remove = true; + } + else + { + t = mark_rvalue_use (t); + if (!processing_template_decl) + t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); + OMP_CLAUSE_THREAD_LIMIT_EXPR (c) = t; + } + break; + case OMP_CLAUSE_DEVICE: t = OMP_CLAUSE_DEVICE_ID (c); if (t == error_mark_node) --- gcc/cp/parser.c.jj 2013-06-04 20:55:56.000000000 +0200 +++ gcc/cp/parser.c 2013-06-12 12:22:01.239604269 +0200 @@ -26225,6 +26225,8 @@ cp_parser_omp_clause_name (cp_parser *pa case 't': if (!strcmp ("taskgroup", p)) result = PRAGMA_OMP_CLAUSE_TASKGROUP; + else if (!strcmp ("thread_limit", p)) + result = PRAGMA_OMP_CLAUSE_THREAD_LIMIT; else if (!strcmp ("to", p)) result = PRAGMA_OMP_CLAUSE_TO; break; @@ -26892,6 +26900,36 @@ cp_parser_omp_clause_num_teams (cp_parse } /* OpenMP 4.0: + thread_limit ( expression ) */ + +static tree +cp_parser_omp_clause_thread_limit (cp_parser *parser, tree list, + location_t location) +{ + tree t, c; + + if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN)) + return list; + + t = cp_parser_expression (parser, false, NULL); + + if (t == error_mark_node + || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) + cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, + /*or_comma=*/false, + /*consume_paren=*/true); + + check_no_duplicate_clause (list, OMP_CLAUSE_THREAD_LIMIT, + "thread_limit", location); + + c = build_omp_clause (location, OMP_CLAUSE_THREAD_LIMIT); + OMP_CLAUSE_THREAD_LIMIT_EXPR (c) = t; + OMP_CLAUSE_CHAIN (c) = list; + + return c; +} + +/* OpenMP 4.0: aligned ( variable-list ) aligned ( variable-list : constant-expression ) */ @@ -27429,6 +27463,11 @@ cp_parser_omp_all_clauses (cp_parser *pa token->location); c_name = "num_teams"; break; + case PRAGMA_OMP_CLAUSE_THREAD_LIMIT: + clauses = cp_parser_omp_clause_thread_limit (parser, clauses, + token->location); + c_name = "thread_limit"; + break; case PRAGMA_OMP_CLAUSE_ALIGNED: clauses = cp_parser_omp_clause_aligned (parser, clauses); c_name = "aligned"; @@ -29058,7 +29097,7 @@ cp_parser_omp_cancellation_point (cp_par | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SHARED) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS) \ - | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREAD_LIMIT) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULT)) static tree --- gcc/cp/pt.c.jj 2013-06-04 20:55:40.000000000 +0200 +++ gcc/cp/pt.c 2013-06-12 12:22:24.221366949 +0200 @@ -12667,6 +12667,7 @@ tsubst_omp_clauses (tree clauses, bool d case OMP_CLAUSE_DEVICE: case OMP_CLAUSE_DIST_SCHEDULE: case OMP_CLAUSE_NUM_TEAMS: + case OMP_CLAUSE_THREAD_LIMIT: case OMP_CLAUSE_SAFELEN: case OMP_CLAUSE_SIMDLEN: OMP_CLAUSE_OPERAND (nc, 0) --- gcc/tree-pretty-print.c.jj 2013-06-12 11:53:15.000000000 +0200 +++ gcc/tree-pretty-print.c 2013-06-12 12:16:32.441883566 +0200 @@ -533,6 +533,13 @@ dump_omp_clause (pretty_printer *buffer, pp_character (buffer, ')'); break; + case OMP_CLAUSE_THREAD_LIMIT: + pp_string (buffer, "thread_limit("); + dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause), + spc, flags, false); + pp_character (buffer, ')'); + break; + case OMP_CLAUSE_DEVICE: pp_string (buffer, "device("); dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause), --- gcc/tree.h.jj 2013-06-12 11:53:15.000000000 +0200 +++ gcc/tree.h 2013-06-12 12:13:18.799984270 +0200 @@ -431,6 +431,9 @@ enum omp_clause_code /* OpenMP clause: num_teams(integer-expression). */ OMP_CLAUSE_NUM_TEAMS, + /* OpenMP clause: thread_limit(integer-expression). */ + OMP_CLAUSE_THREAD_LIMIT, + /* OpenMP clause: proc_bind ({master,close,spread}). */ OMP_CLAUSE_PROC_BIND, @@ -1978,6 +1981,10 @@ extern void protected_set_expr_location #define OMP_CLAUSE_NUM_TEAMS_EXPR(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_NUM_TEAMS), 0) +#define OMP_CLAUSE_THREAD_LIMIT_EXPR(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, \ + OMP_CLAUSE_THREAD_LIMIT), 0) + #define OMP_CLAUSE_DEVICE_ID(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_DEVICE), 0) --- gcc/c-family/c-pragma.h.jj 2013-03-27 13:01:09.000000000 +0100 +++ gcc/c-family/c-pragma.h 2013-06-12 12:18:48.668687172 +0200 @@ -104,6 +104,7 @@ typedef enum pragma_omp_clause { PRAGMA_OMP_CLAUSE_SHARED, PRAGMA_OMP_CLAUSE_SIMDLEN, PRAGMA_OMP_CLAUSE_TASKGROUP, + PRAGMA_OMP_CLAUSE_THREAD_LIMIT, PRAGMA_OMP_CLAUSE_TO, PRAGMA_OMP_CLAUSE_UNIFORM, PRAGMA_OMP_CLAUSE_UNTIED