public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
@ 2023-10-23 14:06 mxlol233 at outlook dot com
  2023-10-23 17:12 ` [Bug target/111937] " tschwinge at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: mxlol233 at outlook dot com @ 2023-10-23 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111937
           Summary: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1,
                    the `poly_xxx`  made `lto_input_mode_table` unable to
                    parse binary gimple data.
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mxlol233 at outlook dot com
  Target Milestone: ---

Recently, I wanted to port an open source gpgpu target (a custom modification
of RISCV) to GCC/openmp (Following the approach of gcu and nvptx, using
offloading (https://gcc.gnu.org/wiki/Offloading)). However, the upstream after
this patch
(https://github.com/mxlol233-ventus/gcc/commit/3496ca4e6566fc3c5f1093a0290bb88c34d368f8#diff-98b71abedd6e59eb80cb43e75ebb507ffa8bf540ee88aa099c6c7fe7cf90ae3e),
NUM_POLY_INT_COEFFS became greater than 1, while for the x86-64-*-* target,
NUM_POLY_INT_COEFFS=1. This makes it impossible for a RISC-V*-*-* lto1 to parse
the data in the LTO sections (e.g. gnu.offload_lto_*) of the object files
generated by x86-64-*-*.

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

* [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
@ 2023-10-23 17:12 ` tschwinge at gcc dot gnu.org
  2023-10-24  1:55 ` mxlol233 at outlook dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2023-10-23 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tschwinge at gcc dot gnu.org

--- Comment #1 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
Created attachment 56178
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56178&action=edit
0001-WIP-STATIC_ASSERT-MAX_MACHINE_MODE-256.patch

(In reply to Xiao Ma from comment #0)
> Recently, I wanted to port an open source gpgpu target (a custom
> modification of RISCV) to GCC/openmp (Following the approach of gcu and
> nvptx, using offloading (https://gcc.gnu.org/wiki/Offloading)).

Interesting!  Please keep us posted how this works out.

> However, the
> upstream after this patch
> (https://github.com/mxlol233-ventus/gcc/commit/
> 3496ca4e6566fc3c5f1093a0290bb88c34d368f8#diff-
> 98b71abedd6e59eb80cb43e75ebb507ffa8bf540ee88aa099c6c7fe7cf90ae3e),
> NUM_POLY_INT_COEFFS became greater than 1, while for the x86-64-*-* target,
> NUM_POLY_INT_COEFFS=1. This makes it impossible for a RISC-V*-*-* lto1 to
> parse the data in the LTO sections (e.g. gnu.offload_lto_*) of the object
> files generated by x86-64-*-*.

I'm not sure about your initial analysis; I'm not familiar with the
code/changes you cite.

However, please try building with the attached
'0001-WIP-STATIC_ASSERT-MAX_MACHINE_MODE-256.patch'.  If that triggers, we've
(likely...) found (one of) your issue(s).

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

* [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
  2023-10-23 17:12 ` [Bug target/111937] " tschwinge at gcc dot gnu.org
@ 2023-10-24  1:55 ` mxlol233 at outlook dot com
  2023-10-24  5:42 ` mxlol233 at outlook dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mxlol233 at outlook dot com @ 2023-10-24  1:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Xiao Ma <mxlol233 at outlook dot com> ---
