]> git.ipfire.org Git - thirdparty/gcc.git/commit
nvptx: Add (experimental) support for HFmode with -misa=sm_53
authorRoger Sayle <roger@nextmovesoftware.com>
Thu, 9 Dec 2021 09:45:28 +0000 (10:45 +0100)
committerTom de Vries <tdevries@suse.de>
Sun, 12 Dec 2021 12:18:49 +0000 (13:18 +0100)
commitaeedb00a1ae2ccd10b1a5f00ff466081aeadb54b
tree3adcc90ef8d5524379a70158123fbfe863203ee5
parente93809f62363ba4b233858005aef652fb550e896
nvptx: Add (experimental) support for HFmode with -misa=sm_53

The recent flurry of activity around HFmode on gcc-patches intrigued me
to investigate adding HFmode support to the nvptx backend.  NVidia GPUs
with an SM ISA above 5.3 support IEEE 16-bit floating point instructions.
Hence, this patch adds support for -misa=sm_53, and implements some
backend patterns/insns sufficient for a proof-of-concept prototype.

The following has been tested on nvptx-none, hosted on x86_64-pc-linux-gnu
with a "make" and "make -k check" with no new failures.

gcc/ChangeLog:

* config/nvptx/nvptx-opts.h (ptx_isa): Add PTX_ISA_SM53 ISA level
to enumeration.
* config/nvptx/nvptx.opt: Add sm_53 to -misa.
* config/nvptx/nvptx-modes.def: Add support for HFmode.
* config/nvptx/nvptx.h (TARGET_SM53):
New helper macro to conditionalize functionality on target ISA.
* config/nvptx/nvptx-c.c (nvptx_cpu_cpp_builtins): Add __PTX_SM__
support for the new ISA levels.
* config/nvptx/nvptx.c (nvtx_ptx_type_from_mode): Support new HFmode
with the ".f16" suffix/qualifier.
(nvptx_file_start): Add support for TARGET_SM53.
(nvptx_omp_device_kind_arch_isa): Add support for TARGET_SM53
and tweak TARGET_SM35.
(nvptx_scalar_mode_supported_p): Target hook with conditional
HFmode support on TARGET_SM53 and higher.
(nvptx_libgcc_floating_mode_supported_p): Likewise.
(TARGET_SCALAR_MODE_SUPPORTED_P): Use nvptx_scalar_mode_supported_p.
(TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Likewise, use new hook.
* config/nvptx/nvptx.md (*movhf_insn): New define_insn.
(movhf): New define_expand for HFmode moves.
(addhf3, subhf3, mulhf, extendhf<mode>2, trunc<mode>hf2): New
instructions conditional on TARGET_SM53 (i.e. -misa=sm_53).

gcc/testsuite/ChangeLog:

* gcc.target/nvptx/float16-1.c: New test case.
gcc/config/nvptx/nvptx-c.c
gcc/config/nvptx/nvptx-modes.def
gcc/config/nvptx/nvptx-opts.h
gcc/config/nvptx/nvptx.c
gcc/config/nvptx/nvptx.h
gcc/config/nvptx/nvptx.md
gcc/config/nvptx/nvptx.opt
gcc/testsuite/gcc.target/nvptx/float16-1.c [new file with mode: 0644]