public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates
@ 2020-07-30 12:53 burnus at gcc dot gnu.org
  2020-07-30 13:02 ` [Bug middle-end/96390] " burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-07-30 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96390
           Summary: [OpenMP] Link errors on the offload side for C++ code
                    with templates
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

sollve_vv's tests/4.5/application_kernels/gemv_target_reduction.cpp fails to
link when compiling with -O0.

Note: with -O1 and higher, it becomes a host-only code, which works.


Testcase:
https://github.com/SOLLVE/sollve_vv/blob/master/tests/4.5/application_kernels/alpaka_complex_template.cpp

g++ -fopenmp alpaka_complex_template.cpp -O0


Namely, with GCN:

ld: error: undefined symbol: S<0>::S()
>>> referenced by /tmp/ccGooH3g.o:(main._omp_fn.2)
>>> referenced by /tmp/ccGooH3g.o:(main._omp_fn.2)

ld: error: undefined symbol: V<1>::V<unsigned long, void>(unsigned long&&)
>>> referenced by /tmp/ccGooH3g.o:(main._omp_fn.2)
>>> referenced by /tmp/ccGooH3g.o:(main._omp_fn.2)

And likewise with nvptx:

libgomp: Link error log ptxas application ptx input, line 262; error   : Label
expected for argument 0 of instruction 'call'
ptxas application ptx input, line 262; error   : Function '_ZN1SILi0EEC1Ev' not
declared in this scope
ptxas application ptx input, line 262; error   : Call target not recognized
ptxas application ptx input, line 276; error   : Label expected for argument 0
of instruction 'call'
ptxas application ptx input, line 276; error   : Function
'_ZN1VILi1EEC1ImvEEOT_' not declared in this scope

which demangles to the same symbols.

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

* [Bug middle-end/96390] [OpenMP] Link errors on the offload side for C++ code with templates
  2020-07-30 12:53 [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates burnus at gcc dot gnu.org
@ 2020-07-30 13:02 ` burnus at gcc dot gnu.org
  2020-07-31 12:28 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-07-30 13:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 48961
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48961&action=edit
Test case from https://bugs.llvm.org/show_bug.cgi?id=43771 (basis for sollve_vv
test case, by Jonas Hahnfeld)

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

* [Bug middle-end/96390] [OpenMP] Link errors on the offload side for C++ code with templates
  2020-07-30 12:53 [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates burnus at gcc dot gnu.org
  2020-07-30 13:02 ` [Bug middle-end/96390] " burnus at gcc dot gnu.org
@ 2020-07-31 12:28 ` burnus at gcc dot gnu.org
  2020-07-31 14:52 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-07-31 12:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
omp-offload.c's omp_discover_declare_target_tgt_fn_r sees the

<function_decl 0x7ffff7647c00 __ct_comp
    full-name "S<0>::S()"

It does not call
 ((vec<tree> *) data)->safe_push (*tp);
to add it to the work list. (→ follow up issue for "V"?)

However, it sets the attribute (+ updates the node); in
omp_discover_declare_target_tgt_fn_r:

(gdb) p *tp
$27 = (tree) 0x7ffff7648e00
(gdb) p debug_tree((*tp)->decl_common.attributes)
 <tree_list 0x7ffff765b1e0
    purpose <identifier_node 0x7ffff7653400 omp declare target
        normal local bindings <(nil)>>>

But later in dump_function_to_file:

(gdb) p fndecl
$30 = (tree) 0x7ffff7648f00
(gdb) p debug_tree(fndecl->decl_common.attributes)

$31 = void

Thus, there is now a different tree – with DECL_ATTRIBUTES stripped.

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

* [Bug middle-end/96390] [OpenMP] Link errors on the offload side for C++ code with templates
  2020-07-30 12:53 [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates burnus at gcc dot gnu.org
  2020-07-30 13:02 ` [Bug middle-end/96390] " burnus at gcc dot gnu.org
  2020-07-31 12:28 ` burnus at gcc dot gnu.org
@ 2020-07-31 14:52 ` burnus at gcc dot gnu.org
  2020-09-28 16:08 ` cvs-commit at gcc dot gnu.org
  2020-09-28 16:44 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-07-31 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The following helps with the "S<0>::S()" problem – but then one runs into the
"V<1>::V" problem.

--- a/gcc/omp-offload.c
+++ b/gcc/omp-offload.c
@@ -207,6 +207,12 @@ omp_discover_declare_target_tgt_fn_r (tree *tp, int 
       symtab_node *node = symtab_node::get (*tp);
       if (node != NULL)
        {
+         if (node->cpp_implicit_alias)
+           {
+             node = node->get_alias_target ();
+             DECL_ATTRIBUTES (node->decl)
+               = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (node->decl));
+           }
          node->offloadable = 1;
          if (ENABLE_OFFLOADING)
            g->have_offload = true;

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

* [Bug middle-end/96390] [OpenMP] Link errors on the offload side for C++ code with templates
  2020-07-30 12:53 [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-07-31 14:52 ` burnus at gcc dot gnu.org
@ 2020-09-28 16:08 ` cvs-commit at gcc dot gnu.org
  2020-09-28 16:44 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-28 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:2a10a2c0689db280ee3a94164504b7196b8370f4

commit r11-3505-g2a10a2c0689db280ee3a94164504b7196b8370f4
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Sep 28 18:08:05 2020 +0200

    OpenMP: Handle cpp_implicit_alias in declare-target discovery (PR96390)

    gcc/ChangeLog:

            PR middle-end/96390
            * omp-offload.c (omp_discover_declare_target_tgt_fn_r): Handle
            alias nodes.

    libgomp/ChangeLog:

            PR middle-end/96390
            * testsuite/libgomp.c++/pr96390.C: New test.
            * testsuite/libgomp.c-c++-common/pr96390.c: New test.

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

* [Bug middle-end/96390] [OpenMP] Link errors on the offload side for C++ code with templates
  2020-07-30 12:53 [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-09-28 16:08 ` cvs-commit at gcc dot gnu.org
@ 2020-09-28 16:44 ` burnus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2020-09-28 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on GCC 11 (= mainline).

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

end of thread, other threads:[~2020-09-28 16:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 12:53 [Bug middle-end/96390] New: [OpenMP] Link errors on the offload side for C++ code with templates burnus at gcc dot gnu.org
2020-07-30 13:02 ` [Bug middle-end/96390] " burnus at gcc dot gnu.org
2020-07-31 12:28 ` burnus at gcc dot gnu.org
2020-07-31 14:52 ` burnus at gcc dot gnu.org
2020-09-28 16:08 ` cvs-commit at gcc dot gnu.org
2020-09-28 16:44 ` 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).