From patchwork Tue Nov 10 14:19:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 542348 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 7CF0A140D69 for ; Wed, 11 Nov 2015 01:20:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=DKfWyLBP; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=O3bxYjHPXGl456W5qvJnU/icdnds+BC9+9f2y20uarMhnjU7/1 Fj7644GkvCYCPaylKLu81hvZMAMWo+BCEldwdjaGvXVVSbIkK7Q2TtsxM542sGaV 18PaHcoKWigpkKpuw3zl70K3ZtrOZ42FtJ3q+h0faN0i3+iD4rJSm/NRc= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=nxWNdhBTni2NnaA4ioQd4hNac8Y=; b=DKfWyLBPFfNOxR8u+oaE I60aexZgXMbVhDRgHqC5i3/Ras5c+x4bwuDwKWTHJ5+1VpnZw4Go85KAZWBbar9v KIUBgJh39JHvEUXJNwYlsIjOXNusD5Zc0pmWK6PL3f/PBdPVQGS9XoLzJsWvfaSG pFT/cMBn4jz9GMw2cRqx2hM= Received: (qmail 14386 invoked by alias); 10 Nov 2015 14:19:56 -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 14298 invoked by uid 89); 10 Nov 2015 14:19:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f50.google.com Received: from mail-qg0-f50.google.com (HELO mail-qg0-f50.google.com) (209.85.192.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 10 Nov 2015 14:19:54 +0000 Received: by qgec40 with SMTP id c40so111317066qge.2 for ; Tue, 10 Nov 2015 06:19:51 -0800 (PST) X-Received: by 10.140.132.139 with SMTP id 133mr4793963qhe.49.1447165191693; Tue, 10 Nov 2015 06:19:51 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id o77sm1376219qgd.15.2015.11.10.06.19.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Nov 2015 06:19:51 -0800 (PST) To: GCC Patches , Thomas Schwinge From: Nathan Sidwell Subject: [gomp4] Random omp-low.c backporting Message-ID: <5641FD06.9010504@acm.org> Date: Tue, 10 Nov 2015 09:19:50 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 I've committed this to backport a bunch of random bits from trunk to gomp4, and thereby reduce divergence. nathan 2015-11-10 Nathan Sidwell * omp-low.c: Backport whitespace & formatting changes from trunk. (is_atomic_compatible_p): Delete. (lower_reduction_clauses): Don't call it. (expand_omp_for_static_nochunk): Revert no-longer needed thread numbering expansion. (set_oacc_fn_attrib): Make static, fixup comment. (expand_omp_for_static_chunk): Likewise. (expand_omp_target): Adjust args initial size. (lower_omp_target): Rename label to oacc_firstprivate_map. Tweak assertions. Index: omp-low.c =================================================================== --- omp-low.c (revision 230080) +++ omp-low.c (working copy) @@ -3950,6 +3950,7 @@ maybe_lookup_ctx (gimple *stmt) return n ? (omp_context *) n->value : NULL; } + /* Find the mapping for DECL in CTX or the immediately enclosing context that has a mapping for DECL. @@ -5446,24 +5447,6 @@ lower_lastprivate_clauses (tree clauses, gimple_seq_add_stmt (stmt_list, gimple_build_label (label)); } -/* Returns true if this reduction operation is compatible with atomics. */ - -static bool -is_atomic_compatible_reduction (tree var, omp_context *ctx) -{ - if (!is_gimple_omp_oacc (ctx->stmt)) - return true; - - /* OpenACC requires an additional level of indirection due to the use - of shared memory. Because of that, it's better to surround the - reduction inside a atomic start/stop region. */ - if (is_reference (var)) - return false; - - return true; -} - - /* Lower the OpenACC reductions of CLAUSES for compute axis LEVEL (which might be a placeholder). INNER is true if this is an inner axis of a multi-axis loop. FORK and JOIN are (optional) fork and @@ -5718,18 +5701,15 @@ lower_reduction_clauses (tree clauses, g if (code == MINUS_EXPR) code = PLUS_EXPR; - if (count == 1 && is_atomic_compatible_reduction (var, ctx)) + if (count == 1) { tree addr = build_fold_addr_expr_loc (clause_loc, ref); addr = save_expr (addr); - ref = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (addr)), addr); - x = fold_build2_loc (clause_loc, code, TREE_TYPE (ref), ref, - new_var); + x = fold_build2_loc (clause_loc, code, TREE_TYPE (ref), ref, new_var); x = build2 (OMP_ATOMIC, void_type_node, addr, x); gimplify_and_add (x, stmt_seqp); - return; } else if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF) @@ -9135,7 +9115,6 @@ expand_omp_for_static_nochunk (struct om t = fold_binary (fd->loop.cond_code, boolean_type_node, fold_convert (type, fd->loop.n1), fold_convert (type, fd->loop.n2)); - if (fd->collapse == 1 && TYPE_UNSIGNED (type) && (t == NULL_TREE || !integer_onep (t))) @@ -9181,22 +9160,20 @@ expand_omp_for_static_nochunk (struct om { case GF_OMP_FOR_KIND_FOR: nthreads = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS); - nthreads = build_call_expr (nthreads, 0); threadid = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM); - threadid = build_call_expr (threadid, 0); break; case GF_OMP_FOR_KIND_DISTRIBUTE: nthreads = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_TEAMS); - nthreads = build_call_expr (nthreads, 0); threadid = builtin_decl_explicit (BUILT_IN_OMP_GET_TEAM_NUM); - threadid = build_call_expr (threadid, 0); break; default: gcc_unreachable (); } + nthreads = build_call_expr (nthreads, 0); nthreads = fold_convert (itype, nthreads); nthreads = force_gimple_operand_gsi (&gsi, nthreads, true, NULL_TREE, true, GSI_SAME_STMT); + threadid = build_call_expr (threadid, 0); threadid = fold_convert (itype, threadid); threadid = force_gimple_operand_gsi (&gsi, threadid, true, NULL_TREE, true, GSI_SAME_STMT); @@ -9588,7 +9565,6 @@ expand_omp_for_static_chunk (struct omp_ cont_bb = region->cont; gcc_assert (EDGE_COUNT (iter_part_bb->succs) == 2); fin_bb = BRANCH_EDGE (iter_part_bb)->dest; - gcc_assert (broken_loop || fin_bb == FALLTHRU_EDGE (cont_bb)->dest); seq_start_bb = split_edge (FALLTHRU_EDGE (iter_part_bb)); @@ -9623,7 +9599,6 @@ expand_omp_for_static_chunk (struct omp_ t = fold_binary (fd->loop.cond_code, boolean_type_node, fold_convert (type, fd->loop.n1), fold_convert (type, fd->loop.n2)); - if (fd->collapse == 1 && TYPE_UNSIGNED (type) && (t == NULL_TREE || !integer_onep (t))) @@ -9669,22 +9644,20 @@ expand_omp_for_static_chunk (struct omp_ { case GF_OMP_FOR_KIND_FOR: nthreads = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_THREADS); - nthreads = build_call_expr (nthreads, 0); threadid = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM); - threadid = build_call_expr (threadid, 0); break; case GF_OMP_FOR_KIND_DISTRIBUTE: nthreads = builtin_decl_explicit (BUILT_IN_OMP_GET_NUM_TEAMS); - nthreads = build_call_expr (nthreads, 0); threadid = builtin_decl_explicit (BUILT_IN_OMP_GET_TEAM_NUM); - threadid = build_call_expr (threadid, 0); break; default: gcc_unreachable (); } + nthreads = build_call_expr (nthreads, 0); nthreads = fold_convert (itype, nthreads); nthreads = force_gimple_operand_gsi (&gsi, nthreads, true, NULL_TREE, true, GSI_SAME_STMT); + threadid = build_call_expr (threadid, 0); threadid = fold_convert (itype, threadid); threadid = force_gimple_operand_gsi (&gsi, threadid, true, NULL_TREE, true, GSI_SAME_STMT); @@ -9957,7 +9930,6 @@ expand_omp_for_static_chunk (struct omp_ /* Replace the GIMPLE_OMP_RETURN with a barrier, or nothing. */ gsi = gsi_last_bb (exit_bb); - if (!gimple_omp_return_nowait_p (gsi_stmt (gsi))) { t = gimple_omp_return_lhs (gsi_stmt (gsi)); @@ -12485,9 +12457,7 @@ oacc_launch_pack (unsigned code, tree de The attribute value is a TREE_LIST. A set of dimensions is represented as a list of INTEGER_CST. Those that are runtime - expres are represented as an INTEGER_CST of zero. Defaults are set - as NULL_TREE and will be filled in later by the target hook - TARGET_GOACC_VALIDATE_DIMS. + exprs are represented as an INTEGER_CST of zero. TOOO. Normally the attribute will just contain a single such list. If however it contains a list of lists, this will represent the use of @@ -12515,7 +12485,7 @@ replace_oacc_fn_attrib (tree fn, tree di function attribute. Push any that are non-constant onto the ARGS list, along with an appropriate GOMP_LAUNCH_DIM tag. */ -void +static void set_oacc_fn_attrib (tree fn, tree clauses, vec *args) { /* Must match GOMP_DIM ordering. */ @@ -12659,7 +12629,6 @@ expand_omp_target (struct omp_region *re bool offloaded, data_region; entry_stmt = as_a (last_stmt (region->entry)); - new_bb = region->entry; offloaded = is_gimple_omp_offloaded (entry_stmt); @@ -13041,7 +13010,7 @@ expand_omp_target (struct omp_region *re gimple *g; bool tagging = false; /* The maximum number used by any start_ix, without varargs. */ - auto_vec args; + auto_vec args; args.quick_push (device); if (offloaded) args.quick_push (build_fold_addr_expr (child_fn)); @@ -13228,7 +13197,7 @@ expand_omp (struct omp_region *region) if (region->type == GIMPLE_OMP_FOR && gimple_omp_for_combined_p (last_stmt (region->entry))) inner_stmt = last_stmt (region->inner->entry); - + if (region->inner) expand_omp (region->inner); @@ -13463,7 +13432,7 @@ omp_expand_local (basic_block head) dump_omp_region (dump_file, root_omp_region, 0); fprintf (dump_file, "\n"); } - + remove_exit_barriers (root_omp_region); expand_omp (root_omp_region); @@ -14488,6 +14457,7 @@ lower_omp_for_lastprivate (struct omp_fo } } + /* Lower code for an OMP loop directive. */ static void @@ -14576,7 +14546,6 @@ lower_omp_for (gimple_stmt_iterator *gsi /* The pre-body and input clauses go before the lowered GIMPLE_OMP_FOR. */ dlist = NULL; body = NULL; - lower_rec_input_clauses (gimple_omp_for_clauses (stmt), &body, &dlist, ctx, fdp); gimple_seq_add_seq (&body, gimple_omp_for_pre_body (stmt)); @@ -15530,7 +15499,7 @@ lower_omp_target (gimple_stmt_iterator * case OMP_CLAUSE_MAP: case OMP_CLAUSE_TO: case OMP_CLAUSE_FROM: - oacc_firstprivate_2: + oacc_firstprivate_map: nc = c; ovar = OMP_CLAUSE_DECL (c); if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP @@ -15581,9 +15550,9 @@ lower_omp_target (gimple_stmt_iterator * x = build_sender_ref (ovar, ctx); if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP - && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER - && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c) - && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE) + && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER + && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c) + && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE) { gcc_assert (offloaded); tree avar @@ -15596,7 +15565,7 @@ lower_omp_target (gimple_stmt_iterator * } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE) { - gcc_assert (is_gimple_omp_oacc (ctx->stmt)); + gcc_checking_assert (is_gimple_omp_oacc (ctx->stmt)); if (TREE_CODE (TREE_TYPE (var)) != REFERENCE_TYPE) var = build_fold_addr_expr (var); else @@ -15727,8 +15696,7 @@ lower_omp_target (gimple_stmt_iterator * case OMP_CLAUSE_FIRSTPRIVATE: if (is_oacc_parallel (ctx)) - goto oacc_firstprivate_2; - gcc_assert (!is_gimple_omp_oacc (ctx->stmt)); + goto oacc_firstprivate_map; ovar = OMP_CLAUSE_DECL (c); if (is_reference (ovar)) talign = TYPE_ALIGN_UNIT (TREE_TYPE (TREE_TYPE (ovar)));