Closed YifeiLu-1 closed 4 years ago
I'm also confused by this. Apparently compiling HIP still requires hcc (a bunch of HIP code relies on HCC headers and libraries), but the compilation instructions make it sound as if you can choose between hcc
and clang
, when in reality, both are still necessary, even if you're building hip-clang
. However, hcc
isn't available in the repos anymore, and I don't want to overwrite the installed version of hip-clang
by installing hip-hcc
.
So, basically, the thing I'd appreciate in the instructions are:
hcc
and llvm
are BOTH still required for hip-clang
. (I imagine there is ongoing work to replace HIP's remaining dependencies on the HCC libraries.)hcc
in order to compile HIP without trashing the rest of the ROCm installation. (It's this part that I don't understand myself.)If someone feels like clarifying this, I'd be happy to send in a PR updating the instructions myself--I really need to be able to build a modified version of HIP from source.
If anyone finds it useful, here is the procedure I've been using to build HIP from source, under ROCm 3.5. Of course, the disclaimer is still that I don't know if I'm doing everything right here. However, hipcc
works after these steps, so at least it's a start.
sudo apt install rocm-dev3.5.0 rocm-libs3.5.0 rocm-utils3.5.0
.hcc
sources, and follow the instructions for building it from source. HOWEVER, you do not need to install it to /opt/rocm
. I just install it to a local directory.git clone -b roc-3.5.x https://github.com/ROCm-Developer-Tools/HIP.git
. (After this I make the modifications I want to HIP.)hip-clang
now ships with ROCm 3.5, build and install hip-clang
. Note that I think /opt/rocm/llvm/bin
needs to be on your PATH
for this to work:
cd HIP
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/rocm/hip \
-DHIP_COMPILER=clang \
-DHCC_HOME=<local dir into which you installed hcc> \
..
make
make install
The messaging has been terrible (hcc
was marked as deprecated a long time before there was a replacement: "...we will stop maintaining HCC after its final release, which is planned for June 2019."), and ROCm docs are usually outdated. The reality from where I am sitting (not inside AMD), is that, as of 3.5, you no longer need hcc
. hip-clang
can be built without it using what is sometimes called the VDI
backend, and sometimes called the ROCclr
backend, with variations on the capitalization, and sometimes, as with the actual compiled library, libamdrocclr_static
. Amazingly, the settings you need for hip-clang
are,
HIP_COMPILER=clang
HIP_RUNTIME=ROCclr
HIP_PLATFORM=hcc
So its mixed heritage is still part of today's reality. A minor downside of the change to hip-clang
with 3.5 is that it does, at times, produce slightly slower executables than the old hip-hcc
, but we all hope the new foundations are solid. 3.5 has the additional benefit of not wanting different LLVM builds for OpenCL and HCC, so it's been a definite improvement for those of us building from source.
as of 3.5, you no longer need
hcc
You don't need it to run hipcc
, or HIP programs, but in order to compile HIP, I still think you need HCC. For example, hip_hcc_internal.h
is still used for hip-clang
, and it #include
s hc.hpp
and uses several structures from HCC's libraries, such as hc::accelerator_view
. I'm not aware of any way to get these necessary definitions apart from setting up hcc
, and these are used regardless of whether you're building hip-clang
or hip-hcc
. After compiling HIP, however, you don't need hcc
any more.
Those includes come from source files added in a branch of CMakeLists.txt
that you can actually disable. In the NixOS build, we manually patch them out. It's entirely possible that I'm misunderstanding my own build as I only did the 3.5 packaging recently, but we'll bump our CI from 3.3 to 3.5 soon to see for sure.
ETA: Part of the reason the build is so confused is that hipconfig
needs HIP_PLATFORM
to be hcc
, but elsewhere in the build we do not want that setting since we do not want to build hip_hcc
.
Oh, I see, thanks. Somehow, I completely missed that all of those definitions are now in the rocclr
directory (I didn't think to look somewhere other than src/
). In either case, I guess the takeaway is simply that INSTALL.md
could use some freshening up, especially the cmake flags for the hip-clang
build.
In ROCm3.5 HIP has migrated to HIP/ROCclr (which was called HIP/VDI before). It does not depend on HCC. The mater branch of this repo is outdated. You need to use 3.5.x branch to build HIP/ROCclr. The build instruction is also outdated. Please follow https://github.com/ROCm-Developer-Tools/ROCclr/tree/roc-3.5.x for building HIP/ROCclr.
Please try following instructions to build ROCm3.5 sources. These should work.
git clone -b roc-3.5.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)" git clone -b roc-3.5.x https://github.com/ROCm-Developer-Tools/ROCclr.git export ROCCLR_DIR="$(readlink -f ROCclr)" git clone -b roc-3.5.x https://github.com/ROCm-Developer-Tools/HIP.git
//Build ROCclr
mkdir -p ROCclr/build
cd ROCclr/build
cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX=
//Build HIP
mkdir -p HIP/build
cd HIP/build
cmake -DHIP_COMPILER=clang -DHIP_PLATFORM=rocclr -DROCclr_DIR="$ROCCLR_DIR" -DLIBROCclr_STATIC_DIR="$ROCCLR_DIR/build" -DCMAKE_INSTALL_PREFIX=
@gargrahul Does the HIP_PLATFORM eq “hcc”
guard in hipconfig around some hip-clang
configuration not apply?
Please try following instructions to build ROCm3.5 sources. These should work.
git clone -b roc-3.5.x https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git export OPENCL_DIR="$(readlink -f ROCm-OpenCL-Runtime)" git clone -b roc-3.5.x https://github.com/ROCm-Developer-Tools/ROCclr.git export ROCCLR_DIR="$(readlink -f ROCclr)" git clone -b roc-3.5.x https://github.com/ROCm-Developer-Tools/HIP.git
//Build ROCclr mkdir -p ROCclr/build cd ROCclr/build cmake -DOPENCL_DIR="$OPENCL_DIR" -DCMAKE_INSTALL_PREFIX= .. make make install
//Build HIP mkdir -p HIP/build cd HIP/build cmake -DHIP_COMPILER=clang -DHIP_PLATFORM=rocclr -DROCclr_DIR="$ROCCLR_DIR" -DLIBROCclr_STATIC_DIR="$ROCCLR_DIR/build" -DCMAKE_INSTALL_PREFIX= .. make make install
These scripts worked for me. Thanks for the help.
I can’t explain why @gargrahul doesn’t encounter that guard I linked to, but we do have ROCm 3.5’s hip-clang
building in CI and pushed to a binary cache for NixOS users now.
@acowley In ROCm 3.5 HIP_PLATFORM=rocclr
only applies to the HIP cmake build steps. The rest of the binaries (such as hipcc, hipconfig) still treat it HIP_PLATFORM
as hcc due to legacy reasons. Ideally HIP_PLATFORM should have been amd and nvidia. This cleanup will happen in a future release. Till then assume that when hipcc and hipconfig refer to HIP_PLATFORM=hcc
, they actually mean HIP_PLATFORM=amd
.
Also FYI the patch release ROCm 3.5.1 has updated the build and install instructions via commit f941b38.
ROCm 3.5 release notes. HIP installation guide.
I'm confused. Shall I build the "experiment" HIP-clang or the deprecated HIP-hcc?