ROCm / HIP-CPU

An implementation of HIP that works on CPUs, across OSes.
MIT License
107 stars 19 forks source link

Internal compiler error building hip-cpu with gcc 12.3 #57

Open fwyzard opened 6 months ago

fwyzard commented 6 months ago

Using the current version of hip-cpu (1bf89aa Merge pull request #49 from Naraenda/remove-moodycamel-cmake) with GCC 12.3 on Ubuntu 22.04 results in an internal compiler error.

This can be seen with the hip-cpu tests:

$ git log -n1 --oneline
1bf89aa Merge pull request #49 from Naraenda/remove-moodycamel-cmake

$ mkdir build

$ cd build

$ cmake .. -DCMAKE_CXX_COMPILER=g++-12 -L
-- The CXX compiler identification is GNU 12.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++-12 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Looking for __PSTL_PAR_BACKEND_TBB
-- Looking for __PSTL_PAR_BACKEND_TBB - not found
-- Looking for _PSTL_PAR_BACKEND_TBB
-- Looking for _PSTL_PAR_BACKEND_TBB - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fwyzard/src/ROCm/hip-cpu/build
-- Cache values
BUILD_TESTING:BOOL=ON
CMAKE_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
TBB_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/TBB
hip_cpu_rt_BUILD_EXAMPLES:BOOL=ON
hip_cpu_rt_BUILD_TESTING:BOOL=ON
hip_cpu_rt_INSTALL_LIBRARY:BOOL=ON

$ cmake --build .
[  1%] Building CXX object examples/bit_extract/CMakeFiles/bit_extract.dir/bit_extract.cpp.o
In file included from /usr/include/c++/12/pstl/parallel_backend_tbb.h:26,
                 from /usr/include/c++/12/pstl/parallel_backend.h:20,
                 from /usr/include/c++/12/pstl/algorithm_impl.h:22,
                 from /usr/include/c++/12/pstl/glue_execution_defs.h:50,
                 from /usr/include/c++/12/execution:32,
                 from /home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/tile.hpp:21,
                 from /home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/coordinates.hpp:12,
                 from /home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/grid_launch.hpp:11,
                 from /home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/api.hpp:15,
                 from /home/fwyzard/src/ROCm/hip-cpu/include/hip/hip_api.h:14,
                 from /home/fwyzard/src/ROCm/hip-cpu/include/hip/hip_runtime.h:14,
                 from /home/fwyzard/src/ROCm/hip-cpu/examples/bit_extract/bit_extract.cpp:5:
/usr/include/tbb/task.h:21:139: note: ‘#pragma message: TBB Warning: tbb/task.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.’
   21 | #pragma message("TBB Warning: tbb/task.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
      |                                                                                                                                           ^
/home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/grid_launch.hpp: In instantiation of ‘void hip::detail::launch(const Dim3&, const Dim3&, uint32_t, Stream*, F, std::tuple<_UTypes ...>) [with F = launch_kernel_from_so(Function*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, Stream*, void**, void**)::<lambda()>; Args = {}; uint32_t = unsigned int; Stream = Flat_combiner<std::vector<std::packaged_task<void(bool&)> > >]’:
/home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/api.hpp:691:19:   required from here
/home/fwyzard/src/ROCm/hip-cpu/src/include/hip/detail/grid_launch.hpp:40:17: internal compiler error: Segmentation fault
   40 |                 ts.emplace_back(
      |                 ^~
0x7ff84904251f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7ff849029d8f __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7ff849029e3f __libc_start_main_impl
        ../csu/libc-start.c:392
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
gmake[2]: *** [examples/bit_extract/CMakeFiles/bit_extract.dir/build.make:76: examples/bit_extract/CMakeFiles/bit_extract.dir/bit_extract.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1138: examples/bit_extract/CMakeFiles/bit_extract.dir/all] Error 2
gmake: *** [Makefile:166: all] Error 2
AlexVlx commented 3 months ago

This appears fixed in GCC 13, so it might have been a transient issue impacting v12. As a temporary workaround, it appears viable to upgrade to 13 or, alternatively, stick to 11, which should work.

fwyzard commented 3 months ago

Thanks @AlexVlx, I confirm that it works for me with GCC 13 on Ubuntu 22.04.