public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] [nvptx] Add -mptx=3.1/6.3
Date: Fri, 14 May 2021 08:51:14 +0000 (GMT)	[thread overview]
Message-ID: <20210514085114.92B26385E447@sourceware.org> (raw)

https://gcc.gnu.org/g:5f654d3d12446c50cd6db54b75ea8966b57651bf

commit 5f654d3d12446c50cd6db54b75ea8966b57651bf
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri May 14 10:11:50 2021 +0200

    [nvptx] Add -mptx=3.1/6.3
    
    Add nvptx option -mptx that sets the ptx ISA version.  This is currently
    hardcoded to 3.1.
    
    Tested libgomp on x86_64-linux with nvptx accelerator, both with default set to
    3.1 and 6.3.
    
    gcc/ChangeLog:
    
    2021-05-12  Tom de Vries  <tdevries@suse.de>
    
            PR target/96005
            * config/nvptx/nvptx-opts.h (enum ptx_version): New enum.
            * config/nvptx/nvptx.c (nvptx_file_start): Print .version according
            to ptx_version_option.
            * config/nvptx/nvptx.h (TARGET_PTX_6_3): Define.
            * config/nvptx/nvptx.md (define_insn "nvptx_shuffle<mode>")
            (define_insn "nvptx_vote_ballot"): Use sync variant for
            TARGET_PTX_6_3.
            * config/nvptx/nvptx.opt (ptx_version): Add enum.
            (mptx): Add option.
            * doc/invoke.texi (Nvidia PTX Options): Add mptx item.
    
    (cherry picked from commit 2a1586401a21dcd43e0f904bb6eec26c8b2f366b)

Diff:
---
 gcc/config/nvptx/nvptx-opts.h |  6 ++++++
 gcc/config/nvptx/nvptx.c      |  5 ++++-
 gcc/config/nvptx/nvptx.h      |  2 ++
 gcc/config/nvptx/nvptx.md     | 14 ++++++++++++--
 gcc/config/nvptx/nvptx.opt    | 14 ++++++++++++++
 gcc/doc/invoke.texi           |  6 ++++++
 6 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/gcc/config/nvptx/nvptx-opts.h b/gcc/config/nvptx/nvptx-opts.h
index ce88245955b..bfa926ef0f7 100644
--- a/gcc/config/nvptx/nvptx-opts.h
+++ b/gcc/config/nvptx/nvptx-opts.h
@@ -26,5 +26,11 @@ enum ptx_isa
   PTX_ISA_SM35
 };
 
+enum ptx_version
+{
+  PTX_VERSION_3_1,
+  PTX_VERSION_6_3
+};
+
 #endif
 
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 1bf37f2ed82..837e55503a0 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -4756,7 +4756,10 @@ static void
 nvptx_file_start (void)
 {
   fputs ("// BEGIN PREAMBLE\n", asm_out_file);
-  fputs ("\t.version\t3.1\n", asm_out_file);
+  if (TARGET_PTX_6_3)
+    fputs ("\t.version\t6.3\n", asm_out_file);
+  else
+    fputs ("\t.version\t3.1\n", asm_out_file);
   if (TARGET_SM35)
     fputs ("\t.target\tsm_35\n", asm_out_file);
   else
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index 2451703e77f..fdaacdd72d8 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -98,6 +98,8 @@
 
 #define TARGET_SM35 (ptx_isa_option >= PTX_ISA_SM35)
 
+#define TARGET_PTX_6_3 (ptx_version_option >= PTX_VERSION_6_3)
+
 /* Registers.  Since ptx is a virtual target, we just define a few
    hard registers for special purposes and leave pseudos unallocated.
    We have to have some available hard registers, to keep gcc setup
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index d63977efba3..bb203d8c80c 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -1459,14 +1459,24 @@
 		 (match_operand:SI 3 "const_int_operand" "n")]
 		  UNSPEC_SHUFFLE))]
   ""
-  "%.\\tshfl%S3.b32\\t%0, %1, %2, 31;")
+  {
+    if (TARGET_PTX_6_3)
+      return "%.\\tshfl.sync%S3.b32\\t%0, %1, %2, 31, 0xffffffff;";
+    else
+      return "%.\\tshfl%S3.b32\\t%0, %1, %2, 31;";
+  })
 
 (define_insn "nvptx_vote_ballot"
   [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
 	(unspec:SI [(match_operand:BI 1 "nvptx_register_operand" "R")]
 		   UNSPEC_VOTE_BALLOT))]
   ""
-  "%.\\tvote.ballot.b32\\t%0, %1;")
+  {
+    if (TARGET_PTX_6_3)
+      return "%.\\tvote.sync.ballot.b32\\t%0, %1, 0xffffffff;";
+    else
+      return "%.\\tvote.ballot.b32\\t%0, %1;";
+  })
 
 ;; Patterns for OpenMP SIMD-via-SIMT lowering
 
diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt
index 51363e4e276..468c6cafd57 100644
--- a/gcc/config/nvptx/nvptx.opt
+++ b/gcc/config/nvptx/nvptx.opt
@@ -65,3 +65,17 @@ Enum(ptx_isa) String(sm_35) Value(PTX_ISA_SM35)
 misa=
 Target RejectNegative ToLower Joined Enum(ptx_isa) Var(ptx_isa_option) Init(PTX_ISA_SM35)
 Specify the version of the ptx ISA to use.
+
+Enum
+Name(ptx_version) Type(int)
+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.3) Value(PTX_VERSION_6_3)
+
+mptx=
+Target RejectNegative ToLower Joined Enum(ptx_version) Var(ptx_version_option) Init(PTX_VERSION_3_1)
+Specify the version of the ptx version to use.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 0a1462bc4e0..982738855b8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -26322,6 +26322,12 @@ 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.
 
+@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.
+
 @item -mmainkernel
 @opindex mmainkernel
 Link in code for a __main kernel.  This is for stand-alone instead of


                 reply	other threads:[~2021-05-14  8:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514085114.92B26385E447@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).