From patchwork Wed Oct 7 08:02:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 527166 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 D886D14029C for ; Wed, 7 Oct 2015 19:02:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=tCx+RHlS; 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:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=WWcCznYk4Mh7T2nR ROP/ZA7741+bIchuHaY6utRC8eUN8fXDslQaMGFnkRusFVjkX/VLNqKskuVDRQhP WlUMHXeSgmUhJaMaeEMnHsOZO5+iyFBgyvwTeAsafcsDCBW9f43gS0qW06y7QyCy uVYk3Cx2a7ni9uTHFvJ0EPnEonc= 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:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=2xAX5XsdSxc7HmR/Y1VXT1 aEdMk=; b=tCx+RHlSJ2DvMBg26I7uGbxPGx9HIyDi42z3MXhnxMU7c3V9ZsHow5 FH8kAad8LxGcOZF7GGKqGrxcYuE/YQKw9c0reltAzNeMs59vw6ADwABtRLIqZn8k DxqPwq92shQm+99I6Pkcfspz+NYrzdyR+71jXWYIcRjQONaOad1t4= Received: (qmail 91968 invoked by alias); 7 Oct 2015 08:02:48 -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 91957 invoked by uid 89); 7 Oct 2015 08:02:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, 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; Wed, 07 Oct 2015 08:02:45 +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 1ZjjgO-0002BQ-KR from Thomas_Schwinge@mentor.com ; Wed, 07 Oct 2015 01:02:40 -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; Wed, 7 Oct 2015 09:02:38 +0100 From: Thomas Schwinge To: James Norris , David Edelsohn CC: Subject: Re: [gomp4] Add -foffload-abi support for PPC In-Reply-To: <5613F8EC.4000400@codesourcery.com> References: <87zizxcxnm.fsf@schwinge.name> <5613F8EC.4000400@codesourcery.com> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Wed, 7 Oct 2015 10:02:29 +0200 Message-ID: <87bncbp0mi.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! rs6000/powerpc port maintainer copied. On Tue, 6 Oct 2015 11:38:04 -0500, James Norris wrote: > The attached patch adds the -foffload-abi option support for PPC. > Only support for the 64-bit ABI has been added. (Yes, only powerpc64le-linux-gnu configurations can be supported.) > Committed after regtesting with x86_64 and powerpc64le. Such a patch needs to go into trunk. (It's of course OK to test-drive it on gomp-4_0-branch first.) However: > + * common.opt (OFFLOAD_ABI_PPC64): New enum. > + * config/nvptx/mkoffload.c (compile_native): Handle new enum. > + (main): Handle new option. > + * config/rs6000/rs6000.c (rs6000_offload_options): New hook. > + * gcc/coretypes.h (OFFLOAD_ABI_PPC64): New enum. > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -1730,6 +1730,9 @@ Enum(offload_abi) String(ilp32) Value(OFFLOAD_ABI_ILP32) > EnumValue > Enum(offload_abi) String(lp64) Value(OFFLOAD_ABI_LP64) > > +EnumValue > +Enum(offload_abi) String(ppc64) Value(OFFLOAD_ABI_PPC64) > --- a/gcc/config/nvptx/mkoffload.c > +++ b/gcc/config/nvptx/mkoffload.c > @@ -367,6 +367,8 @@ compile_native (const char *infile, const char *outfile, const char *compiler) > case OFFLOAD_ABI_ILP32: > obstack_ptr_grow (&argv_obstack, "-m32"); > break; > + case OFFLOAD_ABI_PPC64: > + break; > default: > gcc_unreachable (); > } > @@ -458,6 +460,8 @@ main (int argc, char **argv) > offload_abi = OFFLOAD_ABI_LP64; > else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0) > offload_abi = OFFLOAD_ABI_ILP32; > + else if (strcmp (argv[i] + strlen (STR), "ppc64") == 0) > + offload_abi = OFFLOAD_ABI_PPC64; > else > fatal_error (input_location, > "unrecognizable argument of option " STR); > @@ -485,6 +489,8 @@ main (int argc, char **argv) > case OFFLOAD_ABI_ILP32: > obstack_ptr_grow (&argv_obstack, "-m32"); > break; > + case OFFLOAD_ABI_PPC64: > + break; > default: > gcc_unreachable (); > } > @@ -518,7 +524,8 @@ main (int argc, char **argv) > > /* PR libgomp/65099: Currently, we only support offloading in 64-bit > configurations, and only for OpenACC offloading. */ > - if (offload_abi == OFFLOAD_ABI_LP64 && fopenacc) > + if ((offload_abi == OFFLOAD_ABI_LP64 > + || (offload_abi == OFFLOAD_ABI_PPC64)) && fopenacc) > { > ptx_name = make_temp_file (".mkoffload"); > obstack_ptr_grow (&argv_obstack, "-o"); > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > +#undef TARGET_OFFLOAD_OPTIONS > +#define TARGET_OFFLOAD_OPTIONS rs6000_offload_options > +/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ > +static char * > +rs6000_offload_options (void) > +{ > + return xstrdup ("-foffload-abi=ppc64"); > +} > --- a/gcc/coretypes.h > +++ b/gcc/coretypes.h > @@ -170,7 +170,8 @@ enum tls_model { > enum offload_abi { > OFFLOAD_ABI_UNSET, > OFFLOAD_ABI_LP64, > - OFFLOAD_ABI_ILP32 > + OFFLOAD_ABI_ILP32, > + OFFLOAD_ABI_PPC64 > }; No, that's not how I meant it to be done; I wrote: | On Mon, 5 Oct 2015 07:06:55 -0500, James Norris wrote: | > [The -foffload-abi parameter] is not passed [to mkoffload] when using the | > ppc compiler, and as a result the 'unreachable' assertion [in mkoffload] | > went off. | | That's the bug: you need to pass this parameter: the target (a.k.a. host) | and offload target (a.k.a. device) compilers need to agree on the ABI to | use. This should be straightforward to do; see here: | | $ git grep -i offload.options -- gcc/config/i386/ | gcc/config/i386/i386.c:/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ | gcc/config/i386/i386.c:ix86_offload_options (void) | gcc/config/i386/i386.c:#undef TARGET_OFFLOAD_OPTIONS | gcc/config/i386/i386.c:#define TARGET_OFFLOAD_OPTIONS \ | gcc/config/i386/i386.c: ix86_offload_options | | gcc/config/i386/i386.c:ix86_offload_options: | | /* Implement the TARGET_OFFLOAD_OPTIONS hook. */ | static char * | ix86_offload_options (void) | { | if (TARGET_LP64) | return xstrdup ("-foffload-abi=lp64"); | return xstrdup ("-foffload-abi=ilp32"); | } | | In case that PowerPC supports additional ABIs, you need to add these to | gcc/coretypes.h:enum offload_abi, and adjust the parsing in the | mkoffloads (I can easily test the IntelMIC mkoffload patch for you); of | course we don't need to support anything but the 64-bit ABI (that you're | currently already using, I suppose). From a quick look at the *_TYPE_SIZE definitions in gcc/config/rs6000/rs6000.h as well as , "3-1 Fundamental Types", and , I gather we're dealing with regular ilp32/lp64 here. Then, I assume the right thing is to use the 64BIT flag from gcc/config/rs6000/sysv4.opt (which, per gcc/config.gcc I suppose is used for the relevant powerpc64le-linux-gnu configuration). (David?) I'm not sure where to place the TARGET_OFFLOAD_OPTIONS #define and the function definition in rs6000.c. (David?) So, please revert your patch and instead try the following. Grüße, Thomas --- gcc/config/rs6000/rs6000.c +++ gcc/config/rs6000/rs6000.c @@ -1688,6 +1688,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #define TARGET_LIBGCC_SHIFT_COUNT_MODE rs6000_abi_word_mode #undef TARGET_UNWIND_WORD_MODE #define TARGET_UNWIND_WORD_MODE rs6000_abi_word_mode + +#undef TARGET_OFFLOAD_OPTIONS +#define TARGET_OFFLOAD_OPTIONS rs6000_offload_options /* Processor table. */ @@ -9532,6 +9535,16 @@ rs6000_abi_word_mode (void) return TARGET_32BIT ? SImode : DImode; } +/* Implement the TARGET_OFFLOAD_OPTIONS hook. */ +static char * +rs6000_offload_options (void) +{ + if (TARGET_64BIT) + return xstrdup ("-foffload-abi=lp64"); + else + return xstrdup ("-foffload-abi=ilp32"); +} + /* On rs6000, function arguments are promoted, as are function return values. */