HIP
HIP copied to clipboard
[Issue]: Fails to compile: Hardcoded path to hsa.
Problem Description
Try to compile this with hsa headers located in /opt/rocm/include/hsa.
It will not compile, failing to find said headers. This is due to clr/hipamd/src/hip_embed_pch.sh, which forces a bunch of hard-coded compiles instead of using a cmakelists file. It ignores -DCMAKE_CXX_FLAGS, forgetting to pass them on.
It's missing options to set where ROCM headers are or ignores it entirely when called via cmake. Either way, does not compile out of the box. Variables are forgotten and the thing just assumes the defaults are defined and work (which they aren't, paths to libraries can vary!)
Operating System
Anything linux that is not ubuntu 24
CPU
Any CPU
GPU
AMD Instinct MI300X, AMD Instinct MI300A, AMD Instinct MI250X, AMD Instinct MI250, AMD Instinct MI210, AMD Instinct MI100, AMD Radeon Pro W7900, AMD Radeon Pro W6800, AMD Radeon Pro V620, AMD Radeon Pro VII, AMD Radeon RX 7900 XTX, AMD Radeon RX 7900 XT, AMD Radeon VII
ROCm Version
ROCm 6.1.0, ROCm 6.0.0
ROCm Component
No response
Steps to Reproduce
This is how to reproduce, assuming we have the dependencies; Note; variable values; Note 2: Assuming llvm,roctracer, rocprofiler, hsaprofile, rocr-runtime, rocprofiler-register,rocm-runtime-libs are already compiled.
export ROCM_INSTALL_DIR=/opt/rocm
export BASEDIR=~/src/rocm
cd $BASEDIR
DEST=$BASEDIR/09_hip/output
mkdir -p $BASEDIR/09_hip
mkdir -p $DEST
cd $BASEDIR/09_hip
DEST=$BASEDIR/09_hip/build
git clone https://github.com/ROCm/hip
git clone https://github.com/ROCm/clr
cd hip
git checkout master
cd ..
BUILD_DIR=$BASEDIR/09_hip/build
mkdir -p $BUILD_DIR
mkdir -p hipcc
cd hipcc
cmake \
-Wno-dev \
-DCMAKE_BUILD_TYPE=None \
$LLVMAMD/hipcc
cmake --build .
export HIP_PATH=$ROCM_INSTALL_DIR
export HSA_RUNTIME_INC=$ROCM_INSTALL_DIR/include/hsa/hsa.h
OPT_PROF_API=""
PROF_API_STR="$BASEDIR/09_hip/clr/hipamd/include/hip/amd_detail/hip_prof_str.h"
PROF_API_HDR="$BASEDIR/09_hip/hip/include/hip/hip_runtime_api.h"
PROF_API_SRC="$BASEDIR/09_hip/clr/hipamd/src"
PROF_API_LOG="$BASEDIR/09_hip/build/hip_prof_gen_log.txt"
PROF_API_STR_NEW="$BASEDIR/09_hip/clr/hipamd/include/hip/amd_detail/hip_prof_str.h.new"
# set(PROF_API_CMD "${PROF_API_GEN} -v ${OPT_PROF_API} ${PROF_API_HDR} ${PROF_API_SRC} ${PROF_API_STR} >${PROF_API_LOG}")
python $BASEDIR/09_hip/clr/hipamd/src/hip_prof_gen.py -v ${OPT_PROF_API} ${PROF_API_HDR} ${PROF_API_SRC} ${PROF_API_STR} ${PROF_API_STR_NEW} >${PROF_API_LOG}
#
# -B $BASEDIR/09_hip/build \
# Because C++ compilers suck at finding stuff.
mkdir -p "$BASEDIR/09_hip/hip/hsa";
rsync -av "/opt/rocm/include/hsa/hsa.h" "$BASEDIR/09_hip/hip/hsa/hsa.h";
mkdir -p "$BASEDIR/09_hip/hip/include/hip/hcc_detail/hsa/"
rsync -av "/opt/rocm/include/hsa/hsa.h" "$BASEDIR/09_hip/hip/include/hip/hcc_detail/hsa/hsa.h";
cd $BASEDIR/09_hip/clr
export HSA_PATH="/opt/rocm/include/hsa/"
export ROCM_PATH="/opt/rocm/"
cmake \
-Wno-dev \
-G Ninja \
-DCMAKE_CXX_FLAGS="-isystem /opt/rocm/include/" \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_PREFIX_PATH="/opt/rocm/" \
-DCMAKE_INSTALL_PREFIX=${ROCM_INSTALL_DIR} \
-DHIP_COMMON_DIR="$BASEDIR/09_hip/hip" \
-DHIPCC_BIN_DIR="$BASEDIR/09_hip/hipcc" \
-DROCCLR_PATH="$BASEDIR/09_hip/clr" \
-DPROF_API_HEADER_PATH="${ROCM_INSTALL_DIR}/include/roctracer/ext/" \
-DHIP_CATCH_TEST=0 \
-DHIP_PLATFORM=amd \
-DCLR_BUILD_HIP=ON \
-DCLR_BUILD_OCL=OFF \
-DHSA_PATH="/opt/rocm/include/hsa" \
$BASEDIR/09_hip/clr
Expected output: compilation. Got output;
09_hip/hip/include/hip/hcc_detail/hip_runtime_api.h:48:10: error: 'hsa/hsa.h' file not found with <angled> include; use "quotes" instead
(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support
No response
Additional Information
No response
Note: This can be solved by hard-copying the headers (or linking them in) like so;
mkdir -p "$BASEDIR/09_hip/hip/hsa";
rsync -av "/opt/rocm/include/hsa/hsa.h" "$BASEDIR/09_hip/hip/hsa/hsa.h";
mkdir -p "$BASEDIR/09_hip/hip/include/hip/hcc_detail/hsa/"
rsync -av "/opt/rocm/include/hsa/hsa.h" "$BASEDIR/09_hip/hip/include/hip/hcc_detail/hsa/hsa.h";
mkdir -p "$BASEDIR/09_hip/clr/hipamd/include/hsa/"
rsync -av "/opt/rocm/include/hsa/hsa.h" "$BASEDIR/09_hip/clr/hipamd/include/hsa/hsa.h";
rsync -av "/opt/rocm/include/hsa/amd_hsa_kernel_code.h" "$BASEDIR/09_hip/clr/hipamd/include/hsa/amd_hsa_kernel_code.h";
rsync -av "/opt/rocm/include/hsa/amd_hsa_common.h" "$BASEDIR/09_hip/clr/hipamd/include/hsa/amd_hsa_common.h";
rsync -av "/opt/rocm/include/hsa/hsa_ext_amd.h" "$BASEDIR/09_hip/clr/hipamd/include/hsa/hsa_ext_amd.h";
rsync -av "/opt/rocm/include/hsa/hsa_ext_image.h" "$BASEDIR/09_hip/clr/hipamd/include/hsa/hsa_ext_image.h";
rsync -av "/opt/rocm/include/hsa/hsa_ven_amd_loader.h" "$BASEDIR/09_hip/clr/hipamd/include/hsa/hsa_ven_amd_loader.h";
Hi @AphidGit, internal ticket has been created to investigate your issue. Thanks!
Hi @AphidGit,
It looks like there is an issue with the compiler looking inside of the wrong directory for the hsa related header files. It may be related to the compiler trying to look for hsa/hsa.h within HSA_PATH so it may be trying to include hsa/hsa/hsa.h instead of hsa/hsa.h.
I was however able to build HIP from source instead by following the instructions available here: Build HIP From Source. One thing to mention is that it is missing the dependency for llvm so run: sudo apt install rocm-llvm-dev. Could you give these instructions a try and let me know if you run into any issues? Thanks!
Hi @AphidGit,
I'm going to close this ticket due to inactivity, but please feel free to open it again if the issue persists, thanks!