From patchwork Mon Aug 3 11:37:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 503124 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 C865F1402DE for ; Mon, 3 Aug 2015 21:37:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=IWdfVCUf; 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:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type; q=dns; s=default; b=Ny0SNH1aOHQGTEPYagYeqe3FOfJjf L8NzQllwxonnJRio/VIkL+ZoLV39Y9LxLCAAZFTlR7Pho0apSI8YYifthysUIsL+ J1TRlQX0s6d9Hc6Jd22mIwYPEuDOeVGoDucshEP+eLnrwKVsvqtRAMWkooklBQsP 4sW27KsV91vUzw= 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:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type; s=default; bh=vZu1f67Y6pCGImKN+tgeTqb2iqA=; b=IWd fVCUfoaPkL9qzTNKdbMDcLatGbTvOeqxsovxbB/idD0NtYQr/Kp2chfNi5OEp/CR eKcKsaeBFrj3lcTuc2pEaWo8yvhpBkkuUqYT4Pljt0KUvpygeJhqFO+z4fa1M26/ fUZazQixYbsil0XuMDJQMbkxsXt41dtt1H6bK0fA= Received: (qmail 24450 invoked by alias); 3 Aug 2015 11:37:30 -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 24440 invoked by uid 89); 3 Aug 2015 11:37:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Aug 2015 11:37:28 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZME3Y-0004Kx-MT from Thomas_Schwinge@mentor.com for gcc-patches@gcc.gnu.org; Mon, 03 Aug 2015 04:37:25 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Mon, 3 Aug 2015 12:37:23 +0100 From: Thomas Schwinge To: Nathan Sidwell , GCC Patches Subject: Re: [gomp4] expand acc_on_device earlier In-Reply-To: <55BEC292.6050300@acm.org> References: <55BEC292.6050300@acm.org> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) Date: Mon, 3 Aug 2015 13:37:08 +0200 Message-ID: <874mkgob6j.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Sun, 2 Aug 2015 21:23:30 -0400, Nathan Sidwell wrote: > I've committed this to gomp4 branch. It expands the acc_on_device builtin > earlier in the new oacc_xform pass. This will allow more optimization earlier on. Thanks! > The existing expansion point now only needs to deal with the host-side case. Actually, no; committed to gomp-4_0-branch in r226498: commit 5d1009bd4b959da699cf439200ffa571bf547026 Author: tschwinge Date: Mon Aug 3 11:36:01 2015 +0000 Fix offload compiler build, and de-duplicate acc_on_device logic When building an x86_64-intelmicemul-linux-gnu offloading compiler with r226484, the __builtin_acc_on_device usage in libgomp/oacc-init.c:acc_on_device makes it blow up: [...]/source-gcc/libgomp/oacc-init.c: In function 'acc_on_device': [...]/source-gcc/libgomp/oacc-init.c:643:10: internal compiler error: in expand_builtin_acc_on_device, at builtins.c:5891 return __builtin_acc_on_device (dev); ^ 0x6d9632 expand_builtin_acc_on_device [...]/source-gcc/gcc/builtins.c:5891 0x6d9632 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int) [...]/source-gcc/gcc/builtins.c:7127 0x8021ad expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) [...]/source-gcc/gcc/expr.c:10361 0x80e8b5 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, tree_node*) [...]/source-gcc/gcc/expr.c:5400 0x810eb4 expand_assignment(tree_node*, tree_node*, bool) [...]/source-gcc/gcc/expr.c:5169 0x6f927b expand_call_stmt [...]/source-gcc/gcc/cfgexpand.c:2349 0x6f927b expand_gimple_stmt_1 [...]/source-gcc/gcc/cfgexpand.c:3238 0x6fa77c expand_gimple_stmt [...]/source-gcc/gcc/cfgexpand.c:3399 0x6fa842 expand_gimple_tailcall [...]/source-gcc/gcc/cfgexpand.c:3446 0x6fc615 expand_gimple_basic_block [...]/source-gcc/gcc/cfgexpand.c:5388 0x701456 execute [...]/source-gcc/gcc/cfgexpand.c:6023 (This is not a problem for a nvptx-none offloading compiler, because of its open-coded libgcc/config/nvptx/gomp-acc_on_device.c:acc_on_device implementation.) gcc/ * builtins.c (expand_builtin_on_device): Don't expect to be expanded on host compiler. libgcc/ * config/nvptx/gomp-acc_on_device.c: Don't include "gomp-constants.h". (acc_on_device): Don't code directly here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@226498 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.gomp | 3 +++ gcc/builtins.c | 30 ++++++++++++++++++------------ gcc/omp-low.c | 7 ++----- libgcc/ChangeLog.gomp | 10 ++++++++-- libgcc/config/nvptx/gomp-acc_on_device.c | 16 +++++++--------- libgomp/oacc-init.c | 2 +- 6 files changed, 39 insertions(+), 29 deletions(-) Grüße, Thomas diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp index a30f6a3..d5cc1ed 100644 --- gcc/ChangeLog.gomp +++ gcc/ChangeLog.gomp @@ -1,5 +1,8 @@ 2015-08-03 Thomas Schwinge + * builtins.c (expand_builtin_on_device): Don't expect to be + expanded on host compiler. + * gimplify.c (oacc_default_clause): Remove in_code formal parameter. Adjust all users. diff --git gcc/builtins.c gcc/builtins.c index 9bc08f6..ce369a1 100644 --- gcc/builtins.c +++ gcc/builtins.c @@ -5880,39 +5880,45 @@ expand_stack_save (void) } -/* Expand OpenACC acc_on_device. This is expanded in the openacc - transform pass, but if the user has this outside of an offloaded - region, we'll find it here. In that case we must be host or none. */ +/* Expand OpenACC acc_on_device. This is usually expanded in the + oacc_transform pass, earlier on, but if used outside of an offloaded region, + we'll find it here. */ static rtx expand_builtin_acc_on_device (tree exp, rtx target) { -#ifdef ACCEL_COMPILER - gcc_unreachable (); -#else +#ifndef ACCEL_COMPILER gcc_assert (!get_oacc_fn_attrib (current_function_decl)); +#endif if (!validate_arglist (exp, INTEGER_TYPE, VOID_TYPE)) return NULL_RTX; tree arg = CALL_EXPR_ARG (exp, 0); - rtx val = expand_normal (arg); + + /* Return (arg == v1 || arg == v2) ? 1 : 0. */ + machine_mode v_mode = TYPE_MODE (TREE_TYPE (arg)); + rtx v = expand_normal (arg), v1, v2; +#ifdef ACCEL_COMPILER + v1 = GEN_INT (GOMP_DEVICE_NOT_HOST); + v2 = GEN_INT (ACCEL_COMPILER_acc_device); +#else + v1 = GEN_INT (GOMP_DEVICE_NONE); + v2 = GEN_INT (GOMP_DEVICE_HOST); +#endif machine_mode target_mode = TYPE_MODE (integer_type_node); if (!target || !register_operand (target, target_mode)) target = gen_reg_rtx (target_mode); emit_move_insn (target, const1_rtx); rtx_code_label *done_label = gen_label_rtx (); - do_compare_rtx_and_jump (val, GEN_INT (GOMP_DEVICE_HOST), EQ, - false, GET_MODE (val), NULL_RTX, + do_compare_rtx_and_jump (v, v1, EQ, false, v_mode, NULL_RTX, NULL, done_label, PROB_EVEN); - do_compare_rtx_and_jump (val, GEN_INT (GOMP_DEVICE_NONE), EQ, - false, GET_MODE (val), NULL_RTX, + do_compare_rtx_and_jump (v, v2, EQ, false, v_mode, NULL_RTX, NULL, done_label, PROB_EVEN); emit_move_insn (target, const0_rtx); emit_label (done_label); return target; -#endif } /* Expand a thread-id/thread-count builtin for OpenACC. */ diff --git gcc/omp-low.c gcc/omp-low.c index ebf333f..701e8da 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -14510,12 +14510,9 @@ make_pass_late_lower_omp (gcc::context *ctxt) return new pass_late_lower_omp (ctxt); } -/* Transform an acc_on_device call. The std requires this folded at +/* Transform an acc_on_device call. OpenACC 2.0a requires this folded at compile time for constant operands. We always fold it. In an - offloaded function we're never 'none'. We cannot detect - host_nonshm here, as that's a dynamic feature of the runtime. - However, users shouldn't be using host_nonshm anyway, only the - test harness. */ + offloaded function we're never 'none'. */ static void oacc_xform_on_device (gimple_stmt_iterator *gsi, gimple stmt) diff --git libgcc/ChangeLog.gomp libgcc/ChangeLog.gomp index 4aa45e7..085bfda 100644 --- libgcc/ChangeLog.gomp +++ libgcc/ChangeLog.gomp @@ -1,6 +1,12 @@ -2015-07-17 Nathan Sidwell +2015-08-03 Thomas Schwinge - * config/nvptx/comp-acc_on_device.c: Include gomp-constants.h. + * config/nvptx/gomp-acc_on_device.c: Don't include + "gomp-constants.h". + (acc_on_device): Don't code directly here. + +2015-08-02 Nathan Sidwell + + * config/nvptx/gomp-acc_on_device.c: Include gomp-constants.h. (acc_on_device): Code directly here. 2015-07-17 Nathan Sidwell diff --git libgcc/config/nvptx/gomp-acc_on_device.c libgcc/config/nvptx/gomp-acc_on_device.c index e89cd9b..db94350 100644 --- libgcc/config/nvptx/gomp-acc_on_device.c +++ libgcc/config/nvptx/gomp-acc_on_device.c @@ -1,14 +1,12 @@ -#include "gomp-constants.h" +/* The compiler always attempts to expand acc_on_device, but if the + user disables the builtin, or calls it via a pointer, we have this + version. */ -/* For when the builtin is explicitly disabled. */ -int acc_on_device (int d) +int +acc_on_device (int dev) { - /* We can't use the builtin itself here, because that only expands - to device-like things inside offloaded compute regions, which - this isn't. Even though it'll be executed on the device -- - unless someone builds a host-side PTX compiler, which would be - very strange. */ - return d == GOMP_DEVICE_NOT_HOST || d == GOMP_DEVICE_NVIDIA_PTX; + /* Just rely on the compiler builtin. */ + return __builtin_acc_on_device (dev); } int acc_on_device_h_(int *d) diff --git libgomp/oacc-init.c libgomp/oacc-init.c index 79a643c..8dfe4a7 100644 --- libgomp/oacc-init.c +++ libgomp/oacc-init.c @@ -639,7 +639,7 @@ ialias (acc_set_device_num) int acc_on_device (int dev) { - /* It is safe to use the compiler builtin, as we're the host. */ + /* Just rely on the compiler builtin. */ return __builtin_acc_on_device (dev); }