From patchwork Tue Nov 3 14:19:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 539430 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 CD5011402D6 for ; Wed, 4 Nov 2015 01:20:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=vjQAbcE9; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=oJDh/DhPDjZyUZ2qY 9YMUnHX7/VqOCdI1u6Smi+k0brKryrBJlsICOIMcstKvEJ0xuLVzBMxpTFPPH686 YopjDy0wiJ2nJLVW+85+797gUNG64SibZOXvOQnxOQU+cTfMVZYPpmSfF3/jcCNw yZXM4mp3ePbpWP1FglBcEAtLBU= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=mLWHinZvHvZq36/eIYj8QWt goho=; b=vjQAbcE9coecbqkfzwziK44GTU/m4pUFisGWpWfn5hhVRAj5D3YbUn0 gNFeIlJOd2THb0hYaz91x7K3OwUYEb3MAxgaz0YL2pwpKiqKMKHoPfrOMEhr4OJO Zkn3HEdKMK697tggdCpjFhiBQEh9I6Y9yeDBM8DrgAIGW8sJZLP4= Received: (qmail 122156 invoked by alias); 3 Nov 2015 14:19:58 -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 122146 invoked by uid 89); 3 Nov 2015 14:19:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 03 Nov 2015 14:19:56 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34950) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZtcRF-000161-ST for gcc-patches@gnu.org; Tue, 03 Nov 2015 09:19:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtcRC-0001Gh-Dm for gcc-patches@gnu.org; Tue, 03 Nov 2015 09:19:53 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:59636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtcRC-0001GE-5X for gcc-patches@gnu.org; Tue, 03 Nov 2015 09:19:50 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZtcRA-000648-99 from Tom_deVries@mentor.com for gcc-patches@gnu.org; Tue, 03 Nov 2015 06:19:48 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Tue, 3 Nov 2015 14:19:46 +0000 Subject: [gomp4, committed] Implement -foffload-alias To: Nathan Sidwell References: <56095EEF.7010700@mentor.com> CC: "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <5638C276.7070206@mentor.com> Date: Tue, 3 Nov 2015 15:19:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56095EEF.7010700@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 [ was: Re: [gomp4, WIP] Implement -foffload-alias ] On 28/09/15 17:38, Tom de Vries wrote: > Hi, > > this work-in-progress patch implements a new option > -foffload-alias=. > > > The option -foffload-alias=none instructs the compiler to assume that > objects references and pointer dereferences in an offload region do not > alias. > > The option -foffload-alias=pointer instructs the compiler to assume that > objects references in an offload region do not alias. > > The option -foffload-alias=all instructs the compiler to make no > assumptions about aliasing in offload regions. > > The default value is -foffload-alias=none. > > > The patch works by adding restrict to the types of the fields used to > pass data to an offloading region. > Updated patch attached, committed to gomp-4_0-branch. > Atm, the kernels-loop-offload-alias-ptr.c test-case passes, but the > kernels-loop-offload-alias-none.c test-case fails. I've dropped the two testcases from this patch, I'll commit in a follow-up patch. > For the latter, the > required amount of restrict is added, but it has no effect. I've > reported this in a more basic form in PR67742: "3rd-level restrict > ignored". I've committed a fix for that PR as reported here: https://gcc.gnu.org/ml/gcc-patches/2015-11/msg00204.html . Furthermore, I've added support for the option in the 'mask & 4' case in install_var_field, I ran into this when trying out some Fortran test-cases. Thanks, - Tom Implement -foffload-alias 2015-09-28 Tom de Vries * common.opt (foffload-alias): New option. * flag-types.h (enum offload_alias): New enum. * omp-low.c (install_var_field): Handle flag_offload_alias. * doc/invoke.texi (@item Code Generation Options): Add -foffload-alias. (@item -foffload-alias): New item. --- gcc/common.opt | 16 ++++++++++++++++ gcc/doc/invoke.texi | 11 +++++++++++ gcc/flag-types.h | 7 +++++++ gcc/omp-low.c | 28 ++++++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index c85ab49..135e777 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1738,6 +1738,22 @@ Enum(offload_abi) String(ilp32) Value(OFFLOAD_ABI_ILP32) EnumValue Enum(offload_abi) String(lp64) Value(OFFLOAD_ABI_LP64) +foffload-alias= +Common Joined RejectNegative Enum(offload_alias) Var(flag_offload_alias) Init(OFFLOAD_ALIAS_NONE) +-foffload-alias=[all|pointer|none] Assume non-aliasing in an offload region + +Enum +Name(offload_alias) Type(enum offload_alias) UnknownError(unknown offload aliasing %qs) + +EnumValue +Enum(offload_alias) String(all) Value(OFFLOAD_ALIAS_ALL) + +EnumValue +Enum(offload_alias) String(pointer) Value(OFFLOAD_ALIAS_POINTER) + +EnumValue +Enum(offload_alias) String(none) Value(OFFLOAD_ALIAS_NONE) + fomit-frame-pointer Common Report Var(flag_omit_frame_pointer) Optimization When possible do not generate stack frames. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 5a07512..8967f88 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1142,6 +1142,7 @@ See S/390 and zSeries Options. -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} @gol -fno-common -fno-ident @gol +-foffload-alias=@r{[}none@r{|}pointer@r{|}all@r{]} @gol -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol -fno-jump-tables @gol -frecord-gcc-switches @gol @@ -23842,6 +23843,16 @@ The options @option{-ftrapv} and @option{-fwrapv} override each other, so using using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line results in @option{-ftrapv} being effective. +@item -foffload-alias=@r{[}none@r{|}pointer@r{|}all@r{]} +@opindex -foffload-alias +The option @option{-foffload-alias=none} instructs the compiler to assume that +objects references and pointer dereferences in an offload region do not alias. +The option @option{-foffload-alias=pointer} instruct the compiler to assume that +objects references in an offload region do not alias. The option +@option{-foffload-alias=all} instructs the compiler to make no assumptions about +aliasing in offload regions. The default value is +@option{-foffload-alias=none}. + @item -fexceptions @opindex fexceptions Enable exception handling. Generates extra code needed to propagate diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 6301cea..87b1677 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -293,5 +293,12 @@ enum gfc_convert GFC_FLAG_CONVERT_LITTLE }; +enum offload_alias +{ + OFFLOAD_ALIAS_ALL, + OFFLOAD_ALIAS_POINTER, + OFFLOAD_ALIAS_NONE +}; + #endif /* ! GCC_FLAG_TYPES_H */ diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 3543785..6bac074 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1441,6 +1441,14 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx) tree field, type, sfield = NULL_TREE; splay_tree_key key = (splay_tree_key) var; + /* We use flag_offload_alias only for the oacc kernels region for the + moment. */ + bool offload_alias_p = is_oacc_kernels (ctx); + bool no_alias_var_p + = offload_alias_p && flag_offload_alias != OFFLOAD_ALIAS_ALL; + bool no_alias_ptr_p + = offload_alias_p && flag_offload_alias == OFFLOAD_ALIAS_NONE; + if ((mask & 8) != 0) { key = (splay_tree_key) &DECL_UID (var); @@ -1457,10 +1465,26 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx) if (mask & 4) { gcc_assert (TREE_CODE (type) == ARRAY_TYPE); - type = build_pointer_type (build_pointer_type (type)); + + type = build_pointer_type (type); + if (no_alias_var_p) + type = build_qualified_type (type, TYPE_QUAL_RESTRICT); + + type = build_pointer_type (type); + if (no_alias_var_p) + type = build_qualified_type (type, TYPE_QUAL_RESTRICT); } else if (by_ref) - type = build_pointer_type (type); + { + if (no_alias_ptr_p + && POINTER_TYPE_P (type)) + type = build_qualified_type (type, TYPE_QUAL_RESTRICT); + + type = build_pointer_type (type); + + if (no_alias_var_p) + type = build_qualified_type (type, TYPE_QUAL_RESTRICT); + } else if ((mask & 3) == 1 && is_reference (var)) type = TREE_TYPE (type); -- 1.9.1