From patchwork Wed Sep 23 15:06:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 521728 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 3A34D14012C for ; Thu, 24 Sep 2015 01:06:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Syi4TWhw; 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=uzGbn5MNmitqRYA1 pozItul8l30p8y9EfMvzBZaJPbwgTlyq4IUNb53XFihWnSKEpMzvYSBWwdyV6bBX gzkOzwz7j510VAiuLKu+aEhycEhqYaQKmQj6LtcvemxdRybI0f5ASwk8o3rpxqCQ xF+TuBQkv3BQbH2HI5xqK3u2fbY= 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=3NFWDwT8wFsBti3odo4uBf LtXmo=; b=Syi4TWhwVFcapA3tD8knKwG+mIpPpTkm1PeQq0wJYquecbivRY+gJo X7pT8lmLMdfqM7cKEzZ7TV3Uv0S9i9ZkRzXLdBpXyS5DU+e5yJhjjh3x4/QkX6OM tTFPaXQj6cbhDMeKcFvXFB9UPtV3qq1oZzBFqHwyl8/RYZk0nveGM= Received: (qmail 7191 invoked by alias); 23 Sep 2015 15:06:34 -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 7181 invoked by uid 89); 23 Sep 2015 15:06:33 -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, 23 Sep 2015 15:06:31 +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 1Zelcp-00050B-4P from Thomas_Schwinge@mentor.com ; Wed, 23 Sep 2015 08:06:27 -0700 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.224.2; Wed, 23 Sep 2015 16:06:25 +0100 From: Thomas Schwinge To: Bernd Schmidt , Ilya Verbin , Jakub Jelinek , CC: Richard Biener , Kirill Yukhin , Andrey Turetskiy , Joseph Myers Subject: Re: [PATCH 6/n] OpenMP 4.0 offloading infrastructure: option handling In-Reply-To: <5601D4F6.9010208@redhat.com> References: <20141011144900.GA16368@msticlxl57.ims.intel.com> <87y4fzztub.fsf@kepler.schwinge.homeip.net> <87vbb2fyri.fsf@schwinge.name> <5601D4F6.9010208@redhat.com> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Wed, 23 Sep 2015 17:06:14 +0200 Message-ID: <87fv25xjix.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! I clarified the -foffload usage: . On Wed, 23 Sep 2015 00:23:50 +0200, Bernd Schmidt wrote: > On 09/22/2015 02:02 PM, Thomas Schwinge wrote: > > > > gcc/ > > * gcc.c (handle_foffload_option): Don't lose the trailing NUL > > character when appending to offload_targets. > > > > gcc/ > > * configure.ac (offload_targets, OFFLOAD_TARGETS): Separate > > offload targets by commas, not colons. > > * config.in: Regenerate. > > * configure: Likewise. > > * gcc.c (driver::maybe_putenv_COLLECT_LTO_WRAPPER): Due to that, > > instead of setting up the default offload targets here... > > (process_command): ..., do it here. > > libgomp/ > > * plugin/configfrag.ac (OFFLOAD_TARGETS): Clarify that offload > > targets are separated by commas. > > * config.h.in: Regenerate. > > Looks ok to me Thanks for the prompt review! > except this double ChangeLog seems messed up. Hmm, I thought that was the standard way to format ChangeLogs for several/independent changes? Anyway, to avoid that, I've split the patch into two separate commits; r228053 and r228054: commit daa8f58fd840e8d35f362306fb54e1963f4cbd0f Author: tschwinge Date: Wed Sep 23 14:52:50 2015 +0000 Fix --enable-offload-targets/-foffload handling, pt. 1 gcc/ * configure.ac (offload_targets, OFFLOAD_TARGETS): Separate offload targets by commas, not colons. * config.in: Regenerate. * configure: Likewise. * gcc.c (driver::maybe_putenv_COLLECT_LTO_WRAPPER): Due to that, instead of setting up the default offload targets here... (process_command): ..., do it here. libgomp/ * plugin/configfrag.ac (OFFLOAD_TARGETS): Clarify that offload targets are separated by commas. * config.h.in: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228053 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/config.in | 2 +- gcc/configure | 2 +- gcc/configure.ac | 4 ++-- gcc/gcc.c | 23 +++++++++++++---------- gcc/lto-wrapper.c | 4 ++++ libgomp/config.h.in | 2 +- libgomp/plugin/configfrag.ac | 2 +- 8 files changed, 37 insertions(+), 16 deletions(-) Grüße, Thomas diff --git gcc/ChangeLog gcc/ChangeLog index 0e9b728..df71558 100644 --- gcc/ChangeLog +++ gcc/ChangeLog @@ -1,4 +1,18 @@ 2015-09-23 Thomas Schwinge + + * configure.ac (offload_targets, OFFLOAD_TARGETS): Separate + offload targets by commas, not colons. + * config.in: Regenerate. + * configure: Likewise. + * gcc.c (driver::maybe_putenv_COLLECT_LTO_WRAPPER): Due to that, + instead of setting up the default offload targets here... + (process_command): ..., do it here. + libgomp/ + * plugin/configfrag.ac (OFFLOAD_TARGETS): Clarify that offload + targets are separated by commas. + * config.h.in: Regenerate. + +2015-09-23 Thomas Schwinge Nathan Sidwell * omp-low.h (omp_reduction_init_op): Declare. diff --git gcc/config.in gcc/config.in index 431d262..c5c1be4 100644 --- gcc/config.in +++ gcc/config.in @@ -1913,7 +1913,7 @@ #endif -/* Define to hold the list of target names suitable for offloading. */ +/* Define to offload targets, separated by commas. */ #ifndef USED_FOR_TARGET #undef OFFLOAD_TARGETS #endif diff --git gcc/configure gcc/configure index 6fb11a7..7493c80 100755 --- gcc/configure +++ gcc/configure @@ -7696,7 +7696,7 @@ for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do if test x"$offload_targets" = x; then offload_targets=$tgt else - offload_targets="$offload_targets:$tgt" + offload_targets="$offload_targets,$tgt" fi done diff --git gcc/configure.ac gcc/configure.ac index a6e078a..9d1f6f1 100644 --- gcc/configure.ac +++ gcc/configure.ac @@ -941,11 +941,11 @@ for tgt in `echo $enable_offload_targets | sed 's/,/ /g'`; do if test x"$offload_targets" = x; then offload_targets=$tgt else - offload_targets="$offload_targets:$tgt" + offload_targets="$offload_targets,$tgt" fi done AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets", - [Define to hold the list of target names suitable for offloading.]) + [Define to offload targets, separated by commas.]) if test x"$offload_targets" != x; then AC_DEFINE(ENABLE_OFFLOADING, 1, [Define this to enable support for offloading.]) diff --git gcc/gcc.c gcc/gcc.c index 757bfc9..78b68e2 100644 --- gcc/gcc.c +++ gcc/gcc.c @@ -284,7 +284,8 @@ static const char *const spec_version = DEFAULT_TARGET_VERSION; static const char *spec_machine = DEFAULT_TARGET_MACHINE; static const char *spec_host_machine = DEFAULT_REAL_TARGET_MACHINE; -/* List of offload targets. */ +/* List of offload targets. Separated by colon. Empty string for + -foffload=disable. */ static char *offload_targets = NULL; @@ -4376,6 +4377,13 @@ process_command (unsigned int decoded_options_count, CL_DRIVER, &handlers, global_dc); } +#ifdef ENABLE_OFFLOADING + /* If the user didn't specify any, default to all configured offload + targets. */ + if (offload_targets == NULL) + handle_foffload_option (OFFLOAD_TARGETS); +#endif + if (output_file && strcmp (output_file, "-") != 0 && strcmp (output_file, HOST_BIT_BUCKET) != 0) @@ -7572,22 +7580,17 @@ driver::maybe_putenv_COLLECT_LTO_WRAPPER () const void driver::maybe_putenv_OFFLOAD_TARGETS () const { - const char *targets = offload_targets; - - /* If no targets specified by -foffload, use all available targets. */ - if (!targets) - targets = OFFLOAD_TARGETS; - - if (strlen (targets) > 0) + if (offload_targets && offload_targets[0] != '\0') { obstack_grow (&collect_obstack, "OFFLOAD_TARGET_NAMES=", sizeof ("OFFLOAD_TARGET_NAMES=") - 1); - obstack_grow (&collect_obstack, targets, - strlen (targets) + 1); + obstack_grow (&collect_obstack, offload_targets, + strlen (offload_targets) + 1); xputenv (XOBFINISH (&collect_obstack, char *)); } free (offload_targets); + offload_targets = NULL; } /* Reject switches that no pass was interested in. */ diff --git gcc/lto-wrapper.c gcc/lto-wrapper.c index 150d368..e13a82a 100644 --- gcc/lto-wrapper.c +++ gcc/lto-wrapper.c @@ -594,6 +594,8 @@ append_offload_options (obstack *argv_obstack, const char *target, else { opts = strchr (option->arg, '='); + /* If there are offload targets specified, but no actual options, + there is nothing to do here. */ if (!opts) continue; @@ -606,10 +608,12 @@ append_offload_options (obstack *argv_obstack, const char *target, next = opts; next = (next > opts) ? opts : next; + /* Are we looking for this offload target? */ if (strlen (target) == (size_t) (next - cur) && strncmp (target, cur, next - cur) == 0) break; + /* Skip the comma or equal sign. */ cur = next + 1; } diff --git libgomp/config.h.in libgomp/config.h.in index 8533f03..2e4c698 100644 --- libgomp/config.h.in +++ libgomp/config.h.in @@ -95,7 +95,7 @@ */ #undef LT_OBJDIR -/* Define to hold the list of target names suitable for offloading. */ +/* Define to offload targets, separated by commas. */ #undef OFFLOAD_TARGETS /* Name of package */ diff --git libgomp/plugin/configfrag.ac libgomp/plugin/configfrag.ac index 8c2a420..ad70dd1 100644 --- libgomp/plugin/configfrag.ac +++ libgomp/plugin/configfrag.ac @@ -141,7 +141,7 @@ if test x"$enable_offload_targets" != x; then done fi AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets", - [Define to hold the list of target names suitable for offloading.]) + [Define to offload targets, separated by commas.]) AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1]) AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX], [Define to 1 if the NVIDIA plugin is built, 0 if not.]) commit 3bf38a0b1ae8b2e8c382fa126c15ea815ac29b06 Author: tschwinge Date: Wed Sep 23 14:52:57 2015 +0000 Fix --enable-offload-targets/-foffload handling, pt. 2 gcc/ * gcc.c (handle_foffload_option): Don't lose the trailing NUL character when appending to offload_targets. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228054 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 3 +++ gcc/gcc.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git gcc/ChangeLog gcc/ChangeLog index df71558..ca89477 100644 --- gcc/ChangeLog +++ gcc/ChangeLog @@ -1,5 +1,8 @@ 2015-09-23 Thomas Schwinge + * gcc.c (handle_foffload_option): Don't lose the trailing NUL + character when appending to offload_targets. + * configure.ac (offload_targets, OFFLOAD_TARGETS): Separate offload targets by commas, not colons. * config.in: Regenerate. diff --git gcc/gcc.c gcc/gcc.c index 78b68e2..ef132d6 100644 --- gcc/gcc.c +++ gcc/gcc.c @@ -3657,10 +3657,9 @@ handle_foffload_option (const char *arg) size_t offload_targets_len = strlen (offload_targets); offload_targets = XRESIZEVEC (char, offload_targets, - offload_targets_len + next - cur + 2); - if (offload_targets_len) - offload_targets[offload_targets_len++] = ':'; - memcpy (offload_targets + offload_targets_len, target, next - cur); + offload_targets_len + 1 + next - cur + 1); + offload_targets[offload_targets_len++] = ':'; + memcpy (offload_targets + offload_targets_len, target, next - cur + 1); } }