[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #16 from Tom de Vries --- Created attachment 42977 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42977=edit Updated patch, with both openacc and openmp testcase
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 Tom de Vries changed: What|Removed |Added Keywords||openmp CC||jakub at gcc dot gnu.org --- Comment #15 from Tom de Vries --- Reproduced with openmp as well.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #14 from Tom de Vries --- (In reply to Tom de Vries from comment #13) > Created attachment 42974 [details] > Tentative patch with testcase > > Currently doing: > - bootstrap and reg test on x86_64, and > - build & libgomp regtest on x86_64 with nvptx accelerator. Done, no issues found.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #13 from Tom de Vries --- Created attachment 42974 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42974=edit Tentative patch with testcase Currently doing: - bootstrap and reg test on x86_64, and - build & libgomp regtest on x86_64 with nvptx accelerator.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #12 from Tom de Vries --- Tentative patch: ... diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index ed3df15b143..de5655abbb6 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -,6 +,16 @@ output_offload_tables (void) struct lto_simple_output_block *ob = lto_create_simple_output_block (LTO_section_offload_table); + for (unsigned i = 0; i < vec_safe_length (offload_funcs);) +{ + if (!cgraph_node::get((*offload_funcs)[i])) + { + offload_funcs->ordered_remove (i); + continue; + } + i++; +} + for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++) { streamer_write_enum (ob->main_stream, LTO_symtab_tags, ...
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #11 from Tom de Vries --- Rewriting the test-case like this triggers the ICE without -Wreturn-type being active: ... /* { dg-do run { target openacc_nvidia_accel_selected } } */ /* This code uses nvptx inline assembly guarded with acc_on_device, which is not optimized away at -O0, and then confuses the target assembler. { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ #include #include #define N 100 #define GANG_ID(I) \ (acc_on_device (acc_device_nvidia)\ ? ({unsigned __r;\ __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (__r)); \ __r; }) : (I)) int main () { int a[N]; int i, x; int c; c = 1; #pragma acc parallel loop gang (static:*) num_gangs (10) for (i = 0; i < 100; i++) a[i] = GANG_ID (i); if (c) __builtin_unreachable (); #pragma acc parallel loop gang (static:1) num_gangs (10) for (i = 0; i < 100; i++) a[i] = GANG_ID (i); return 0; } ...
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 Tom de Vries changed: What|Removed |Added Target||nvptx --- Comment #10 from Tom de Vries --- (In reply to Martin Liška from comment #8) > (In reply to Martin Liška from comment #7) > > Created attachment 42667 [details] > > Untested patch > > Can you please Thomas test it and send to mailing list (and commit). > Thanks. I've tested and committed the work-around, which re-enables the test-case. Of course the ICE still needs to be fixed.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #9 from Tom de Vries --- Author: vries Date: Wed Dec 27 07:50:04 2017 New Revision: 256008 URL: https://gcc.gnu.org/viewcvs?rev=256008=gcc=rev Log: Workaround PR83046 in gang-static-2.c 2017-12-27 Tom de VriesPR c++/83046 * testsuite/libgomp.oacc-c-c++-common/gang-static-2.c (test_static) (test_nonstatic): Fix return type to workaround PR83046. Modified: trunk/libgomp/ChangeLog trunk/libgomp/testsuite/libgomp.oacc-c-c++-common/gang-static-2.c
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 Martin Liška changed: What|Removed |Added Status|WAITING |NEW --- Comment #8 from Martin Liška --- (In reply to Martin Liška from comment #7) > Created attachment 42667 [details] > Untested patch Can you please Thomas test it and send to mailing list (and commit). Thanks.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #7 from Martin Liška --- Created attachment 42667 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42667=edit Untested patch
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #6 from Thomas Schwinge --- (In reply to Martin Liška from comment #5) > Thanks for instructions, but apparently does not work for me: > > make check-target-libgomp > === libgomp Summary === > > # of untested testcases 2 Oh, sorry, that must be the tests being skipped when you don't have a Nvidia GPU. Please remove the "dg-do run { target openacc_nvidia_accel_selected }" directive from the test case file.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #5 from Martin Liška --- Thanks for instructions, but apparently does not work for me: make check-target-libgomp RUNTESTFLAGS='--target_board=unix\{-foffload=disable\} {c,c++}.exp=gang-static-2.c' make[1]: Entering directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp' Making check in testsuite make[2]: Entering directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp/testsuite' make check-DEJAGNU make[3]: Entering directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp/testsuite' srcdir='../../../../libgomp/testsuite'; export srcdir; \ EXPECT=expect; export EXPECT; \ runtest=runtest; \ if /bin/sh -c "$runtest --version" > /dev/null 2>&1; then \ exit_status=0; l='libgomp'; for tool in $l; do \ if $runtest --tool $tool --srcdir $srcdir --target_board=unix\{-foffload=disable\} {c,c++}.exp=gang-static-2.c; \ then :; else exit_status=1; fi; \ done; \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi; \ exit $exit_status Test run by marxin on Mon Nov 20 15:03:00 2017 Native configuration is x86_64-pc-linux-gnu === libgomp tests === Schedule of variations: unix/-foffload=disable Running target unix/-foffload=disable Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using ../../../../libgomp/testsuite/config/default.exp as tool-and-target-specific interface file. Running ../../../../libgomp/testsuite/libgomp.c/c.exp ... Running ../../../../libgomp/testsuite/libgomp.c++/c++.exp ... Running ../../../../libgomp/testsuite/libgomp.hsa.c/c.exp ... Running ../../../../libgomp/testsuite/libgomp.oacc-c/c.exp ... Running ../../../../libgomp/testsuite/libgomp.oacc-c++/c++.exp ... === libgomp Summary === # of untested testcases 2 # of unsupported tests 2 make[3]: Leaving directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp/testsuite' make[2]: Leaving directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp/testsuite' make[2]: Entering directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp' true DO=all multi-do # make : : : make[2]: Leaving directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp' make[1]: Leaving directory '/home/marxin/Programming/gcc/objdir2/x86_64-pc-linux-gnu/libgomp' $ ./gcc/xgcc -v Using built-in specs. COLLECT_GCC=./gcc/xgcc OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-pc-linux-gnu Configured with: ../configure --enable-languages=c,c++,fortran --disable-multilib --prefix=/home/marxin/bin/gcc --disable-bootstrap --enable-offload-targets=nvptx-none=/no/where Thread model: posix gcc version 8.0.0 20171120 (experimental) (GCC)
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #4 from Thomas Schwinge --- (In reply to Martin Liška from comment #3) > (In reply to Thomas Schwinge from comment #0) > > ... starting with r254437 "Instrument function exit with > > __builtin_unreachable in C++". > > Obviously, that test case has a "-Wreturn-type mismatch" (which is not > > diagnosed for C++; see reduced PR83045), and fixing that cures this nvptx > > offloading ICE. > > Can you please provide steps to reproduce this? You'll either have to build an offloading compiler, but -- much simpler! -- I assume it will be sufficient to resolve the issue seen in the "-foffload=disable" case: Configure GCC as usual, but add "--enable-offload-targets=nvptx-none=/no/where" (to generally enable offloading, but without providing an actual nvptx offloading compiler), build, and then run: $ make check-target-libgomp RUNTESTFLAGS='--target_board=unix\{-foffload=disable\} {c,c++}.exp=gang-static-2.c' [...] Running target unix/-foffload=disable Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target. Using /usr/share/dejagnu/config/unix.exp as generic interface file for target. Using ../../../../source-gcc/libgomp/testsuite/config/default.exp as tool-and-target-specific interface file. Running ../../../../source-gcc/libgomp/testsuite/libgomp.c/c.exp ... Running ../../../../source-gcc/libgomp/testsuite/libgomp.c++/c++.exp ... Running ../../../../source-gcc/libgomp/testsuite/libgomp.hsa.c/c.exp ... Running ../../../../source-gcc/libgomp/testsuite/libgomp.oacc-c/c.exp ... FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/gang-static-2.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -O2 execution test Running ../../../../source-gcc/libgomp/testsuite/libgomp.oacc-c++/c++.exp ... FAIL: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/gang-static-2.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -O2 (test for excess errors) === libgomp Summary === # of expected passes1 # of unexpected failures2 # of unresolved testcases 1 # of unsupported tests 4 [...] Compilation should either succeed (as it still does for C, and did before for C++), or terminate with a suitable diagnostic (the issue discussed in PR83045 "-Wreturn-type regression in C++"). For "c.exp" the "execution test" FAILs: "libgomp: target function wasn't mapped" (expected in this special configuration), but for c++.exp you'll see compilation FAIL with "excess errors": /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x0): undefined reference to `main._omp_fn.7' /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x8): undefined reference to `main._omp_fn.6' /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x10): undefined reference to `main._omp_fn.5' /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x18): undefined reference to `main._omp_fn.4' /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x20): undefined reference to `main._omp_fn.3' /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x28): undefined reference to `main._omp_fn.2' /tmp/ccBzwk9H.o:(.gnu.offload_funcs+0x30): undefined reference to `main._omp_fn.1' collect2: error: ld returned 1 exit status compiler exited with status 1 (I'll probably not be able to look into that myself in the next few weeks.)
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #3 from Martin Liška --- (In reply to Thomas Schwinge from comment #0) > ... starting with r254437 "Instrument function exit with > __builtin_unreachable in C++". > > Program received signal SIGSEGV, Segmentation fault. > input_offload_tables (do_force_output=true) at > [...]/source-gcc/gcc/lto-cgraph.c:1942 > 1942varpool_node::get (var_decl)->force_output = 1; > (gdb) bt > #0 input_offload_tables (do_force_output=true) at > [...]/source-gcc/gcc/lto-cgraph.c:1942 > #1 0x005a0927 in read_cgraph_and_symbols (fnames= out>, nfiles=) at [...]/source-gcc/gcc/lto/lto.c:2863 > #2 lto_main () at [...]/source-gcc/gcc/lto/lto.c:3314 > #3 0x00a7f63f in compile_file () at > [...]/source-gcc/gcc/toplev.c:455 > #4 0x0056ef20 in do_compile () at > [...]/source-gcc/gcc/toplev.c:2059 > #5 toplev::main (this=this@entry=0x7fffcfb0, argc=argc@entry=15, > argv=0x17908e0, argv@entry=0x7fffd0b8) at > [...]/source-gcc/gcc/toplev.c:2194 > #6 0x00571457 in main (argc=15, argv=0x7fffd0b8) at > [...]/source-gcc/gcc/main.c:39 > > Obviously, that test case has a "-Wreturn-type mismatch" (which is not > diagnosed for C++; see reduced PR83045), and fixing that cures this nvptx > offloading ICE. Hello. Can you please provide steps to reproduce this?
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 --- Comment #2 from Thomas Schwinge --- Also, for "-foffload=disable -x c++" we now run into: /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x0): undefined reference to `main._omp_fn.7' /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x8): undefined reference to `main._omp_fn.6' /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x10): undefined reference to `main._omp_fn.5' /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x18): undefined reference to `main._omp_fn.4' /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x20): undefined reference to `main._omp_fn.3' /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x28): undefined reference to `main._omp_fn.2' /tmp/ccAXdy3B.o:(.gnu.offload_funcs+0x30): undefined reference to `main._omp_fn.1' collect2: error: ld returned 1 exit status ..., which also suggests some C++ front end/middle end offloading inconsistency.
[Bug c++/83046] ICE in nvptx offloading, C++ compilation of libgomp.oacc-c-c++-common/gang-static-2.c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83046 Thomas Schwinge changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2017-11-19 Ever confirmed|0 |1 --- Comment #1 from Thomas Schwinge --- I suggest we first analyze PR83045.