From patchwork Thu Jan 14 18:18:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1426604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DGsyB2b1xz9sVm for ; Fri, 15 Jan 2021 05:18:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51AA238708CC; Thu, 14 Jan 2021 18:18:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 746403857C6F for ; Thu, 14 Jan 2021 18:18:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 746403857C6F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Thomas_Schwinge@mentor.com IronPort-SDR: tDdQ7s2NY7jOM74o3bQJJanN96k2kRvnSmCbOjlXYhDsWVkRpkLX6zvmVgHwcnALKapFcPzghw +cMBXRl83eAI0wi3Rk6uotjatx8CZaWPtuXlD0oArVCOV/FVFC0icw8KdPKI5cEsjN4mrGbG50 +FjqNiOru0KB5m+eVtCWRkXj88fy6FngwAytnwqVWdSW7s7KtNl2PnSYln7LF0JVq8Vrum5krz l35WJzXNjiJkhYX2cU1PEjNUq4El0GAKfI1DhJ1EdR75nLmWy4wtRuw3jZh90lEpugYdSYxrzn yu0= X-IronPort-AV: E=Sophos;i="5.79,347,1602576000"; d="scan'208,223";a="57071421" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 14 Jan 2021 10:18:32 -0800 IronPort-SDR: WZNG7mMAiU/VJAYaV/oxDA/gvkl/mKBkJO/IFY2XdkUbizeaQ7a4s3l4WdGWw5iL4oVPOny0xp zKqTv8LRUo0T646+dRVxTGscZQeImoAgss1d197Hz/Cl5piAQ+t3d9uAh8z48uii8ppMxnVnm1 D1yJ686XFgQR/6C8JfuVmQO3Uhfj42Mpo8Hz8X9bvlCHNdH5nw4/NrXk+Sco1HRyfsL9WH8Whw LXmVbI9fzq0hf0CW/Rg0AOG8+eU/Drcd5pAq1c5UaVBOmicpa9+E/nCS5tGFKmeQTrvxYn6D4p y74= From: Thomas Schwinge To: Subject: [nvptx libgomp plugin] Build only in supported configurations (was: [nvptx offloading] Only 64-bit configurations are currently supported) In-Reply-To: <87zj364rq1.fsf@kepler.schwinge.homeip.net> References: <54451994.9070209@codesourcery.com> <54451D57.5050803@codesourcery.com> <5447F0E1.7080906@redhat.com> <544FAE8B.5010906@codesourcery.com> <545179C6.4030406@redhat.com> <5460E5AD.6060502@codesourcery.com> <87vbl2w69s.fsf@kepler.schwinge.homeip.net> <87egq8mir1.fsf@schwinge.name> <20150204094314.GH1746@tucnak.redhat.com> <8761azfvso.fsf@kepler.schwinge.homeip.net> <87zj364rq1.fsf@kepler.schwinge.homeip.net> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Thu, 14 Jan 2021 19:18:13 +0100 Message-ID: <87lfcvidqy.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2015-07-08T17:03:02+0200, I wrote: > On Wed, 18 Feb 2015 09:50:15 +0100, I wrote: >> So far, we have concentrated only on the 64-bit x86_64 configuration; >> 32-bit has several known issues to be resolved. >> filed. (This still holds, and is unlikely to ever get addressed.) > I have committed the following patch in r225560. This gets us rid of the > lots of "expected FAILs" in the 32-bit part of > RUNTESTFLAGS='--target_board=unix\{-m64,-m32\}' testing, for example. > > commit fe265ad3c9624da88f43be349137696449148f4f > Author: tschwinge > Date: Wed Jul 8 14:59:59 2015 +0000 > > [nvptx offloading] Only 64-bit configurations are currently supported > > PR libgomp/65099 > gcc/ > * config/nvptx/mkoffload.c (main): Create an offload image only in > 64-bit configurations. (That remains in place.) > libgomp/ > * plugin/plugin-nvptx.c (nvptx_get_num_devices): Return 0 if not > in a 64-bit configuration. That, for reasons given in the commit log, I've just refined, pushed "[nvptx libgomp plugin] Build only in supported configurations" to master branch in commit 6106dfb9f73a33c87108ad5b2dcd4842bdd7828e, and cherry-picked into releases/gcc-10 branch in commit 1e56a7c9a6631b217299b2ddcd5c4d497bb3445e, releases/gcc-9 branch in commit 0f1e1069a753e912b058f0d4bf599f0edde28408, releases/gcc-8 branch in commit f9267925c648f2ccd9e4680b699e581003125bcf, see attached. Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter From f9267925c648f2ccd9e4680b699e581003125bcf Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 30 Nov 2020 15:15:20 +0100 Subject: [PATCH] [nvptx libgomp plugin] Build only in supported configurations As recently again discussed in "[nvptx] -m32 support", nvptx offloading other than for 64-bit host has never been implemented, tested, supported. So we simply should buildn't the nvptx libgomp plugin in this case. This avoids build problems if, for example, in a (standard) bi-arch x86_64-pc-linux-gnu '-m64'/'-m32' build, libcuda is available only in a 64-bit variant but not in a 32-bit one, which, for example, is the case if you build GCC against the CUDA toolkit's 'stubs/libcuda.so' (see ). This amends PR65099 commit a92defdab79a1268f4b9dcf42b937e4002a4cf15 (r225560) "[nvptx offloading] Only 64-bit configurations are currently supported" to match the way we're doing this for the HSA/GCN plugins. libgomp/ PR libgomp/65099 * plugin/configfrag.ac (PLUGIN_NVPTX): Restrict to supported configurations. * configure: Regenerate. * plugin/plugin-nvptx.c (nvptx_get_num_devices): Remove 64-bit check. (cherry picked from commit 6106dfb9f73a33c87108ad5b2dcd4842bdd7828e) --- libgomp/configure | 75 +++++++++++++++++++------------- libgomp/plugin/configfrag.ac | 81 +++++++++++++++++++++-------------- libgomp/plugin/plugin-nvptx.c | 9 ---- 3 files changed, 95 insertions(+), 70 deletions(-) diff --git a/libgomp/configure b/libgomp/configure index ced7606b355..2529a8e0603 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -15398,19 +15398,28 @@ if test x"$enable_offload_targets" != x; then tgt_name=intelmic ;; nvptx*) - tgt_name=nvptx - PLUGIN_NVPTX=$tgt - PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS - PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS - PLUGIN_NVPTX_LIBS='-lcuda' - - PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS" - PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS - LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS" - PLUGIN_NVPTX_save_LIBS=$LIBS - LIBS="$PLUGIN_NVPTX_LIBS $LIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + case "${target}" in + aarch64*-*-* | powerpc64le-*-* | x86_64-*-*) + case " ${CC} ${CFLAGS} " in + *" -m32 "* | *" -mx32 "*) + # PR libgomp/65099: Currently, we only support offloading in + # 64-bit configurations. + PLUGIN_NVPTX=0 + ;; + *) + tgt_name=nvptx + PLUGIN_NVPTX=$tgt + PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS + PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS + PLUGIN_NVPTX_LIBS='-lcuda' + + PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS" + PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS + LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS" + PLUGIN_NVPTX_save_LIBS=$LIBS + LIBS="$PLUGIN_NVPTX_LIBS $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "cuda.h" int @@ -15426,22 +15435,30 @@ if ac_fn_c_try_link "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS - LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS - LIBS=$PLUGIN_NVPTX_save_LIBS - case $PLUGIN_NVPTX in - nvptx*) - if test "x$CUDA_DRIVER_INCLUDE" = x \ - && test "x$CUDA_DRIVER_LIB" = x; then - PLUGIN_NVPTX=1 - PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' - PLUGIN_NVPTX_LIBS='-ldl' - PLUGIN_NVPTX_DYNAMIC=1 - else - PLUGIN_NVPTX=0 - as_fn_error "CUDA driver package required for nvptx support" "$LINENO" 5 - fi - ;; + CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS + LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS + LIBS=$PLUGIN_NVPTX_save_LIBS + case $PLUGIN_NVPTX in + nvptx*) + if test "x$CUDA_DRIVER_INCLUDE" = x \ + && test "x$CUDA_DRIVER_LIB" = x; then + PLUGIN_NVPTX=1 + PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' + PLUGIN_NVPTX_LIBS='-ldl' + PLUGIN_NVPTX_DYNAMIC=1 + else + PLUGIN_NVPTX=0 + as_fn_error "CUDA driver package required for nvptx support" "$LINENO" 5 + fi + ;; + esac + ;; + esac + ;; + *-*-*) + # Target architecture not supported. + PLUGIN_NVPTX=0 + ;; esac ;; hsa*) diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac index 864817d44d1..d3470f82f8c 100644 --- a/libgomp/plugin/configfrag.ac +++ b/libgomp/plugin/configfrag.ac @@ -148,39 +148,56 @@ if test x"$enable_offload_targets" != x; then tgt_name=intelmic ;; nvptx*) - tgt_name=nvptx - PLUGIN_NVPTX=$tgt - PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS - PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS - PLUGIN_NVPTX_LIBS='-lcuda' + case "${target}" in + aarch64*-*-* | powerpc64le-*-* | x86_64-*-*) + case " ${CC} ${CFLAGS} " in + *" -m32 "* | *" -mx32 "*) + # PR libgomp/65099: Currently, we only support offloading in + # 64-bit configurations. + PLUGIN_NVPTX=0 + ;; + *) + tgt_name=nvptx + PLUGIN_NVPTX=$tgt + PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS + PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS + PLUGIN_NVPTX_LIBS='-lcuda' - PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS" - PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS - LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS" - PLUGIN_NVPTX_save_LIBS=$LIBS - LIBS="$PLUGIN_NVPTX_LIBS $LIBS" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [#include "cuda.h"], - [CUresult r = cuCtxPushCurrent (NULL);])], - [PLUGIN_NVPTX=1]) - CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS - LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS - LIBS=$PLUGIN_NVPTX_save_LIBS - case $PLUGIN_NVPTX in - nvptx*) - if test "x$CUDA_DRIVER_INCLUDE" = x \ - && test "x$CUDA_DRIVER_LIB" = x; then - PLUGIN_NVPTX=1 - PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' - PLUGIN_NVPTX_LIBS='-ldl' - PLUGIN_NVPTX_DYNAMIC=1 - else - PLUGIN_NVPTX=0 - AC_MSG_ERROR([CUDA driver package required for nvptx support]) - fi - ;; + PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS" + PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS + LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS" + PLUGIN_NVPTX_save_LIBS=$LIBS + LIBS="$PLUGIN_NVPTX_LIBS $LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include "cuda.h"], + [CUresult r = cuCtxPushCurrent (NULL);])], + [PLUGIN_NVPTX=1]) + CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS + LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS + LIBS=$PLUGIN_NVPTX_save_LIBS + case $PLUGIN_NVPTX in + nvptx*) + if test "x$CUDA_DRIVER_INCLUDE" = x \ + && test "x$CUDA_DRIVER_LIB" = x; then + PLUGIN_NVPTX=1 + PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' + PLUGIN_NVPTX_LIBS='-ldl' + PLUGIN_NVPTX_DYNAMIC=1 + else + PLUGIN_NVPTX=0 + AC_MSG_ERROR([CUDA driver package required for nvptx support]) + fi + ;; + esac + ;; + esac + ;; + *-*-*) + # Target architecture not supported. + PLUGIN_NVPTX=0 + ;; esac ;; hsa*) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 9ae60953a9a..0a4f4f410bb 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -835,15 +835,6 @@ nvptx_get_num_devices (void) { int n; - /* PR libgomp/65099: Currently, we only support offloading in 64-bit - configurations. */ - if (sizeof (void *) != 8) - { - GOMP_PLUGIN_debug (0, "Disabling nvptx offloading;" - " only 64-bit configurations are supported\n"); - return 0; - } - /* This function will be called before the plugin has been initialized in order to enumerate available devices, but CUDA API routines can't be used until cuInit has been called. Just call it now (but don't yet do any -- 2.17.1