ROCm / HIP

HIP: C++ Heterogeneous-Compute Interface for Portability
https://rocmdocs.amd.com/projects/HIP/
MIT License
3.76k stars 538 forks source link

cmake build error: unknown type name 'hipEvent_t'; #959

Closed holyprince closed 5 years ago

holyprince commented 5 years ago

I use cmake to build a complex GPU program ported from cuda. I have used the guide to find hip https://github.com/ROCm-Developer-Tools/HIP/tree/master/samples/2_Cookbook/12_cmake_hip_add_executable#including-findhip-cmake-module-in-the-project But it prints the error and to make it more detailed, I print the make process:

[ 0%] Building HIPCC object src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o .......................................................................................... /opt/rocm/hip/bin/hipcc -c /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include In file included from /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp:1: In file included from /home/holy/autom-2/src/acc/acc_projector_plan.h:9: /home/holy/autom-2/src/acc/hip/custom_allocator.hpp:55:3: error: unknown type name 'hipEvent_t'; did you mean 'sigevent_t'? hipEvent_t readyEvent; ^~~~~~ sigevent_t /usr/include/bits/siginfo.h:321:5: note: 'sigevent_t' declared here } sigevent_t;

And I have checked that the file has included the header file "hip/hip_runtime.h"

So what may the problem be?

mangupta commented 5 years ago

Could you try turning on cmake verbose mode using make VERBOSE=1 <your_target>? Additionally you can also turn on hipcc verbose mode using export HIPCC_VERBOSE=7. Please share the build log after turning on these 2 verbose modes.

holyprince commented 5 years ago

ok, I have turned the two verbose modes and the output is :

[ 0%] Building HIPCC object src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o cd /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip && /work/soft/compiler/cmake-3.13.0/bin/cmake -E make_directory /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/. cd /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip && /work/soft/compiler/cmake-3.13.0/bin/cmake -D verbose:BOOL=1 -D build_configuration:STRING=Release -D generated_file:STRING=/home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o -P /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.cmake -- Removing /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o /work/soft/compiler/cmake-3.13.0/bin/cmake -E remove /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o -- Generating dependency file: /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre /opt/rocm/hip/bin/hipcc -M /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include HIP_PATH=/opt/rocm/hip HIP_PLATFORM=hcc HSA_PATH=/opt/rocm/hsa HCC_HOME=/opt/rocm/hcc hipcc-args: -M /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include hipcc-cmd: /opt/rocm/hcc/bin/hcc -hc -DHIPCC -I/opt/rocm/hcc/include -I/opt/rocm/hip/include/hip/hcc_detail/cuda -I/opt/rocm/hsa/include -Wno-deprecated-register -I/opt/rocm/profiler/CXLActivityLogger/include -I/opt/rocm/hip/include -DHIP_VERSION_MAJOR=1 -DHIP_VERSION_MINOR=5 -DHIP_VERSION_PATCH=18353 -DHIP_ARCH_GFX906=1 -M /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include -- Generating temporary cmake readable file: /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.tmp /work/soft/compiler/cmake-3.13.0/bin/cmake -D input_file:FILEPATH=/home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir/__/acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre -D output_file:FILEPATH=/home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.tmp -D verbose=1 -P /opt/rocm/hip/cmake/FindHIP/run_make2cmake.cmake -- Copy if different /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.tmp to /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend /work/soft/compiler/cmake-3.13.0/bin/cmake -E copy_if_different /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.tmp /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend -- Removing /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.tmp and /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre /work/soft/compiler/cmake-3.13.0/bin/cmake -E remove /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.tmp /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/autom_gpu_util_generated_hip_projector_plan.hip.cpp.o.depend.pre -- Generating /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o /opt/rocm/hip/bin/hipcc -c /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include HIP_PATH=/opt/rocm/hip HIP_PLATFORM=hcc HSA_PATH=/opt/rocm/hsa HCC_HOME=/opt/rocm/hcc hipcc-args: -c /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include hipcc-cmd: /opt/rocm/hcc/bin/hcc -hc -DHIPCC -I/opt/rocm/hcc/include -I/opt/rocm/hip/include/hip/hcc_detail/cuda -I/opt/rocm/hsa/include -Wno-deprecated-register -I/opt/rocm/profiler/CXLActivityLogger/include -I/opt/rocm/hip/include -DHIP_VERSION_MAJOR=1 -DHIP_VERSION_MINOR=5 -DHIP_VERSION_PATCH=18353 -DHIP_ARCH_GFX906=1 -c /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp -o /home/holy/autom-2/build2/src/apps/CMakeFiles/autom_gpu_util.dir//acc/hip/./autom_gpu_util_generated_hip_projector_plan.hip.cpp.o -I/work/soft/mpi/openmpi/3.1.0_hygon/gcc-7.2/include -I/home/holy/autom-2 -I/home/holy/autom-2/external/fftw/include -I/opt/rocm/include -I/opt/rocm/rocrand/include -I/opt/rocm/hiprand/include In file included from /home/holy/autom-2/src/acc/hip/hip_projector_plan.hip.cpp:1: In file included from /home/holy/autom-2/src/acc/acc_projector_plan.h:9: /home/holy/autom-2/src/acc/hip/custom_allocator.hpp:55:3: error: unknown type name 'hipEvent_t'; did you mean 'sigevent_t'? hipEvent_t readyEvent; ^~~~~~ sigevent_t /usr/include/bits/siginfo.h:321:5: note: 'sigevent_t' declared here } sigevent_t;

mangupta commented 5 years ago

I am guessing that the GPU application in question is https://github.com/3dem/relion. Looking at https://github.com/3dem/relion/blob/master/src/acc/cuda/custom_allocator.cuh, it seems to require CUDA to be defined for it to work correctly. This seems to be enabled in https://github.com/3dem/relion/blob/master/CMakeLists.txt#L147. However I don't see -DCUDA or anything similar being passed to hipcc in the logs you shared. Please recheck your build scripts. Alternatively see if you can share your HIPified code for us to look at it.

holyprince commented 5 years ago

Thank you very much. Your guess is right and I try to port the relion application to rocm. After getting your wise advice, I find I miss the -DHIP in the build logs. But I have written the flag is true in the CMakeLists.txt like this:

if(HIP) add_definitions(-DHIP) endif() I also add the flag in the subdirectories cmake file :

if (HIP_FOUND)

add_definitions(-DHIP) set(HIP_INCLUDE_PATH /opt/rocm/include) include_directories("${HIP_INCLUDE_PATH}") include_directories("/opt/rocm/rocrand/include") include_directories("/opt/rocm/hiprand/include")

find_package(rocprim REQUIRED CONFIG PATHS "/opt/rocm/rocprim")
find_package(hipcub REQUIRED CONFIG PATHS "/opt/rocm/rocPRIM/hipcub")

file(GLOB REL_HIP_SRC "${CMAKE_SOURCE_DIR}/src/acc/hip/*.hip.cpp" "${CMAKE_SOURCE_DIR}/src/acc/hip/hip_kernels/*.hip.cpp" )
set_source_files_properties(${REL_HIP_SRC} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_library(relion_gpu_util ${REL_HIP_SRC})

But it doesn't work and the error is the same. Even though I use cmake .. -DHIP=ON also has no effect.

It is very strange, and the whole HIPified code is provided : https://github.com/holyprince/relionrocm

Thank you very much!