public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases
@ 2020-09-18  7:15 burnus at gcc dot gnu.org
  2020-09-18  8:04 ` [Bug target/97102] " burnus at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-18  7:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

            Bug ID: 97102
           Summary: [nvptx] PTX JIT compilation failed when using aliases
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: vries at gcc dot gnu.org
  Target Milestone: ---

[Found when testing a patch for PR96390, which works with GCN offloading but
not with nvptx]

When compiling the following with -fopenmp
--------------------------------------
#pragma omp declare target
int foo () { return 42; }
int bar () __attribute__((alias ("foo")));
#pragma omp end declare target

int
main ()
{
  int n;
  #pragma omp target map(from:n)
    n = bar ();
  if (n != 42)
    __builtin_abort ();
}
--------------------------------------

it fails with when running with:

libgomp: Link error log ptxas application ptx input, line 89; error   : Label
expected for argument 0 of instruction 'call'
ptxas application ptx input, line 89; fatal   : Call target not recognized
ptxas fatal   : Ptx assembly aborted due to errors

libgomp: cuLinkAddData (ptx_code) error: a PTX JIT compilation failed


The generated PTX has:
------------
// BEGIN GLOBAL FUNCTION DECL: foo
.visible .func (.param.u32 %value_out) foo;

// BEGIN GLOBAL FUNCTION DEF: foo
.visible .func (.param.u32 %value_out) foo
{
        .reg.u32 %value;
        .reg.u32 %r22;
        .reg.u32 %r23;
                mov.u32 %r22, 42;
                mov.u32 %r23, %r22;
                mov.u32 %value, %r23;
        st.param.u32    [%value_out], %value;
        ret;
}
...
call (%value_in), bar;
------

Namely: 'bar' only appears in the call.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
@ 2020-09-18  8:04 ` burnus at gcc dot gnu.org
  2020-09-18 10:27 ` burnus at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-18  8:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #0)
> .visible .func (.param.u32 %value_out) foo

https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#kernel-and-function-directives-alias

has the example:

.visible .func bar(.param .u32 p);
.alias bar, foo;

And the note:
.alias directive requires sm_30 or higher.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
  2020-09-18  8:04 ` [Bug target/97102] " burnus at gcc dot gnu.org
@ 2020-09-18 10:27 ` burnus at gcc dot gnu.org
  2020-09-18 10:42 ` burnus at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-18 10:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 49239
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49239&action=edit
Draft patch

PTX ISA Notes
.alias directive introduced in PTX ISA 6.3.

