From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21451 invoked by alias); 10 Mar 2015 12:37:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 20459 invoked by uid 89); 10 Mar 2015 12:37:58 -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; Tue, 10 Mar 2015 12:37:56 +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 1YVJQ0-0000es-9e from Thomas_Schwinge@mentor.com ; Tue, 10 Mar 2015 05:37:52 -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; Tue, 10 Mar 2015 12:37:50 +0000 From: Thomas Schwinge To: Bernd Schmidt , CC: Ilya Verbin , Jakub Jelinek , Richard Biener , Kirill Yukhin , Andrey Turetskiy Subject: Re: [PATCH 6/n] OpenMP 4.0 offloading infrastructure: option handling In-Reply-To: <87lhjue1lz.fsf@schwinge.name> References: <20141011144900.GA16368@msticlxl57.ims.intel.com> <20141013101909.GT10376@tucnak.redhat.com> <20141013103311.GA64058@msticlxl57.ims.intel.com> <87d257ducq.fsf@kepler.schwinge.homeip.net> <87lhjue1lz.fsf@schwinge.name> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Tue, 10 Mar 2015 12:37:00 -0000 Message-ID: <87zj7lc9k4.fsf@schwinge.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2015-03/txt/msg00556.txt.bz2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 7797 Hi! Ping. On Thu, 19 Feb 2015 09:39:52 +0100, I wrote: > On Wed, 18 Feb 2015 18:04:21 +0100, I wrote: > > On Mon, 13 Oct 2014 14:33:11 +0400, Ilya Verbin wro= te: > > > On 13 Oct 12:19, Jakub Jelinek wrote: > > > > On Sat, Oct 11, 2014 at 06:49:00PM +0400, Ilya Verbin wrote: > > > > > 2. -foffload-abi=3D[lp64|ilp32] > > > > > This option is supposed to tell mkoffload (and offload compile= r) which ABI is > > > > > used in streamed GIMPLE. This option is desirable, because host = and offload > > > > > compilers must have the same ABI. The option is generated by the= host compiler > > > > > automatically, it should not be specified by user. > > > >=20 > > > > But I'd like to understand why is this one needed. > > > > Why should the compilers care? Aggregates layout and alignment of > > > > integral/floating types must match between host and offload compile= rs, sure, > > > > but isn't that something streamed already in the LTO bytecode? > > > > Or is LTO streamer not streaming some types like long_type_node? > > > > I'd expect if host and offload compiler disagree on long type size = that > > > > you'd just use a different integral type with the same size as long= on the > > > > host. > > > > Different sized pointers are of course a bigger problem, but can't = you just > > > > error out on that during reading of the LTO, or even handle it (jus= t use > > > > some integral type for when is the pointer stored in memory, and ju= st > > > > convert to pointer after reads from memory, and convert back before= storing > > > > to memory). Erroring out during LTO streaming in sounds just fine = to me > > > > though. > > >=20 > > > Actually this option was developed by Bernd, so I think PTX team is g= oing to use > > > it somehow. In MIC's case we're planning just to check in mkoffload = that host > > > and target compiler's ABI are the same. Without this check we will c= rash in LTO > > > streamer with ICE, so I'd like to issue an error message, rather than= crashing. > >=20 > > In gcc/config/i386/intelmic-mkoffload.c, this option is now parsed to > > initialize the target_ilp32 variable, which will then be used > > (target_ilp32 ? "-m32" : "-m64") when invoking different tools. > >=20 > > In nvptx, we've been using the following approach: > >=20 > > --- gcc/config/nvptx/nvptx.h > > +++ gcc/config/nvptx/nvptx.h > > @@ -54,24 +54,28 @@ > >=20=20 > > /* Type Layout. */ > >=20=20 > > +#define TARGET_64BIT \ > > + (flag_offload_abi =3D=3D OFFLOAD_ABI_UNSET ? TARGET_ABI64 \ > > + : flag_offload_abi =3D=3D OFFLOAD_ABI_LP64 ? true : false) > > + > > #define DEFAULT_SIGNED_CHAR 1 > >=20=20 > > #define SHORT_TYPE_SIZE 16 > > #define INT_TYPE_SIZE 32 > > -#define LONG_TYPE_SIZE (TARGET_ABI64 ? 64 : 32) > > +#define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) > > #define LONG_LONG_TYPE_SIZE 64 > > #define FLOAT_TYPE_SIZE 32 > > #define DOUBLE_TYPE_SIZE 64 > > #define LONG_DOUBLE_TYPE_SIZE 64 > >=20=20 > > #undef SIZE_TYPE > > -#define SIZE_TYPE (TARGET_ABI64 ? "long unsigned int" : "unsigned int") > > +#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") > > #undef PTRDIFF_TYPE > > -#define PTRDIFF_TYPE (TARGET_ABI64 ? "long int" : "int") > > +#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") > >=20=20 > > -#define POINTER_SIZE (TARGET_ABI64 ? 64 : 32) > > +#define POINTER_SIZE (TARGET_64BIT ? 64 : 32) > >=20=20 > > -#define Pmode (TARGET_ABI64 ? DImode : SImode) > > +#define Pmode (TARGET_64BIT ? DImode : SImode) > >=20=20 > > /* Registers. Since ptx is a virtual target, we just define a few > > hard registers for special purposes and leave pseudos unallocated. = */ > >=20 > > Should we settle on one of the two, that is, either pass -m[...] from > > mkoffload, or handle flag_offload_abi in the respective backend? I thi= nk > > I prefer the intelmic-mkoffload.c approach; this seems cleaner to me: > > mkoffload "configures" the offloading compiler. (Also, the flag 32-bit > > vs. 64-bit flag may in fact be needed for tools other than the offloadi= ng > > compiler). >=20 > Well, "for instance", when in -m32 mode, we also need to use it in > gcc/config/nvptx/mkoffload.c:compile_native -- otherwise, later on, the > linker will not be happy with the request to link a 64-bit object file > with 32-bit object files... >=20 > > Bernd, is there any specific reason for the approach you had > > chosen? >=20 > OK to do the following instead? (Coding style/code copied from > gcc/config/i386/intelmic-mkoffload.c for consistency.) >=20 > --- gcc/config/nvptx/mkoffload.c > +++ gcc/config/nvptx/mkoffload.c > @@ -126,6 +126,9 @@ static id_map *var_ids, **vars_tail =3D &var_ids; > static const char *ptx_name; > static const char *ptx_cfile_name; >=20=20 > +/* Shows if we should compile binaries for i386 instead of x86-64. */ > +bool target_ilp32 =3D false; > + > /* Delete tempfiles. */ >=20=20 > /* Unlink a temporary file unless requested otherwise. */ > @@ -883,6 +886,7 @@ compile_native (const char *infile, const char *outfi= le, const char *compiler) > struct obstack argv_obstack; > obstack_init (&argv_obstack); > obstack_ptr_grow (&argv_obstack, compiler); > + obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); > obstack_ptr_grow (&argv_obstack, infile); > obstack_ptr_grow (&argv_obstack, "-c"); > obstack_ptr_grow (&argv_obstack, "-o"); > @@ -960,10 +964,23 @@ main (int argc, char **argv) > passed with @file. Expand them into argv before processing. */ > expandargv (&argc, &argv); >=20=20 > + /* Find out whether we should compile binaries for i386 or x86-64. */ > + for (int i =3D argc - 1; i > 0; i--) > + if (strncmp (argv[i], "-foffload-abi=3D", sizeof ("-foffload-abi=3D"= ) - 1) =3D=3D 0) > + { > + if (strstr (argv[i], "ilp32")) > + target_ilp32 =3D true; > + else if (!strstr (argv[i], "lp64")) > + fatal_error (input_location, > + "unrecognizable argument of option -foffload-abi"); > + break; > + } > + > struct obstack argv_obstack; > obstack_init (&argv_obstack); > obstack_ptr_grow (&argv_obstack, driver); > obstack_ptr_grow (&argv_obstack, "-xlto"); > + obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); > obstack_ptr_grow (&argv_obstack, "-S"); >=20=20 > for (int ix =3D 1; ix !=3D argc; ix++) > diff --git gcc/config/nvptx/nvptx.h gcc/config/nvptx/nvptx.h > index 15460b7..e74d16f 100644 > --- gcc/config/nvptx/nvptx.h > +++ gcc/config/nvptx/nvptx.h > @@ -58,28 +58,24 @@ >=20=20 > /* Type Layout. */ >=20=20 > -#define TARGET_64BIT \ > - (flag_offload_abi =3D=3D OFFLOAD_ABI_UNSET ? TARGET_ABI64 \ > - : flag_offload_abi =3D=3D OFFLOAD_ABI_LP64 ? true : false) > - > #define DEFAULT_SIGNED_CHAR 1 >=20=20 > #define SHORT_TYPE_SIZE 16 > #define INT_TYPE_SIZE 32 > -#define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) > +#define LONG_TYPE_SIZE (TARGET_ABI64 ? 64 : 32) > #define LONG_LONG_TYPE_SIZE 64 > #define FLOAT_TYPE_SIZE 32 > #define DOUBLE_TYPE_SIZE 64 > #define LONG_DOUBLE_TYPE_SIZE 64 >=20=20 > #undef SIZE_TYPE > -#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") > +#define SIZE_TYPE (TARGET_ABI64 ? "long unsigned int" : "unsigned int") > #undef PTRDIFF_TYPE > -#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") > +#define PTRDIFF_TYPE (TARGET_ABI64 ? "long int" : "int") >=20=20 > -#define POINTER_SIZE (TARGET_64BIT ? 64 : 32) > +#define POINTER_SIZE (TARGET_ABI64 ? 64 : 32) >=20=20 > -#define Pmode (TARGET_64BIT ? DImode : SImode) > +#define Pmode (TARGET_ABI64 ? DImode : SImode) >=20=20 > /* Registers. Since ptx is a virtual target, we just define a few > hard registers for special purposes and leave pseudos unallocated. */ Gr=C3=BC=C3=9Fe, Thomas --=-=-= Content-Type: application/pgp-signature Content-length: 472 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJU/uWbAAoJEPoxNhtoi6COuBkIAIsaifBgtundtSM7sXGOfHUc AehC/OUC7V05XbquRRKAxtGpF6sadwRiUyCx72nOnPKCNGWT7PMND8HXKmcouI/1 gVFXL0o1GCOneF1wjl8+RdHZ8DEWn6BKKphemiUMkUBA84nfZ4rvNfMR/T7GtPP0 pq+Mi+BPVvSctX1B1yjMWO8Zodr6I8nGKYy71h9jI8bQ+t4JCyyN2UCtpxYUVhzl U9riyLvVGQlQQ3nDJJnIWJy0VQsB/TFVDmO0feehMGahs7ysv2DucjtHJMpb6rys DU559dLf56/a93g78ny/z7tnnkF4WILldvefrVBjbFBEOK9aJgJiAwLeaf+OT6Q= =8oXm -----END PGP SIGNATURE----- --=-=-=--