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)
PTX_ISA_SM35
};
+enum ptx_version
+{
+ PTX_VERSION_3_1,
+ PTX_VERSION_6_3
+};
+
#endif
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
#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
(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
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.
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