(In reply to Thomas Schwinge from comment #1)
> Created attachment 56178 [details]
> 0001-WIP-STATIC_ASSERT-MAX_MACHINE_MODE-256.patch
> 
> (In reply to Xiao Ma from comment #0)

> I'm not sure about your initial analysis; I'm not familiar with the
> code/changes you cite.
> 
> However, please try building with the attached
> '0001-WIP-STATIC_ASSERT-MAX_MACHINE_MODE-256.patch'.  If that triggers,
> we've (likely...) found (one of) your issue(s).

Thanks for your advice, I will check this out, and attach a patch to show how
to reproduce it, under the upstream gcc.

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

* [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
  2023-10-23 17:12 ` [Bug target/111937] " tschwinge at gcc dot gnu.org
  2023-10-24  1:55 ` mxlol233 at outlook dot com
@ 2023-10-24  5:42 ` mxlol233 at outlook dot com
  2023-10-24  7:27 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mxlol233 at outlook dot com @ 2023-10-24  5:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Xiao Ma <mxlol233 at outlook dot com> ---
Created attachment 56185
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56185&action=edit
a patch on releases/gcc-13 to reproduce the bug.

steps:
1. git clone -b releases/gcc-13 https://github.com/gcc-mirror/gcc.git
2. cd gcc
3. #apply this patch
4. mkdir .build_accel && cd .build_accel && ../configure --target=rvgpu-none
--enable-languages=c --enable-as-accelerator-for=x86_64-pc-linux-gnu && make
all-gcc -j16
5. cd ../
6. mkdir .build_host && cd .build_host && ../configure --enable-languages=c
--enable-offload-targets=rvgpu-none=`pwd`/../../.install/rvgpu-none/ && make
all-gcc -j16
7. cd ../ && mkdir .tmp && cd .tmp
8. # touch a file:

```
/* { dg-do run } */


int
main (void)
{
  int i2, l = 0, r = 0, l2 = 0;
  int a[3][3][3];


  #pragma acc parallel
  #pragma acc loop collapse(4 - 1)
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          a[i][j][k] = i + j * 4 + k * 16;
#pragma acc parallel
    {
      #pragma acc loop collapse(2) reduction(|:l)
        for (i2 = 0; i2 < 2; i2++)
          for (int j = 0; j < 2; j++)
            for (int k = 0; k < 2; k++)
              if (a[i2][j][k] != i2 + j * 4 + k * 16)
                l += 1;
    }

  /*  Test loop with >= condition.  */
#pragma acc parallel
    {
      #pragma acc loop collapse(2) reduction(|:l2)
        for (i2 = 0; i2 < 2; i2++)
          for (int j = 1; j >= 0; j--)
            for (int k = 0; k < 2; k++)
              if (a[i2][j][k] != i2 + j * 4 + k * 16)
                l2 += 1;
    }

    for (i2 = 0; i2 < 2; i2++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          if (a[i2][j][k] != i2 + j * 4 + k * 16)
            r += 1;


  return 0;
}


```
9. ../.build_host/gcc/cc1 -fopenacc  -quiet  -o a.s a.c
# you will see the log like this:
```NUM_POLY_INT_COEFFS=1
```
10. as --64 -o a.o a.s

11. ../.build_accel/gcc/lto1 -quiet  -o a.o.s a.o                               
# you will see the log like this:
```
NUM_POLY_INT_COEFFS=2
‘
Segmentation fault
0xbf3e83 crash_signal
        ../../gcc/toplev.cc:314
0x7f92986f608f ???
       
/build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f929883b6e5 ???
        ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
0x1773512 pp_quoted_string
        ../../gcc/pretty-print.cc:1845
0x177435a pp_format(pretty_printer*, text_info*)
        ../../gcc/pretty-print.cc:1359
0x176495f diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ../../gcc/diagnostic.cc:1592
0x1765149 diagnostic_impl
        ../../gcc/diagnostic.cc:1756
0x1767236 fatal_error(unsigned int, char const*, ...)
        ../../gcc/diagnostic.cc:2141
0xa90e11 lto_input_mode_table(lto_file_decl_data*)
        ../../gcc/lto-streamer-in.cc:2103
0x748626 lto_file_finalize
        ../../gcc/lto/lto-common.cc:2275
0x748626 lto_create_files_from_ids
        ../../gcc/lto/lto-common.cc:2298
0x748626 lto_file_read
        ../../gcc/lto/lto-common.cc:2353
0x748626 read_cgraph_and_symbols(unsigned int, char const**)
        ../../gcc/lto/lto-common.cc:2801
0x735356 lto_main()
        ../../gcc/lto/lto.cc:654
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

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

* [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
                   ` (2 preceding siblings ...)
  2023-10-24  5:42 ` mxlol233 at outlook dot com
@ 2023-10-24  7:27 ` rguenth at gcc dot gnu.org
  2023-10-24  7:39 ` mxlol233 at outlook dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-24  7:27 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The host and the target compiler have to be "similar" enough for the LTO
bytecode to be transferable.  May I suggest to use aarch64 with SVE as host
instead?

I fear differing NUM_POLY_INT_COEFFS is almost impossible to support.  Well,
we could maybe stream NUM_POLY_INT_COEFFS and adjust reading to rewrite to
the target supported number - rewriting from 1 to 2 should be possible but
I'm not sure how to handle the reverse ...

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

* [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
                   ` (3 preceding siblings ...)
  2023-10-24  7:27 ` rguenth at gcc dot gnu.org
@ 2023-10-24  7:39 ` mxlol233 at outlook dot com
  2024-04-09  1:14 ` pinskia at gcc dot gnu.org
  2024-04-09  1:15 ` [Bug target/111937] offloading from x86_64-linux-gnu to riscv*-linux-gnu will have issues pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mxlol233 at outlook dot com @ 2023-10-24  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Xiao Ma <mxlol233 at outlook dot com> ---
yes. handle the lto reading process is simple: just make the binary block jump
steps is same  as the host's  num_poly value.



获取Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: rguenth at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
Sent: Tuesday, October 24, 2023 3:27:52 PM
To: mxlol233@outlook.com <mxlol233@outlook.com>
Subject: [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` >
1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple
data.

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The host and the target compiler have to be "similar" enough for the LTO
bytecode to be transferable.  May I suggest to use aarch64 with SVE as host
instead?

I fear differing NUM_POLY_INT_COEFFS is almost impossible to support.  Well,
we could maybe stream NUM_POLY_INT_COEFFS and adjust reading to rewrite to
the target supported number - rewriting from 1 to 2 should be possible but
I'm not sure how to handle the reverse ...

--
You are receiving this mail because:
You are on the CC list for the bug.
You reported the bug.

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

* [Bug target/111937] [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx`  made `lto_input_mode_table` unable to parse binary gimple data.
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
                   ` (4 preceding siblings ...)
  2023-10-24  7:39 ` mxlol233 at outlook dot com
@ 2024-04-09  1:14 ` pinskia at gcc dot gnu.org
  2024-04-09  1:15 ` [Bug target/111937] offloading from x86_64-linux-gnu to riscv*-linux-gnu will have issues pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-09  1:14 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 96265 ***

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

* [Bug target/111937] offloading from x86_64-linux-gnu to riscv*-linux-gnu will have issues
  2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
                   ` (5 preceding siblings ...)
  2024-04-09  1:14 ` pinskia at gcc dot gnu.org
@ 2024-04-09  1:15 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-09  1:15 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-09
             Status|RESOLVED                    |NEW
         Resolution|DUPLICATE                   |---
            Summary|[RISCV][lto][offload] When  |offloading from
                   |`NUM_POLY_INT_COEFFS` > 1,  |x86_64-linux-gnu to
                   |the `poly_xxx`  made        |riscv*-linux-gnu will have
                   |`lto_input_mode_table`      |issues
                   |unable to parse binary      |
                   |gimple data.                |

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually this is the opposite way as PR 96265.

Confirmed.

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

end of thread, other threads:[~2024-04-09  1:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 14:06 [Bug target/111937] New: [RISCV][lto][offload] When `NUM_POLY_INT_COEFFS` > 1, the `poly_xxx` made `lto_input_mode_table` unable to parse binary gimple data mxlol233 at outlook dot com
2023-10-23 17:12 ` [Bug target/111937] " tschwinge at gcc dot gnu.org
2023-10-24  1:55 ` mxlol233 at outlook dot com
2023-10-24  5:42 ` mxlol233 at outlook dot com
2023-10-24  7:27 ` rguenth at gcc dot gnu.org
2023-10-24  7:39 ` mxlol233 at outlook dot com
2024-04-09  1:14 ` pinskia at gcc dot gnu.org
2024-04-09  1:15 ` [Bug target/111937] offloading from x86_64-linux-gnu to riscv*-linux-gnu will have issues pinskia 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).