diff mbox series

OpenMP/nvptx: support 'arch(nvptx64)' as context selector

Message ID b95b3013-925b-4eca-9715-11520dfa1292@baylibre.com
State New
Headers show
Series OpenMP/nvptx: support 'arch(nvptx64)' as context selector | expand

Commit Message

Tobias Burnus Feb. 20, 2024, 4:39 p.m. UTC
I just encountered 'arch(nvptx64)'. I think it makes sense to support
it as alias for 'nvptx' in the context selector for better compatibility.

Comments, remarks, suggestions?

Tobias

PS: See the LLVM documentation below. I do note that those are not identical
as LLVM uses 'nvptx' for 32bit while we effectively only support 64bit
(at least for offloading). Thus, while 'nvptx' might cause problems, adding
'nvptx64' in addition should be harmless.

* * *
 From LLVM's https://android.googlesource.com/toolchain/llvm/+/refs/heads/master/docs/NVPTXUsage.rst

"The NVPTX target uses the module triple to select between 32/64-bit code
generation and the driver-compiler interface to use. The triple architecture
can be one of ``nvptx`` (32-bit PTX) or ``nvptx64`` (64-bit PTX). The
operating system should be one of ``cuda`` or ``nvcl``, which determines the
interface used by the generated code to communicate with the driver.  Most
users will want to use ``cuda`` as the operating system, which makes the
generated PTX compatible with the CUDA Driver API.

Example: 32-bit PTX for CUDA Driver API: ``nvptx-nvidia-cuda``
Example: 64-bit PTX for CUDA Driver API: ``nvptx64-nvidia-cuda``"

And usage inside LLVM:

clang/lib/Headers/openmp_wrappers/complex:    device = {arch(amdgcn, nvptx, nvptx64)},                                   \

Comments

Jakub Jelinek Feb. 20, 2024, 4:50 p.m. UTC | #1
On Tue, Feb 20, 2024 at 05:39:39PM +0100, Tobias Burnus wrote:
> clang/lib/Headers/openmp_wrappers/complex:    device = {arch(amdgcn, nvptx, nvptx64)},                                   \

That one doesn't really need the nvptx64 support.
> --- a/gcc/config/nvptx/nvptx.cc
> +++ b/gcc/config/nvptx/nvptx.cc
> @@ -6403,7 +6403,7 @@ nvptx_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
>      case omp_device_kind:
>        return strcmp (name, "gpu") == 0;
>      case omp_device_arch:
> -      return strcmp (name, "nvptx") == 0;
> +      return strcmp (name, "nvptx") == 0 || strcmp (name, "nvptx64") == 0;

Maybe guard the nvptx64 on TARGET_ABI64, at least as long as we have that?
Just in case we'd reconsider at some point the -m64 only thing.

Otherwise LGTM.

	Jakub
diff mbox series

Patch

OpenMP/nvptx: support 'arch(nvptx64)' as context selector

The main 'arch' context selector for nvptx is, well, 'nvptx';
however, as 'nvptx64' is used as by LLVM, it makes sense
to support it as well.

Note that LLVM has: "The triple architecture can be one of
``nvptx`` (32-bit PTX) or ``nvptx64`` (64-bit PTX)."
GCC effectively only supports the 64bit variant (at least for
offloading). Thus, GCC's 'nvptx' is not quite the same as LLVM's.

gcc/ChangeLog:

	* config/nvptx/gen-omp-device-properties.sh: Add 'nvptx64' to arch.
	* config/nvptx/nvptx.cc (nvptx_omp_device_kind_arch_isa): Likewise.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP Context Selectors): Add 'nvptx64' as additional
	'arch' value for nvptx.

 gcc/config/nvptx/gen-omp-device-properties.sh | 2 +-
 gcc/config/nvptx/nvptx.cc                     | 2 +-
 libgomp/libgomp.texi                          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/nvptx/gen-omp-device-properties.sh b/gcc/config/nvptx/gen-omp-device-properties.sh
index 95c754a164f..3666f9746d1 100644
--- a/gcc/config/nvptx/gen-omp-device-properties.sh
+++ b/gcc/config/nvptx/gen-omp-device-properties.sh
@@ -23,7 +23,7 @@  nvptx_sm_def="$1/nvptx-sm.def"
 sms=$(grep ^NVPTX_SM $nvptx_sm_def | sed 's/.*(//;s/,.*//')
 
 echo kind: gpu
-echo arch: nvptx
+echo arch: nvptx nvptx64
 
 isa=""
 for sm in $sms; do
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 9363d3ecc6a..3b46b70fc3b 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -6403,7 +6403,7 @@  nvptx_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
     case omp_device_kind:
       return strcmp (name, "gpu") == 0;
     case omp_device_arch:
-      return strcmp (name, "nvptx") == 0;
+      return strcmp (name, "nvptx") == 0 || strcmp (name, "nvptx64") == 0;
     case omp_device_isa:
 #define NVPTX_SM(XX, SEP)				\
       {							\
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index d7da799a922..9de6e15f1c2 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -6193,7 +6193,7 @@  on more architectures, GCC currently does not match any @code{arch} or
 @item @code{amdgcn}, @code{gcn}
       @tab See @code{-march=} in ``AMD GCN Options''@footnote{Additionally,
       @code{gfx803} is supported as an alias for @code{fiji}.}
-@item @code{nvptx}
+@item @code{nvptx}, @code{nvptx64}
       @tab See @code{-march=} in ``Nvidia PTX Options''
 @end multitable