public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tobias Burnus <tobias@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: Re: [Patch] nvptx: Add -mptx=6.0 + -misa=sm_70
Date: Thu, 24 Feb 2022 09:29:17 +0100	[thread overview]
Message-ID: <71e9c008-7ad1-c24f-76eb-6a03180525c4@suse.de> (raw)
In-Reply-To: <221e5215-3b8b-fa9f-4e7b-2faa86b8b991@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]

On 2/22/22 17:03, Tobias Burnus wrote:
> Hi Tom,
> 
> On 22.02.22 15:43, Tom de Vries wrote:
>> On 2/17/22 18:24, Tobias Burnus wrote:
>>> --- a/gcc/config/nvptx/t-omp-device
>>> +++ b/gcc/config/nvptx/t-omp-device
>>> @@ -1,4 +1,4 @@
>>>      echo kind: gpu > $@
>>>      echo arch: nvptx >> $@
>>> -    echo isa: sm_30 sm_35 >> $@
>>> +    echo isa: sm_30 sm_35 sm_53 sm_70 sm_75 sm_80 >> $@
>>
>> I'm not sure I understand how this is used.  Is this user-visible?  Is
>> there a libgomp test-case where we can observe a difference?
> 
> That's used for OpenMP context selectors like; that way, one can generate,
> e.g. one code used with nvptx and one with gcn as with:
> 
> #pragma omp declare variant (on_nvptx) 
> match(construct={target},device={arch(nvptx)})
> #pragma omp declare variant (on_gcn) 
> match(construct={target},device={arch(gcn)})
> ...
>    #pragma omp target map(from:v)
>    v = on ();
> which then either calls 'on' or 'on_nvptx' or 'on_gcn'
> (from libgomp/testsuite/libgomp.c/target-42.c)
> 
> 
> The following testcases use 'arch(nvptx)':
> 
> libgomp/testsuite/libgomp.c-c++-common/on_device_arch.h
> libgomp/testsuite/libgomp.c/target-42.c
> libgomp/testsuite/libgomp.c/usleep.h
> libgomp/testsuite/libgomp.fortran/declare-variant-1.f90
> 
> For ISA, there is only one run-time test:
> 
> libgomp/testsuite/libgomp.c/declare-variant-1.c
> 
> but only for x86-64: match (device={isa("avx512f")})
> 
> The sm_35 also appears, but only in the compile-time tests:
> gcc/testsuite/{c-c++-common,gfortran.dg}/gomp/declare-variant-{9,10}.*
> 

Thanks for the explanation.

I've updated the patch to include changes to 
nvptx_omp_device_kind_arch_isa, and committed.

I'll try to submit a patch with one or more test-cases.

Thanks,
- Tom


[-- Attachment #2: 0003-nvptx-Add-missing-t-omp-device-isas.patch --]
[-- Type: text/x-patch, Size: 1866 bytes --]

[nvptx] Add missing t-omp-device isas

In t-omp-device we list isas that can be used in omp declare variant like so:
...
  #pragma omp declare variant (f30) match (device={isa("sm_30")})
...
and in nvptx_omp_device_kind_arch_isa we handle them.

Update both to reflect the current list of isas.

Tested on x86_64-linux with nvptx accelerator.

gcc/ChangeLog:

2022-02-23  Tom de Vries  <tdevries@suse.de>

	* config/nvptx/nvptx.cc (nvptx_omp_device_kind_arch_isa): Handle
	sm_70, sm_75 and sm_80.
	* config/nvptx/t-omp-device: Add sm_53, sm_70, sm_75 and sm_80.

Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>

---
 gcc/config/nvptx/nvptx.cc     | 8 +++++++-
 gcc/config/nvptx/t-omp-device | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 6f6d592e462..b9451c2ed09 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -6181,7 +6181,13 @@ nvptx_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
       if (strcmp (name, "sm_35") == 0)
 	return TARGET_SM35 && !TARGET_SM53;
       if (strcmp (name, "sm_53") == 0)
-	return TARGET_SM53;
+	return TARGET_SM53 && !TARGET_SM70;
+      if (strcmp (name, "sm_70") == 0)
+	return TARGET_SM70 && !TARGET_SM75;
+      if (strcmp (name, "sm_75") == 0)
+	return TARGET_SM75 && !TARGET_SM80;
+      if (strcmp (name, "sm_80") == 0)
+	return TARGET_SM80;
       return 0;
     default:
       gcc_unreachable ();
diff --git a/gcc/config/nvptx/t-omp-device b/gcc/config/nvptx/t-omp-device
index 8765d9f1881..4228218a424 100644
--- a/gcc/config/nvptx/t-omp-device
+++ b/gcc/config/nvptx/t-omp-device
@@ -1,4 +1,4 @@
 omp-device-properties-nvptx: $(srcdir)/config/nvptx/nvptx.cc
 	echo kind: gpu > $@
 	echo arch: nvptx >> $@
-	echo isa: sm_30 sm_35 >> $@
+	echo isa: sm_30 sm_35 sm_53 sm_70 sm_75 sm_80 >> $@

  reply	other threads:[~2022-02-24  8:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 17:24 Tobias Burnus
2022-02-22 14:26 ` Tom de Vries
2022-02-22 14:39 ` Tom de Vries
2022-02-22 14:43 ` Tom de Vries
2022-02-22 16:03   ` Tobias Burnus
2022-02-24  8:29     ` Tom de Vries [this message]
2022-02-24 10:01       ` [PATCH][libgomp, testsuite, nvptx] Add libgomp.c/declare-variant-3-sm*.c Tom de Vries
2022-02-24 10:09         ` Jakub Jelinek
2022-02-24 10:32           ` Tom de Vries
2022-02-24 10:38             ` Jakub Jelinek
2023-11-30 14:48             ` Fix 'libgomp.c/declare-variant-3-*.c' compilation for configurations where GCN offloading is enabled in addition to nvptx (was: [PATCH][libgomp, testsuite, nvptx] Add libgomp.c/declare-variant-3-sm*.c) Thomas Schwinge
2023-11-30 14:49               ` Thomas Schwinge
2023-11-30 14:57             ` In 'libgomp.c/declare-variant-{3,4}-*.c', restrict 'scan-offload-tree-dump's to 'only_for_offload_target [...]' " Thomas Schwinge
2023-11-30 14:59             ` Spin 'dg-do run' part of 'libgomp.c/declare-variant-3-sm30.c' off into new 'libgomp.c/declare-variant-3.c' " Thomas Schwinge

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=71e9c008-7ad1-c24f-76eb-6a03180525c4@suse.de \
    --to=tdevries@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=tobias@codesourcery.com \
    /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).