From patchwork Wed Jan 28 16:02:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Verbin X-Patchwork-Id: 433901 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 3BBAA1401F6 for ; Thu, 29 Jan 2015 03:07:58 +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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=uWkX3kBcr9MOu/J7D wEKGmJdaOX+ommgdsvVf6i9hOYIpcyzCsp2Ny6+AbzX04LpD8alcXp2aP0wyPv2M ImgMOM9KTo7JDIVjnOwUk6Ks1u7EQcwfg7obmmOiaPPsa3B7rL5NdqNp7qKgxl5r W3tiYRLol35HXr+QRLAiAU28rc= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=pHKRYDqDqGyMijkH4Es+ECH ILXs=; b=uH9Dmd2J6fuTvrgxorNk1B9t2z7GkbtlNKZYwvHKj+Qg+eVNqsmXA0O wEoO/eQAb+yu5Z4gFqb5kjjL1iLpketOGjxtYk+SXHVQwEYanW2Kbv6mwO4SJnS1 cGUFmomEUznrz4Mo7iVRs9HxTz8rgKRaEpQag5U/AsuVhBBU2YaM= Received: (qmail 13138 invoked by alias); 28 Jan 2015 16:03:24 -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 13087 invoked by uid 89); 28 Jan 2015 16:03:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f180.google.com Received: from mail-wi0-f180.google.com (HELO mail-wi0-f180.google.com) (209.85.212.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 28 Jan 2015 16:03:15 +0000 Received: by mail-wi0-f180.google.com with SMTP id h11so12901585wiw.1 for ; Wed, 28 Jan 2015 08:03:12 -0800 (PST) X-Received: by 10.180.73.239 with SMTP id o15mr8430562wiv.14.1422460992687; Wed, 28 Jan 2015 08:03:12 -0800 (PST) Received: from msticlxl57.ims.intel.com (fmdmzpr01-ext.fm.intel.com. [192.55.54.36]) by mx.google.com with ESMTPSA id w3sm6685018wjf.3.2015.01.28.08.03.08 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jan 2015 08:03:12 -0800 (PST) Date: Wed, 28 Jan 2015 19:02:59 +0300 From: Ilya Verbin To: Jakub Jelinek , Thomas Schwinge Cc: Kirill Yukhin , gcc-patches@gcc.gnu.org Subject: Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing Message-ID: <20150128160259.GA12176@msticlxl57.ims.intel.com> References: <20141021171323.GA47586@msticlxl57.ims.intel.com> <20141030114001.GA34120@msticlxl57.ims.intel.com> <87tx0t0yh5.fsf@kepler.schwinge.homeip.net> <87oaqvzz0n.fsf@kepler.schwinge.homeip.net> <20141222123553.GK1667@tucnak.redhat.com> <20150115185540.GD5706@msticlxl57.ims.intel.com> <20150115185846.GJ1405@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150115185846.GJ1405@tucnak.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 15 Jan 19:58, Jakub Jelinek wrote: > On Thu, Jan 15, 2015 at 09:55:40PM +0300, Ilya Verbin wrote: > > This patch enables 'make check-target-libgomp' with noninstalled offloading > > compilers. It creates gcc/accel// directory in the build tree of the > > offloading compiler, this allows lto-wrapper to find corresponding mkoffload in > > case if there is more than one offloading compiler. Is this approach ok? > > I don't like changes in config.gcc and t-intelmic, probably there is a better > > way to create a link? > > Let's wait until Thomas hopefully checks in the OpenACC merge in order not > to make him work even harder. > I'll look at your patch afterwards. I've rebased this patch. -- Ilya diff --git a/gcc/config.gcc b/gcc/config.gcc index bf67beb..c56c055 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4371,7 +4371,7 @@ fi case ${target} in i[34567]86-*-* | x86_64-*-*) if test x$enable_as_accelerator = xyes; then - extra_programs="mkoffload\$(exeext)" + extra_programs="mkoffload\$(exeext) accel/${target_noncanonical}/mkoffload$(exeext)" fi ;; esac diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c index 5d9ed33..73ca9ce 100644 --- a/gcc/config/i386/intelmic-mkoffload.c +++ b/gcc/config/i386/intelmic-mkoffload.c @@ -45,6 +45,13 @@ const char *temp_files[MAX_NUM_TEMPS]; /* Shows if we should compile binaries for i386 instead of x86-64. */ bool target_ilp32 = false; +/* Optional prefixes for the target compiler, which are required when target + compiler is not installed. */ +char *optional_target_path1 = NULL; +char *optional_target_path2 = NULL; +char *optional_target_lib_path = NULL; + + /* Delete tempfiles and exit function. */ void tool_cleanup (bool from_signal ATTRIBUTE_UNUSED) @@ -151,14 +158,18 @@ access_check (const char *name, int mode) return access (name, mode); } -/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH. */ +/* Find target compiler using a path from COLLECT_GCC, COMPILER_PATH, or a path + relative to ARGV0. */ static char * -find_target_compiler (const char *name) +find_target_compiler (const char *argv0) { bool found = false; char **paths = NULL; unsigned n_paths, i; + const char *current_path; const char *collect_path = dirname (ASTRDUP (getenv ("COLLECT_GCC"))); + const char *name + = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc"; size_t len = strlen (collect_path) + 1 + strlen (name) + 1; char *target_compiler = XNEWVEC (char, len); sprintf (target_compiler, "%s/%s", collect_path, name); @@ -177,13 +188,38 @@ find_target_compiler (const char *name) if (access_check (target_compiler, X_OK) == 0) { found = true; - break; + goto out; } } + /* If installed compiler wasn't found, try to find a non-installed compiler, + using a path relative to mkoffload. */ + current_path = dirname (ASTRDUP (argv0)); + len = strlen (current_path) + sizeof ("/../../") - 1; + target_compiler = XRESIZEVEC (char, target_compiler, len + sizeof ("xgcc")); + sprintf (target_compiler, "%s/../../xgcc", current_path); + if (access_check (target_compiler, X_OK) == 0) + { + optional_target_path1 = XNEWVEC (char, len + sizeof ("-B")); + sprintf (optional_target_path1, "-B%s/../../", current_path); + optional_target_path2 + = XNEWVEC (char, len + sizeof ("-B" "../" DEFAULT_TARGET_MACHINE + "/libgomp/")); + sprintf (optional_target_path2, "-B%s/../../../" DEFAULT_TARGET_MACHINE + "/libgomp/", current_path); + optional_target_lib_path + = XNEWVEC (char, len + sizeof ("-L" "../" DEFAULT_TARGET_MACHINE + "/libgomp/.libs/")); + sprintf (optional_target_lib_path, "-L%s/../../../" DEFAULT_TARGET_MACHINE + "/libgomp/.libs/", current_path); + found = true; + } + out: free_array_of_ptrs ((void **) paths, n_paths); - return found ? target_compiler : NULL; + if (!found) + fatal_error ("offload compiler %s not found", name); + return target_compiler; } static void @@ -193,6 +229,14 @@ compile_for_target (struct obstack *argv_obstack) obstack_ptr_grow (argv_obstack, "-m32"); else obstack_ptr_grow (argv_obstack, "-m64"); + + if (optional_target_path1) + obstack_ptr_grow (argv_obstack, optional_target_path1); + if (optional_target_path2) + obstack_ptr_grow (argv_obstack, optional_target_path2); + if (optional_target_lib_path) + obstack_ptr_grow (argv_obstack, optional_target_lib_path); + obstack_ptr_grow (argv_obstack, NULL); char **argv = XOBFINISH (argv_obstack, char **); @@ -492,11 +536,7 @@ main (int argc, char **argv) if (!host_compiler) fatal_error ("COLLECT_GCC must be set"); - const char *target_driver_name - = DEFAULT_REAL_TARGET_MACHINE "-accel-" DEFAULT_TARGET_MACHINE "-gcc"; - char *target_compiler = find_target_compiler (target_driver_name); - if (target_compiler == NULL) - fatal_error ("offload compiler %s not found", target_driver_name); + char *target_compiler = find_target_compiler (argv[0]); /* We may be called with all the arguments stored in some file and passed with @file. Expand them into argv before processing. */ diff --git a/gcc/config/i386/t-intelmic b/gcc/config/i386/t-intelmic index 8b36e0d..efc50fca 100644 --- a/gcc/config/i386/t-intelmic +++ b/gcc/config/i386/t-intelmic @@ -7,3 +7,9 @@ mkoffload.o: $(srcdir)/config/i386/intelmic-mkoffload.c | insn-modes.h mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS) $(COMPILER) -o $@ mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS) + +accel/$(target_noncanonical)/mkoffload$(exeext): mkoffload$(exeext) + test -d accel || mkdir accel + test -d accel/$(target_noncanonical) || mkdir accel/$(target_noncanonical) + rm -f $@ + $(LN) mkoffload$(exeext) $@ diff --git a/libgomp/configure b/libgomp/configure index 0818707..8d96950 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -15226,6 +15226,9 @@ if test x"$enable_offload_targets" != x; then case $tgt in *-intelmic-* | *-intelmicemul-*) tgt_name=intelmic + if test x"$tgt_dir" != x; then + offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs" + fi ;; nvptx*) tgt_name=nvptx @@ -15276,7 +15279,7 @@ rm -f core conftest.err conftest.$ac_objext \ offload_targets=$offload_targets,$tgt_name fi if test x"$tgt_dir" != x; then - offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin" + offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin" offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32" else offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)" diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac index 254c688..2861e68 100644 --- a/libgomp/plugin/configfrag.ac +++ b/libgomp/plugin/configfrag.ac @@ -94,6 +94,9 @@ if test x"$enable_offload_targets" != x; then case $tgt in *-intelmic-* | *-intelmicemul-*) tgt_name=intelmic + if test x"$tgt_dir" != x; then + offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/$tgt/liboffloadmic/.libs" + fi ;; nvptx*) tgt_name=nvptx @@ -133,7 +136,7 @@ if test x"$enable_offload_targets" != x; then offload_targets=$offload_targets,$tgt_name fi if test x"$tgt_dir" != x; then - offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin" + offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/gcc -B$tgt_dir/bin" offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32" else offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"