From patchwork Thu Feb 17 17:24:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1594403 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4K01tN0xTBz9s1l for ; Fri, 18 Feb 2022 04:25:14 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D45763857007 for ; Thu, 17 Feb 2022 17:25:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 4B9633857805 for ; Thu, 17 Feb 2022 17:24:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4B9633857805 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: 5vzsMzsuDN3reT09lKMXsMVqsimZ2AL61XsPMhbke7MK9B7yG7xBYR9c4IytlGoY+oxdulMwXV kSUYpPx66odnFWt0JHJIJeCAihZ6Nf/Lqwcqk00w2yf9rpn3CJ7BouDUuS1k4nrJfMGKbnQDo4 TFTtyxExp1+M37PplNL1VdjHRh7ucKhvoEmRcoQS6oEMa42mjTcFliP317vC7C0mpkxrfHtDvn hA27z+lu4/NF099Q57MeaELtWCko1xwq3aKmpvIgME47DH66al1OXgIkqLFrN+PcAXsXQS64H6 IcoZ48wwLoZaUruAVsCx31oo X-IronPort-AV: E=Sophos;i="5.88,376,1635235200"; d="diff'?scan'208";a="71971634" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 17 Feb 2022 09:24:46 -0800 IronPort-SDR: OtxMdZY/cYWtfYbs/1SpDA5kGVIUOJ5LnDbKm74UKmove8uw1FUkxZAFHwqoDUwU3+zF9w2hsU tQYFHvrZg9mNTZZ6LQTxyyvhkXmRVIJ8Z2DO78Ubwj+HouCf2BRaHvFEtvUN7kP2mz1KBy+9Q6 Jur/naDSHvHuw9PfjT+l+Wm9rSgRwAHIv+xQZ2eKC8qSpHWi6pDWdsEisM8X1KWGF90WSecq+H Hx2EyIWejBpJiERgtd+0F2psMwdpIzzBjwCz7bD2kkHc3YZYAvyA5MRkBO+fK/nVzUvgFVxjtc fN0= Message-ID: Date: Thu, 17 Feb 2022 18:24:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Content-Language: en-US To: Tom de Vries , gcc-patches From: Tobias Burnus Subject: [Patch] nvptx: Add -mptx=6.0 + -misa=sm_70 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch exposes two -m* option values which are already internally available. I think it makes sense to expose them explicitly to the user (see below), but there are also arguments against. Thoughts? PTX version (-mptx=) [patch adds -mptx=6.0 as option] * Currently supported internally are 3.1 (CUDA 5.0, used by GCC <= 11), 6.0 (CUDA 9.0, current GCC 12 default), 6.3 (CUDA 10.0), 7.0 (CUDA 11.0) * -mptx= supports 3.1, 6.3, 7.0 – but not the internal default 6.0 First, I think all versions make sense: * 3.1 is the previous default and permits running with older CUDA (if need) * 6.0 is for CUDA 9 - and if we want to support it, it has to stay. 6.0 is the default since commit https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590007.html * 6.3 is CUDA 10.0. In that PTX version, a lot of nice features were added like .alias * 7.0 is CUDA 11.0. This adds support for sm_80 (honored in code gen). PTX >= 6.0 makes sense as it permits newer sm_* (in particular: sm_53 and sm_70) and + /* Pick at least 6.0, to enable using bar.warp.sync to have a way to force + warp convergence. */ On the other hand, for older systems, CUDA 10.0 might be too new and we still want to support CUDA 9. (At least that's how I understood one of nvpx gcc emails, which I cannot find at the moment.) Assuming we don't want to change the default minimal version from PTX 6.0 back to 6.3, it looks as both should stay. Downside: we probably need one lib{c,gomp,gfortran,...} per PTX version, i.e. 4 versions (3.1, 6.0, 6.3, 7.0). I think it makes sense to expose the 6.0 value to the user and not only use it internally behind the scenes. As it is already used internally, the change is tiny but user visible. Thus, it has to stay when we will bump the default in later GCC versions; on the other hand, if we bump the default, it might be also a good reason to have it to permit the user to have a backward compatible PTX output for linking libraries. * * * SM version (-misa=) [Patch adds -misa=sm_70] * The compiler supports internally: SM_30, SM_35, SM_53, SM_70, SM_75, SM_80. * GCC <= 11 only had sm_30 and sm_35 (supported since PTX 3.1/CUDA 5.0) * GCC 12 exposes - sm_30, sm_35, - sm_53 (PTX 4.2, CUDA 7.0), - sm_75 (PTX 6.3, CUDA 10.0) - sm_80 (PTX 7.0, CUDA 11.0) but it does not permit using -misa=sm_70 (PTX 6.0, CUDA 9.0). * Note: sm_75 + sm_80 imply a newer PTX version, which the compiler defaults to (if no -mptx= has been specified). I think it makes sense to have sm_70 in addition: * sm_70 enables several new features (see PTX documentation) * sm_70 is the highest supported for CUDA 9 (default PTX version); as sm_75 will require CUDA 10, currently only sm_53 can be used with CUDA 9. * The current code actually does generate different code for >= sm_70 already. * * * This patch updates -misa= and -mptx= documentation to match what actually has been implemented. I think that makes sense as: * The currently documented default for -mptx= is no longer true. * The available values are already exposed via the diagnostic * The multilib issue already occurs when the user explicitly specifies -mptx=6.3 (or -mptx=3.1). * If needed, we could note that certain PTX or ISA values are experimental. I think besides > sm_35 being experimental, there is no reason that higher sm_* should not be used. Except for the pre-existing multilib issue and for the ICE when bootstrapping with sm_53 (instead of sm_35) as default ISA version. But that's solved by Roger's patch (pending ME (and then BE) review), https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590545.html * * * Comments to any of those three patches (-mptx=6.0, -misa=sm_70, documentation)? (Lightly tested on x86-64 with nvptx offloading.) OK? (All, some?) Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 nvptx: Add -mptx=6.0 + -misa=sm_70 gcc/ChangeLog: * config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Handle SM70. * gcc/config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Likewise. * config/nvptx/nvptx.opt (misa): Add sm_70 alias PTX_ISA_SM70. (mptx): Add 6.0 alias PTX_VERSION_6_0. * config/nvptx/t-omp-device: Add sm_53, sm_70, sm_75, sm_80. * doc/invoke.texi (-misa, -mptx): Update for new values and defaults. gcc/config/nvptx/nvptx-c.cc | 2 ++ gcc/config/nvptx/nvptx.cc | 2 ++ gcc/config/nvptx/nvptx.opt | 6 ++++++ gcc/config/nvptx/t-omp-device | 2 +- gcc/doc/invoke.texi | 17 +++++++++++------ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gcc/config/nvptx/nvptx-c.cc b/gcc/config/nvptx/nvptx-c.cc index d68b9910d7e..b2375fb5b16 100644 --- a/gcc/config/nvptx/nvptx-c.cc +++ b/gcc/config/nvptx/nvptx-c.cc @@ -43,6 +43,8 @@ nvptx_cpu_cpp_builtins (void) cpp_define (parse_in, "__PTX_SM__=800"); else if (TARGET_SM75) cpp_define (parse_in, "__PTX_SM__=750"); + else if (TARGET_SM70) + cpp_define (parse_in, "__PTX_SM__=700"); else if (TARGET_SM53) cpp_define (parse_in, "__PTX_SM__=530"); else if (TARGET_SM35) diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index afbad5bdde6..f3f3201a7ba 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -217,6 +217,8 @@ first_ptx_version_supporting_sm (enum ptx_isa sm) return PTX_VERSION_3_1; case PTX_ISA_SM53: return PTX_VERSION_4_2; + case PTX_ISA_SM70: + return PTX_VERSION_6_0; case PTX_ISA_SM75: return PTX_VERSION_6_3; case PTX_ISA_SM80: diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt index e3f65b2d0b1..c00af111829 100644 --- a/gcc/config/nvptx/nvptx.opt +++ b/gcc/config/nvptx/nvptx.opt @@ -64,6 +64,9 @@ Enum(ptx_isa) String(sm_35) Value(PTX_ISA_SM35) EnumValue Enum(ptx_isa) String(sm_53) Value(PTX_ISA_SM53) +EnumValue +Enum(ptx_isa) String(sm_70) Value(PTX_ISA_SM70) + EnumValue Enum(ptx_isa) String(sm_75) Value(PTX_ISA_SM75) @@ -82,6 +85,9 @@ Known PTX versions (for use with the -mptx= option): EnumValue Enum(ptx_version) String(3.1) Value(PTX_VERSION_3_1) +EnumValue +Enum(ptx_version) String(6.0) Value(PTX_VERSION_6_0) + EnumValue Enum(ptx_version) String(6.3) Value(PTX_VERSION_6_3) diff --git a/gcc/config/nvptx/t-omp-device b/gcc/config/nvptx/t-omp-device index 8765d9f1881..4228218a424 100644 --- a/gcc/config/nvptx/t-omp-device +++ b/gcc/config/nvptx/t-omp-device @@ -1,4 +1,4 @@ omp-device-properties-nvptx: $(srcdir)/config/nvptx/nvptx.cc echo kind: gpu > $@ echo arch: nvptx >> $@ - echo isa: sm_30 sm_35 >> $@ + echo isa: sm_30 sm_35 sm_53 sm_70 sm_75 sm_80 >> $@ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e1a00c80307..54ca0070356 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -27250,15 +27250,20 @@ supported. @item -misa=@var{ISA-string} @opindex march -Generate code for given the specified PTX ISA (e.g.@: @samp{sm_35}). ISA -strings must be lower-case. Valid ISA strings include @samp{sm_30} and -@samp{sm_35}. The default ISA is sm_35. +Generate code for given the specified PTX ISA (e.g.@: @samp{sm_70}). ISA +strings must be lower-case. Valid ISA strings include @samp{sm_30}, +@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75}, and @samp{sm_80}. +The default ISA is sm_35. @item -mptx=@var{version-string} @opindex mptx -Generate code for given the specified PTX version (e.g.@: @samp{6.3}). -Valid version strings include @samp{3.1} and @samp{6.3}. The default PTX -version is 3.1. +Generate code for given the specified PTX version (e.g.@: @samp{7.0}). +Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and +@samp{7.0}. The default PTX version is 6.0, unless a higher minimal +version is required for specified PTX ISA via option @option{-misa=}. + +the lowest supported +PTX version supporting @item -mmainkernel @opindex mmainkernel