ROCm / rpp

AMD ROCm Performance Primitives (RPP) library is a comprehensive high-performance computer vision library for AMD processors with HIP/OpenCL/CPU back-ends.
https://rocm.docs.amd.com/projects/rpp/en/latest/
MIT License
55 stars 40 forks source link

Can't compile in Ubuntu 22.04 #255

Closed ochiana closed 1 year ago

ochiana commented 1 year ago

Somehow the CMakeLists.txt doesn't find OpenMP.

 /opencv/build$ cmake -DBACKEND=HIP ../rpp
-- INFO:ROCM_PATH Set -- /opt/rocm
TEST DEBUG: /opt/rocm/include

-- AMD ROCm Performance Primitives (RPP) Version -- 1.5.0
-- AMD RPP install path set to -- /opt/rocm
-- AMD RPP Backend set to -- HIP
-- AMD RPP Build Type -- Release
-- Using HALF -- 
    Includes:/opt/rocm/include
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindOpenMP.cmake:544 (find_package_handle_standard_args)
  CMakeLists.txt:138 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/CMakeError.log".

From what I see in the error log, it cannot find omp.h file because it doesn't include the /opt/rocm folders.

Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_bffe9/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_bffe9.dir/build.make CMakeFiles/cmTC_bffe9.dir/build
gmake[1]: Entering directory '/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o
/usr/bin/clang++   -O3 -Ofast -DNDEBUG -Xclang -fopenmp -v -MD -MT CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o -MF CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o.d -o CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o -c /home/florin/cust-ffmpeg/opencv/build/CMakeFiles/FindOpenMP/OpenMPTryFlag.cpp
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name OpenMPTryFlag.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -menable-no-infs -menable-no-nans -fapprox-func -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/CMakeTmp -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -dependency-file CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o.d -MT CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o -sys-header-deps -D NDEBUG -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Ofast -fdeprecated-macro -fdebug-compilation-dir=/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/CMakeTmp -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -fopenmp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o -x c++ /home/florin/cust-ffmpeg/opencv/build/CMakeFiles/FindOpenMP/OpenMPTryFlag.cpp
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12
 /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12
 /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/FindOpenMP/OpenMPTryFlag.cpp:2:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^~~~~~~
1 error generated.
gmake[1]: *** [CMakeFiles/cmTC_bffe9.dir/build.make:79: CMakeFiles/cmTC_bffe9.dir/OpenMPTryFlag.cpp.o] Error 1
gmake[1]: Leaving directory '/home/florin/cust-ffmpeg/opencv/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_bffe9/fast] Error 2

I have the latest rocm-5.7.1 and I see there the omp.h header.

opencv/build$ locate omp.h | grep rocm
/opt/rocm-5.7.1/include/thrust/system/omp/detail/pragma_omp.h
/opt/rocm-5.7.1/llvm/include/omp.h
/opt/rocm-5.7.1/llvm/lib/clang/17.0.0/include/omp.h
/opt/rocm-5.7.1/llvm/lib-debug/src/openmp/runtime/src/kmp_omp.h
/opt/rocm-5.7.1/llvm/lib-debug/src/openmp/runtime/src/include/omp.h.var
/opt/rocm-5.7.1/rocthrust/include/thrust/system/omp/detail/pragma_omp.h

And this is the hipconfig output.

opencv/build$ /opt/rocm/bin/hipconfig --full
HIP version  : 5.7.31921-1949b1621

== hipconfig
HIP_PATH     : /opt/rocm-5.7.1
ROCM_PATH    : /opt/rocm-5.7.1
HIP_COMPILER : clang
HIP_PLATFORM : amd
HIP_RUNTIME  : rocclr
CPP_CONFIG   :  -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__= -I/opt/rocm-5.7.1/include -I/opt/rocm-5.7.1/llvm/lib/clang/17.0.0

== hip-clang
HIP_CLANG_PATH   : /opt/rocm-5.7.1/llvm/bin
AMD clang version 17.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.7.1 23382 f3e174a1d286158c06e4cc8276366b1d4bc0c914)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm-5.7.1/llvm/bin
AMD LLVM version 17.0.0git
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: alderlake

  Registered Targets:
    amdgcn - AMD GCN GPUs
    r600   - AMD GPUs HD2XXX-HD6XXX
    x86    - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64
hip-clang-cxxflags :  -isystem "/opt/rocm-5.7.1/include" -O3
hip-clang-ldflags  :  -O3 --hip-link --rtlib=compiler-rt -unwindlib=libgcc

=== Environment Variables
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/rocm-5.7.1/bin:/opt/rocm-5.7.1/opencl/bin

== Linux Kernel
Hostname     : florin-B660-DS3H-DDR4
Linux florin-B660-DS3H-DDR4 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy

Any idea what I am missing?

Thank you

ochiana commented 1 year ago

Nevermind. I was missing the libomp-dev package.