2021-07-18 15:22:28 -04:00
## Prerequisites
- Install mesa-common-dev
- Either build or install [COMGR ](https://github.com/RadeonOpenCompute/ROCm-CompilerSupport ), [CLANG ](https://github.com/RadeonOpenCompute/llvm-project ) and [Device Library ](https://github.com/RadeonOpenCompute/ROCm-Device-Libs )
2022-03-01 15:17:50 -05:00
## Branch of repository
Before get HIP source code, set the expected branch of repository at the variable HIP_BRANCH.
For example, for ROCm5.0 release branch, set
```
export HIP_BRANCH=rocm-5.0.x
```
ROCm5.1 release branch, set
```
export HIP_BRANCH=rocm-5.1.x
```
Similiar format for future branches.
2021-07-18 15:22:28 -04:00
## Getting the source code
```bash
2022-03-01 15:17:50 -05:00
git clone -b $HIP_BRANCH https://github.com/ROCm-Developer-Tools/hipamd.git
git clone -b $HIP_BRANCH https://github.com/ROCm-Developer-Tools/hip.git
git clone -b $HIP_BRANCH https://github.com/ROCm-Developer-Tools/ROCclr.git
git clone -b $HIP_BRANCH https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime.git
2021-07-18 15:22:28 -04:00
```
## Set the environment variables
```bash
export HIPAMD_DIR = " $( readlink -f hipamd) "
export HIP_DIR = " $( readlink -f hip) "
export ROCclr_DIR = " $( readlink -f ROCclr) "
export OPENCL_DIR = " $( readlink -f ROCm-OpenCL-Runtime) "
```
2021-07-22 19:27:42 +00:00
## Build HIPAMD
2022-03-25 20:35:51 -04:00
2021-07-22 19:27:42 +00:00
Commands to build hipamd are as following,
2022-03-25 20:35:51 -04:00
```bash
cd " $HIPAMD_DIR "
mkdir -p build; cd build
cmake -DHIP_COMMON_DIR= $HIP_DIR -DAMD_OPENCL_PATH= $OPENCL_DIR -DROCCLR_PATH= $ROCCLR_DIR -DCMAKE_PREFIX_PATH= "<ROCM_PATH>/" ..
make -j$( nproc)
sudo make install
```
Please note, HIP_COMMON_DIR looks for hip common ([HIP ](https://github.com/ROCm-Developer-Tools/HIP/ )) source codes.
By default, release version of hipamd is built. hip will be installed to the default path <ROCM_PATH>/hip
2021-07-18 15:22:28 -04:00
2022-03-25 20:35:51 -04:00
Developer can use cmake option CMAKE_INSTALL_PREFIX to define the path where hip is expected to be installed, commands to build are as following,
2021-07-18 15:22:28 -04:00
```bash
cd " $HIPAMD_DIR "
mkdir -p build; cd build
2021-10-04 04:01:28 -07:00
cmake -DHIP_COMMON_DIR= $HIP_DIR -DAMD_OPENCL_PATH= $OPENCL_DIR -DROCCLR_PATH= $ROCCLR_DIR -DCMAKE_PREFIX_PATH= "<ROCM_PATH>/" -DCMAKE_INSTALL_PREFIX= $PWD /install ..
2021-07-18 15:22:28 -04:00
make -j$( nproc)
sudo make install
```
2022-03-25 20:35:51 -04:00
After installation, make sure HIP_PATH is pointed to the path where hip is installed.
2021-07-18 15:22:28 -04:00