HIP RT is a ray tracing library for HIP, making it easy to write ray-tracing applications in HIP. The APIs and library are designed to be minimal, lower level, and simple to use and integrate into any existing HIP applications.
Although there are other ray tracing APIs which introduce many new things, we designed HIP RT in a slightly different way so you do not need to learn many new kernel types.
Released binaries can be found at HIP RT page under GPUOpen. HIP RT library is developed and maintained by ARR, Advanced Rendering Research Group.
This is the main repository for the source code for HIPRT.
git clone https://github.com/GPUOpen-LibrariesAndSDKs/HIPRT.gitcd HIPRTgit submodule update --init --recursivegit lfs fetch(To get resources for running performance tests)
Then, you can use either premake or cmake.
On Windows with premake:
5. set HIP_PATH=C:\Program Files\AMD\ROCm\6.2\ (optional: change default HIP SDK path)
6. .\tools\premake5\win\premake5.exe vs2022
7. Open build\hiprt.sln with Visual Studio 2022.
On Linux with premake:
5. export HIP_PATH=/opt/rocm (optional: change default HIP SDK path)
6. ./tools/premake5/linux64/premake5 gmake
7. make -C build -j config=release_x64
Example with Cmake on Windows:
5. mkdir build
6. cmake -DCMAKE_BUILD_TYPE=Release -DBITCODE=OFF -DHIP_PATH="C:\Program Files\AMD\ROCm\5.7" -S . -B build
7. Open build\hiprt.sln with Visual Studio 2022.
Example with Cmake on Linux:
5. mkdir build
6. cmake -DCMAKE_BUILD_TYPE=Release -DBITCODE=OFF -DHIP_PATH="/opt/rocm" -S . -B build
7. cmake --build build --config Release
Add the option --bitcode in premake, or -DBITCODE=ON in cmake to enable precompiled bitcode.
- After premake, go to
scripts/bitcodes, then runpython compile.pywhich compiles kernels to bitcode and fatbinary. - Or pass
--precompileto premake, or-DPRECOMPILE=ONin cmake . It executes thecompile.pyduring premake. Note that you cannot do it in git bash on windows (because of hipcc...)
There are three types of tests.
- HiprtTests - tests covering all basic features.
- ObjTestCases - tests with loading meshes and testing advanced features like shadow/ AO.
- PerformanceTestCases - tests with complex mesh to test performance features.
Example: ..\dist\bin\Release\unittest64.exe --width=512 --height=512 --referencePath=.\references\ --gtest_filter=hiprt*:Obj*"
- Clone
hipSdkrepo to the root directory. - Go to
scripts/bitcodes, runpython compile.pywhich useshipccfrom thehipSdkdirectory. (todo. make it more general, maybe search forhipccfrom path, if it's not found, use the directory above or something like this)- Note use python version 3.*+.
- Git bash shell is not supported for compile.py.
- Resolve compiler warnings.
- Use lower camel case for variable names (e.g.,
nodeCount) and upper camel case for constants (e.g.,LogSize). - Separate functions by one line.
- Use prefix
m_for non-static member variables. - Do not use static local variables.
- Do not use
voidfor functions without arguments (leave it blank). - Do not use blocks without any reason.
- Use references instead of pointers if possible.
- Use bit-fields instead of explicit bit masking if possible.
- Use
nullptrinstead ofNULLor zero. - Use C++-style casts (e.g.,
static_cast) instead of C-style cast. - Add
constfor references and pointers if they are not being changed. - Add
constexprfor variables and functions if they can be constant in compile time (do not use#defineif possible). - Use
if constsexprinstead of#ifdefif possible. - Throw
std::runtime_errorwith an appropriate message in case of failure in the core and catch it inhiprt.cpp.
- Use
std::stringinstead of C strings (i.e.,char*) and avoid C string functions as much as possible. - Use
std::coutandstd::cerrinstead ofprintf. - Do not assign
char8_t(orstd::u8string) tochar(orstd::string). They will not be compatible in C++20.
- Use
std::ifstreamandstd::ofstreaminstead ofFILE. - Use
std::filesystem::pathfor files and paths instead ofstd::string.
- Use the in-class initializer instead of the default constructor.
- Use the keyword
overrideinstead ofvirtual(or nothing) when overriding a virtual function from the base class.- Reason: The
overridekeyword can help prevent bugs by producing compilation errors when the intended override is not actually implemented as an override. For example, when the function type is not exactly identical to the base class function. This can be caused by mistakes or if the virtual functions in the base class are changed due to refactor.
- Reason: The
- Use
std::optionalinstead of pointers for optional parameters.- Reason:
std::optionalguarantees that no auxiliary memory allocation is needed. Meaning, it does not involve dynamic memory allocation & deallocation on the heap, which results in better performance and less memory overhead.
- Reason:
- A base class destructor should be either public and virtual, or protected and non-virtual
- Reason: This is to prevent undefined behavior. If the destructor is public, then the calling code can attempt to destroy a derived class object/instance through a base class pointer, and the result is undefined if the base class’s destructor is non-virtual.
- Implement the customized {copy/move} {constructor/assignment operator} if an user-defined destructor of a class is needed, or remove them using
= delete- Reason: Rule of five
- When we update the master branch, we need to update the version number of hiprt in
version.txt. - If there is a change in the API, you need to update minor version.
- If the major and minor versions matches, the binaries are compatible.
- Each commit in the master should have a unique patch version.