This tutorial shows how to use the Microsoft Visual C++ Compiler on Windows to build the HIP CPU Runtime. It does not delve into the details of HIP, the C++ language or the Microsoft C++ toolset.
If you encounter any difficulties, please create an issue for this tutorial.
To successfully complete this tutorial, the following steps are necessary:
- Install the Microsoft Visual C++ (MSVC) compiler toolset:
- If you have a recent version of Visual Studio, launch the Visual Studio Installer and ensure that the C++ workload is enabled. If it is not, check the relevant box and select Modify in the installer;
- Alternatively, you can install only the C++ Build Tools without a full
Visual Studio IDE installation. From the Visual Studio Downloads
page, select the download for Build Tools for Visual Studio under the
All Downloads/Tools for Visual Studio entry, and execute the
downloaded file;
- This shall launch the Visual Studio Installer; under the available Visual Studio Build Tools workloads pick C++ Build Tools and select Install;
- Note that at the moment it appears that the above flow for downloading the installer is broken, therefore please consider using the direct download
- Install latest CMake
- Install Git
git clone https://github.com/ROCm-Developer-Tools/HIP-CPU.git
cd HIP-CPU
mkdir build
cd build
cmake ../
cmake --build ./
rem Assumes that you are in the build folder created in the build step.
cmake --build ./ --target install
rem Assumes that you are in the build folder created in the build step.
ctest --output-on-failure
To use any of the HIP public interfaces include the hip/hip_runtime.h
header.
- If you are working with CMake, link against the convenience
INTERFACE
targethip_cpu_rt::hip_cpu_rt
, which is exported by the HIP CPU Runtime, which can be queried byfind_package(hip_cpu_rt)
; - If you are not working with CMake, add either
/path_where_you_cloned_the_hip_cpu_runtime/include
or, if you installed it,/path_where_you_installed_the_hip_cpu_runtime/include
to your include path. - For potentially enhanced vectorisation, consider adding
/openmp:experimental
to your compiler flags, as this will allow the back-end to (eventually) be more aggressive in vectorising HIP code.