Thus, it does not work everywhere :-(

Patch – I did bump '.version' - but that probably has more side effects than
desirable.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
  2020-09-18  8:04 ` [Bug target/97102] " burnus at gcc dot gnu.org
  2020-09-18 10:27 ` burnus at gcc dot gnu.org
@ 2020-09-18 10:42 ` burnus at gcc dot gnu.org
  2020-09-22  6:10 ` vries at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-18 10:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #2)
> PTX ISA Notes
> .alias directive introduced in PTX ISA 6.3.

Which is CUDA 10.0, cf.
https://docs.nvidia.com/cuda/archive/10.0/cuda-toolkit-release-notes/index.html#cuda-general-new-features

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-09-18 10:42 ` burnus at gcc dot gnu.org
@ 2020-09-22  6:10 ` vries at gcc dot gnu.org
  2020-09-22  7:18 ` vries at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2020-09-22  6:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #2)
> Created attachment 49239 [details]
> Draft patch
> 
> PTX ISA Notes
> .alias directive introduced in PTX ISA 6.3.
> 
> Thus, it does not work everywhere :-(
> 
> Patch – I did bump '.version' - but that probably has more side effects than
> desirable.

This patch does manage to complete a build, but tests (both standalone and
libgomp) using alias fail with "unresolved symbol".  This is because it calls
write_fn_proto which generates a linker marker for the alias, which makes the
linker think there's such a function, and when it cannot find it, it generates
an "unresolved symbol" error.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-09-22  6:10 ` vries at gcc dot gnu.org
@ 2020-09-22  7:18 ` vries at gcc dot gnu.org
  2020-09-22  8:09 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2020-09-22  7:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 49252
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49252&action=edit
Other draft patch

I started out independently, and converged to roughly the same code.

One thing I came across during standalone testing is that the alias support in
gcc is for symbols, and as such supports functions and variables, but the ptx
support is only there for functions.  I handle this in the patch with an error,
but it causes quite a few failures:
...
src/gcc/testsuite/gcc.c-torture/execute/alias-2.c:3:12: error: non-function
alias definitions not supported in this configuration^M
compiler exited with status 1
FAIL: gcc.c-torture/execute/alias-2.c   -O0  (test for excess errors)
...
So, that would probably need to be handled by separate effective targets
alias_var/alias_fn.

With standalone testing we also run into various problems related to bumping
the ISA, see also PR96005.

As for libgomp testing, I've tried the test reported in this PR, and got this
ptx link error (silent with trunk, needed to add some printing in plugin):
...
Internal error: reference to deleted section
...

By dumping the ptx code using GOMP_NVPTX_PTXRW and compiling it using ptxas, it
becomes clear that the most complained about problem is deprecated shfl:
...
ptxas gomp-nvptx.11.ptx, line 117; warning : Instruction 'shfl' without '.sync'
is deprecated since PTX ISA version 6.0 and will be discontinued in a future
PTX ISA version
...

The internal error is a driver problem, but it's possible that we push the
driver into a corner by using deprecated insns alongside with modern constructs
like .alias.

So, it seems sensible to do the porting to newer ISA (PR96005) first, before
trying to enable .alias.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-09-22  7:18 ` vries at gcc dot gnu.org
@ 2020-09-22  8:09 ` vries at gcc dot gnu.org
  2020-09-23  7:25 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2020-09-22  8:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #49252|0                           |1
        is obsolete|                            |

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 49253
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49253&action=edit
Updated other draft patch

(In reply to Tom de Vries from comment #5)
> One thing I came across during standalone testing is that the alias support
> in gcc is for symbols, and as such supports functions and variables, but the
> ptx support is only there for functions.  I handle this in the patch with an
> error, 

Oops, that bit was missing, now added.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-09-22  8:09 ` vries at gcc dot gnu.org
@ 2020-09-23  7:25 ` vries at gcc dot gnu.org
  2020-09-23  7:31 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2020-09-23  7:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2020-09-23  7:25 ` vries at gcc dot gnu.org
@ 2020-09-23  7:31 ` vries at gcc dot gnu.org
  2021-05-12 16:39 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2020-09-23  7:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
In PR97106 comment 1, it's suggested:
...
14:11 < amonakov> Tobias__: I think the proper way to solve this is define
hooks for the backend to print something for aliases, and then have nvptx-ld.c
resolve them
...
which wouldn't rely on ptx .alias.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2020-09-23  7:31 ` vries at gcc dot gnu.org
@ 2021-05-12 16:39 ` vries at gcc dot gnu.org
  2022-03-22 13:59 ` vries at gcc dot gnu.org
  2022-09-07  8:02 ` burnus at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2021-05-12 16:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102
Bug 97102 depends on bug 96005, which changed state.

Bug 96005 Summary: Add possibility to use newer ptx isa
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96005

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-05-12 16:39 ` vries at gcc dot gnu.org
@ 2022-03-22 13:59 ` vries at gcc dot gnu.org
  2022-09-07  8:02 ` burnus at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-22 13:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
The test-case from comment 0 now works in combination with:
/* { dg-additional-options "-foffload=-malias -foffload=-mptx=6.3" } */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/97102] [nvptx] PTX JIT compilation failed when using aliases
  2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-03-22 13:59 ` vries at gcc dot gnu.org
@ 2022-09-07  8:02 ` burnus at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-09-07  8:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102

--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Regarding the commit:

commit r12-7766-gf8b15e177155960017ac0c5daef8780d1127f91c
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Mar 11 13:41:01 2022 +0100

    [nvptx] Use .alias directive for mptx >= 6.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-09-07  8:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18  7:15 [Bug target/97102] New: [nvptx] PTX JIT compilation failed when using aliases burnus at gcc dot gnu.org
2020-09-18  8:04 ` [Bug target/97102] " burnus at gcc dot gnu.org
2020-09-18 10:27 ` burnus at gcc dot gnu.org
2020-09-18 10:42 ` burnus at gcc dot gnu.org
2020-09-22  6:10 ` vries at gcc dot gnu.org
2020-09-22  7:18 ` vries at gcc dot gnu.org
2020-09-22  8:09 ` vries at gcc dot gnu.org
2020-09-23  7:25 ` vries at gcc dot gnu.org
2020-09-23  7:31 ` vries at gcc dot gnu.org
2021-05-12 16:39 ` vries at gcc dot gnu.org
2022-03-22 13:59 ` vries at gcc dot gnu.org
2022-09-07  8:02 ` burnus at gcc dot gnu.org

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).