Hi! On 2022-02-08T14:56:40+0100, Tom de Vries via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > On 2/8/22 14:24, Tobias Burnus wrote: >> if I understand the patch correctly, -misa=sm_53 -mptx=3.1 will ...
> $ ./gcc.sh ~/hello.c -misa=sm_53 -mptx=3.1 > cc1: error: PTX version (-mptx) needs to be at least 4.2 to support > selected -misa (sm_53) >> I think that's okay but -mptx only supports the values 3.1, 6.3, and 7.0. > > I know. I'm sort of hoping that the new default setting will make using > -mptx unnecessary. >> it only occurs when both are specified in >> the way shown above. Thus, we can live with that. (Misleading message >> for odd corner case, only. In particular, I am not sure we really want >> to add another PTX version...) > > Agreed, it's misleading, but I'm hoping people will just specify the sm > version. But there's no reason not to expose '-mptx=4.2' to the user? Going forward, we'll need more PTX ISA versions added at least for internal use (to correctly describe PTX instructions etc.), and I don't want to spend time to decide which of these to expose to the user and which not to. Therefore, let's just expose all of them. I've pushed to trunk branch commit 1af83aa09979e5f2ca36f844d56ccd629268057d "nvptx: Expose '-mptx=4.2'", see attached. Grüße Thomas
>From 1af83aa09979e5f2ca36f844d56ccd629268057d Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Sun, 10 Nov 2024 17:35:07 +0100 Subject: [PATCH] nvptx: Expose '-mptx=4.2' 'PTX_VERSION_4_2' was added in commit decde11183bdccc46587d6614b75f3d56a2f2e4a "[nvptx] Choose -mptx default based on -misa" for use for '-march=sm_52' ('first_ptx_version_supporting_sm', 'PTX_ISA_SM53'), as documented by Nvidia. However, '-mptx=4.2' wasn't exposed to the user, but there's no reason not to. gcc/ * config/nvptx/nvptx.h (TARGET_PTX_4_2): New. * config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue' '4.2' for 'PTX_VERSION_4_2'. * doc/invoke.texi (Nvidia PTX Options): Document '-mptx=4.2'. gcc/testsuite/ * gcc.target/nvptx/mptx=4.2.c: New. --- gcc/config/nvptx/nvptx.h | 1 + gcc/config/nvptx/nvptx.opt | 3 +++ gcc/doc/invoke.texi | 10 +++++++--- gcc/testsuite/gcc.target/nvptx/mptx=4.2.c | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/nvptx/mptx=4.2.c diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index 792da4901d22..d9a5e541257d 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -90,6 +90,7 @@ /* There are no 'TARGET_PTX_3_1' and smaller conditionals: our baseline is PTX ISA Version 3.1. */ +#define TARGET_PTX_4_2 (ptx_version_option >= PTX_VERSION_4_2) #define TARGET_PTX_6_0 (ptx_version_option >= PTX_VERSION_6_0) #define TARGET_PTX_6_3 (ptx_version_option >= PTX_VERSION_6_3) #define TARGET_PTX_7_0 (ptx_version_option >= PTX_VERSION_7_0) diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt index 53ddf451836e..408c88354446 100644 --- a/gcc/config/nvptx/nvptx.opt +++ b/gcc/config/nvptx/nvptx.opt @@ -127,6 +127,9 @@ Known PTX ISA versions (for use with the -mptx= option): EnumValue Enum(ptx_version) String(3.1) Value(PTX_VERSION_3_1) +EnumValue +Enum(ptx_version) String(4.2) Value(PTX_VERSION_4_2) + EnumValue Enum(ptx_version) String(6.0) Value(PTX_VERSION_6_0) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 33a1b6b7983a..a2234725e671 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -30070,9 +30070,13 @@ capable. For instance, for @option{-march-map=sm_50} select @opindex mptx @item -mptx=@var{version-string} -Generate code for the specified PTX ISA 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 ISA version is 6.0, unless a higher +Generate code for the specified PTX ISA version. +Valid version strings are +@samp{3.1}, +@samp{4.2}, +@samp{6.0}, @samp{6.3}, +and @samp{7.0}. +The default PTX ISA version is 6.0, unless a higher version is required for specified PTX ISA target architecture via option @option{-march=}. diff --git a/gcc/testsuite/gcc.target/nvptx/mptx=4.2.c b/gcc/testsuite/gcc.target/nvptx/mptx=4.2.c new file mode 100644 index 000000000000..e17ee1babf96 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/mptx=4.2.c @@ -0,0 +1,19 @@ +/* { dg-do assemble } */ +/* { dg-options {-march=sm_30 -mptx=4.2} } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { scan-assembler-times {(?n)^ \.version 4\.2$} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)^ \.target sm_30$} 1 } } */ + +#if __PTX_ISA_VERSION_MAJOR__ != 4 +#error wrong value for __PTX_ISA_VERSION_MAJOR__ +#endif + +#if __PTX_ISA_VERSION_MINOR__ != 2 +#error wrong value for __PTX_ISA_VERSION_MINOR__ +#endif + +#if __PTX_SM__ != 300 +#error wrong value for __PTX_SM__ +#endif + +int dummy; -- 2.34.1