ROCm / ROCm-OpenCL-Runtime

ROCm OpenOpenCL Runtime
166 stars 60 forks source link

Cannot find "elfio" include directory with CMake #139

Closed dipietrantonio closed 1 year ago

dipietrantonio commented 3 years ago

I am trying to build this project (ROCm-OpenCL-Runtime), but it seems there is an issue with the cmake package. The directory "/opt/rocm-dev/rocclr/include/elf/elfio" is not included in the search path for header files, although I couldn't pinpoint where to add this in the CMake file.

Here is the error I get.

-- ROCclr at /opt/rocm-dev/rocclr/lib/cmake/rocclr
-- Looking for secure_getenv
[..]
[ 43%] Built target icd_loader_test
Scanning dependencies of target amdocl64
[ 43%] Building CXX object amdocl/CMakeFiles/amdocl64.dir/cl_memobj.cpp.o
In file included from /opt/rocm-dev/rocclr/include/elf/elf.hpp:31,
                 from /opt/rocm-dev/rocclr/include/device/device.hpp:32,
                 from /opt/rocm-dev/rocclr/include/platform/context.hpp:25,
                 from /opt/rocm-dev/rocclr/include/platform/command.hpp:36,
                 from /opt/rocm-dev/rocclr/include/vdi_common.hpp:26,
                 from /home/ubuntu/ROCm-OpenCL-Runtime-rocm-4.3.1/amdocl/cl_common.hpp:32,
                 from /home/ubuntu/ROCm-OpenCL-Runtime-rocm-4.3.1/amdocl/cl_memobj.cpp:21:
/opt/rocm-dev/rocclr/include/elf/elfio/elfio.hpp:43:10: fatal error: elfio/elf_types.hpp: No such file or directory
   43 | #include <elfio/elf_types.hpp>

Maybe it is something that has to be fixed in the ROCclr repo?

vsytch commented 3 years ago

Hello there, rocclr is no longer a standalone project, so it shouldn't be installed anywhere. It is now built as part of OpenCL/HIP. If you have the opencl and rocclr projects cloned at the same level, CMake should be able to find it automatically (see https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/blob/develop/amdocl/cmake/FindROCclr.cmake#L25).

dipietrantonio commented 3 years ago

HI @vsytch, according to the build instructions on the ROCclr and ROCm-OpenCL-Runtime, ROCclr must be built first. Anyway, I have tried your suggestion but it does not work. Here is what I do,

# ROCclr is needed by HIP and OpenCL
# see issue https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/issues/139
cd $ROOT_BUILD_DIR
rm * -rf
run_command wget https://github.com/ROCm-Developer-Tools/ROCclr/archive/refs/tags/rocm-${ROCM_VERSION}.tar.gz  
run_command tar -xf rocm-${ROCM_VERSION}.tar.gz
rm rocm-${ROCM_VERSION}.tar.gz
mv ROCclr-rocm-${ROCM_VERSION} ROCclr
ROCCLR_PATH=`pwd`/ROCclr #-rocm-${ROCM_VERSION}

# install opencl runtime
run_command wget https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/refs/tags/rocm-${ROCM_VERSION}.tar.gz 
run_command tar -xf rocm-${ROCM_VERSION}.tar.gz
rm rocm-${ROCM_VERSION}.tar.gz
cd ROCm-OpenCL-Runtime-rocm-${ROCM_VERSION}
mkdir build && cd build
export ROCclr_DIR=$ROCCLR_PATH
export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:$ROCCLR_PATH
run_command cmake -DCMAKE_BUILD_TYPE=Release -DUSE_COMGR_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=$ROCM_INSTALL_DIR -DROCclr_DIR=$ROCCLR_PATH ..
run_command make -j$NCORES install

And what I get is

Running command cmake -DCMAKE_BUILD_TYPE=Release -DUSE_COMGR_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=/opt/rocm-dev -DROCclr_DIR=/root/rocm-build/ROCclr ..
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- LINK_COMGR_STATIC :OFF
-- Code Object Manager found at /opt/rocm-dev/lib/cmake/amd_comgr.
CMake Error at CMakeLists.txt:68 (find_package):
  Could not find a package configuration file provided by "ROCclr" with any
  of the following names:

    ROCclrConfig.cmake
    rocclr-config.cmake

  Add the installation prefix of "ROCclr" to CMAKE_PREFIX_PATH or set
  "ROCclr_DIR" to a directory containing one of the above files.  If "ROCclr"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
See also "/root/rocm-build/ROCm-OpenCL-Runtime-rocm-4.3.1/build/CMakeFiles/CMakeOutput.log".
See also "/root/rocm-build/ROCm-OpenCL-Runtime-rocm-4.3.1/build/CMakeFiles/CMakeError.log".
Error running a command: cmake -DCMAKE_BUILD_TYPE=Release -DUSE_COMGR_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=/opt/rocm-dev -DROCclr_DIR=/root/rocm-build/ROCclr ..

Whereas the following sequence of commands works

export CPATH=$ROCM_INSTALL_DIR/rocclr/include/elf:$CPATH
# get the opencl runtime
run_command wget https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/refs/tags/rocm-${ROCM_VERSION}.tar.gz 
run_command tar -xf rocm-${ROCM_VERSION}.tar.gz
rm rocm-${ROCM_VERSION}.tar.gz
export OPENCL_DIR=`pwd`/ROCm-OpenCL-Runtime-rocm-${ROCM_VERSION}

# ROCclr is needed by HIP and OpenCL
# see issue https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/issues/139
run_command wget https://github.com/ROCm-Developer-Tools/ROCclr/archive/refs/tags/rocm-${ROCM_VERSION}.tar.gz  
run_command tar -xf rocm-${ROCM_VERSION}.tar.gz
rm rocm-${ROCM_VERSION}.tar.gz
cd ROCclr-rocm-${ROCM_VERSION}
mkdir build && cd build
run_command cmake -DOPENCL_DIR=$OPENCL_DIR -DCMAKE_INSTALL_PREFIX=$ROCM_INSTALL_DIR/rocclr .. 
run_command make -j$NCORES install

# install opencl runtime
cd $OPENCL_DIR
run_command mkdir -p /etc/OpenCL/vendors/
run_command cp config/amdocl64.icd /etc/OpenCL/vendors/
mkdir build && cd build
run_command cmake -DCMAKE_BUILD_TYPE=Release -DUSE_COMGR_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=$ROCM_INSTALL_DIR ..
run_command make -j$NCORES install