From patchwork Mon Dec 22 11:20:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 423361 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 D892714007D for ; Mon, 22 Dec 2014 22:21:20 +1100 (AEDT) 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=w8sP6dDEsiL8zLD1 U0R5D3ywSi5/g+dd/nlKFW5knMHarRsRNr8UaoSagkY0yFdRnut8fCr9AOTrUPtK YNU3YBMvd7JfPGYEYBXCUZneAucgRXqUjXzHeIDKFMNsmWtE4j8Ld4QgxHUJ0oAE OrZeg4bNyPQBjkvBtCNAprxl8+I= 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=hiThAqgYw0QZdqDmou0wZV rJI4I=; b=OWQgDGQ7OMmnd6MyUxoWtlLb6veD6jSsDupKW9WdO7fkgPh8xPcNWc gul2uLLucXfOLwdTNTKhnW0Emsxw/rX7TB7P344dn0JKHnK3cNxNbHtOtUmSvsa8 eoUvp4JY/nznnhp9U57+TAOg+woQDPAcSyQ4nJwTZGKzXslpf0RYc= Received: (qmail 6901 invoked by alias); 22 Dec 2014 11:21:13 -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 6889 invoked by uid 89); 22 Dec 2014 11:21:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, 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, 22 Dec 2014 11:21:10 +0000 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 1Y312v-0003og-9i from Thomas_Schwinge@mentor.com ; Mon, 22 Dec 2014 03:21:05 -0800 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.181.6; Mon, 22 Dec 2014 11:21:03 +0000 From: Thomas Schwinge To: Ilya Verbin , Jakub Jelinek CC: , Kirill Yukhin , Andrey Turetskiy , Bernd Schmidt Subject: OMP builtins in offloading (was: [PATCH 1/4] Add mkoffload for Intel MIC) In-Reply-To: <20141022185701.GA21398@msticlxl57.ims.intel.com> References: <20141021171323.GA47586@msticlxl57.ims.intel.com> <20141021171602.GB47586@msticlxl57.ims.intel.com> <20141022082103.GH10376@tucnak.redhat.com> <20141022185701.GA21398@msticlxl57.ims.intel.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) Date: Mon, 22 Dec 2014 12:20:58 +0100 Message-ID: <87wq5kylph.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Wed, 22 Oct 2014 22:57:01 +0400, Ilya Verbin wrote: > --- /dev/null > +++ b/gcc/config/i386/intelmic-mkoffload.c > @@ -0,0 +1,541 @@ > +/* Offload image generation tool for Intel MIC devices. > +static const char * > +prepare_target_image (const char *target_compiler, int argc, char **argv) > +{ > + [...] > + obstack_init (&argv_obstack); > + obstack_ptr_grow (&argv_obstack, target_compiler); > + obstack_ptr_grow (&argv_obstack, "-xlto"); > + obstack_ptr_grow (&argv_obstack, "-fopenmp"); > + obstack_ptr_grow (&argv_obstack, "-shared"); > + obstack_ptr_grow (&argv_obstack, "-fPIC"); > + obstack_ptr_grow (&argv_obstack, opt1); What is the reason that you're adding -fopenmp here? I assume it is that otherwise you'd get tree streaming errors because of different builtins configurations, like this? $ [...]/build-gcc/gcc/xgcc -B[...]/build-gcc/gcc/ [...]/source-gcc/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/collapse-1.c -B[...]/build-gcc/x86_64-unknown-linux-gnu/./libgomp/ -B[...]/build-gcc/x86_64-unknown-linux-gnu/./libgomp/.libs -I[...]/build-gcc/x86_64-unknown-linux-gnu/./libgomp -I[...]/source-gcc/libgomp/testsuite/../../include -I[...]/source-gcc/libgomp/testsuite/.. -fmessage-length=0 -fno-diagnostics-show-caret -fdiagnostics-color=never -B[...]/install/offload-x86_64-intelmicemul-linux-gnu/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0 -B[...]/install/offload-x86_64-intelmicemul-linux-gnu/bin -fopenacc -DACC_DEVICE_TYPE_host_nonshm=1 -DACC_MEM_SHARED=0 -O2 -L[...]/build-gcc/x86_64-unknown-linux-gnu/./libgomp/.libs -lm -o ./collapse-1.exe lto1: internal compiler error: in streamer_get_builtin_tree, at tree-streamer-in.c:1136 0xc0b7ff streamer_get_builtin_tree(lto_input_block*, data_in*) [...]/source-gcc/gcc/tree-streamer-in.c:1136 0x8f7cc4 lto_input_tree_1(lto_input_block*, data_in*, LTO_tags, unsigned int) [...]/source-gcc/gcc/lto-streamer-in.c:1303 0x8f7ee0 lto_input_scc(lto_input_block*, data_in*, unsigned int*, unsigned int*) [...]/source-gcc/gcc/lto-streamer-in.c:1231 0x5e9bee lto_read_decls [...]/source-gcc/gcc/lto/lto.c:1889 0x5ebc5c lto_file_finalize [...]/source-gcc/gcc/lto/lto.c:2218 0x5ebc5c lto_create_files_from_ids [...]/source-gcc/gcc/lto/lto.c:2228 0x5ebc5c lto_file_read [...]/source-gcc/gcc/lto/lto.c:2269 0x5ebc5c read_cgraph_and_symbols [...]/source-gcc/gcc/lto/lto.c:2969 0x5ebc5c lto_main() [...]/source-gcc/gcc/lto/lto.c:3424 [...] mkoffload-intelmic: fatal error: [...]/install/offload-x86_64-intelmicemul-linux-gnu/bin//x86_64-unknown-linux-gnu-accel-x86_64-intelmicemul-linux-gnu-gcc returned 1 exit status compilation terminated. lto-wrapper: fatal error: [...]/install/offload-x86_64-intelmicemul-linux-gnu/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0//accel/x86_64-intelmicemul-linux-gnu/mkoffload returned 1 exit status compilation terminated. [...]/ld: lto-wrapper failed collect2: error: ld returned 1 exit status If that is the "only" reason to add -fopenmp there, can we then instead do the following? gcc/builtins.def | 8 ++++++-- gcc/config/i386/intelmic-mkoffload.c | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) Grüße, Thomas diff --git gcc/builtins.def gcc/builtins.def index b70e8e0..08bf62e 100644 --- gcc/builtins.def +++ gcc/builtins.def @@ -148,10 +148,13 @@ along with GCC; see the file COPYING3. If not see /* Builtin used by the implementation of OpenACC and OpenMP. Few of these are actually implemented in the compiler; most are in libgomp. */ +/* These builtins also need to be enabled in offloading compilers invoked from + mkoffload; for that purpose, we're checking the -foffload-abi flag here. */ #undef DEF_GOACC_BUILTIN #define DEF_GOACC_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ - false, true, true, ATTRS, false, flag_openacc) + false, true, true, ATTRS, false, \ + (flag_openacc || flag_offload_abi != OFFLOAD_ABI_UNSET)) #undef DEF_GOACC_BUILTIN_COMPILER #define DEF_GOACC_BUILTIN_COMPILER(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ @@ -160,7 +163,8 @@ along with GCC; see the file COPYING3. If not see #define DEF_GOMP_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ false, true, true, ATTRS, false, \ - (flag_openmp || flag_tree_parallelize_loops)) + (flag_openmp || flag_tree_parallelize_loops \ + || flag_offload_abi != OFFLOAD_ABI_UNSET)) /* Builtin used by implementation of Cilk Plus. Most of these are decomposed by the compiler but a few are implemented in libcilkrts. */ diff --git gcc/config/i386/intelmic-mkoffload.c gcc/config/i386/intelmic-mkoffload.c index c972f56..caf58a1 100644 --- gcc/config/i386/intelmic-mkoffload.c +++ gcc/config/i386/intelmic-mkoffload.c @@ -386,7 +386,6 @@ prepare_target_image (const char *target_compiler, int argc, char **argv) obstack_init (&argv_obstack); obstack_ptr_grow (&argv_obstack, target_compiler); obstack_ptr_grow (&argv_obstack, "-xlto"); - obstack_ptr_grow (&argv_obstack, "-fopenmp"); obstack_ptr_grow (&argv_obstack, "-shared"); obstack_ptr_grow (&argv_obstack, "-fPIC"); obstack_ptr_grow (&argv_obstack, opt1);