HIP Kernel Provider Plugin
A hipDNN plugin that provides GPU kernel implementations using HIP and HIPRTC for runtime kernel compilation.
🚧 This project is under active development 🚧
Overview
The HIP Kernel Provider is a hipDNN plugin that implements operations using custom HIP kernels compiled at runtime via HIPRTC.
Architecture
The plugin follows the standard hipDNN plugin architecture:
HipKernelEngine
├── PlanBuilder (IPlanBuilder)
│ ├── ApplicabilityChecks
│ └── Plan (IPlan)
│ └── execute() - Compile and launch kernel on GPU
└── [Additional plan builders...]
Key Components
- Engines (
src/engines/): High-level operation orchestration- HIP MLops engine (
src/engines/hip_mlops_engine/): Kernel-specific execution logic. Enabled via the compile flagENABLE_HIP_MLOPS_ENGINE(on by default) - ASM SDPA engine (
src/engines/asm_sdpa_engine/): Assembly kernels to do scaled dot-product attention (SDPA). Enabled viaENABLE_ASM_SDPA_ENGINE(on by default)
- HIP MLops engine (
- HIP Infrastructure (
src/hip/): HIPRTC wrapper classes for compilation and execution - Kernels (
kernels/): Device-side kernel source code embedded at build time - Plugin SDK Integration: Implements
IPlan,IPlanBuilder,IEngineinterfaces
Building
This plugin is built as a standalone project outside of the main hipDNN build. It depends on the hipDNN SDK packages (hipdnn_data_sdk and hipdnn_plugin_sdk), which must be available on the system before building.
The SDK packages can come from either:
- Building hipDNN from source (in the
projects/hipdnndirectory of this repository): build hipDNN and runninja installto install the SDK packages. Note that theCMAKE_INSTALL_PREFIXmay need to be set when configuring the hipDNN CMake project if ROCm was not installed to the default/opt/rocmon your system. - A ROCm or TheRock installation that includes hipDNN: the SDK packages are installed as part of the install.
Either approach works as long as the installed SDK version is compatible with the plugin version being built.
Avoiding header conflicts: If you have hipDNN installed system-wide (e.g., from ROCm or TheRock) and also build hipDNN from source in the repository, the two sets of headers may conflict. To avoid this, use
CMAKE_PREFIX_PATHto point at exactly the installation you intend to use:cmake -GNinja -DCMAKE_PREFIX_PATH=<path-to-hipdnn-install> -DCMAKE_CXX_COMPILER=<path-to-amdclang>/clang++ ..
Steps
- Navigate to the
dnn-providers/hip-kernel-providerdirectory. - Make a build directory using
mkdir build && cd build. - Configure the build using
cmake -GNinja -DCMAKE_CXX_COMPILER=<path to amdclang>/clang++ ...- If you would like to enable/disable a specific engine, add the argument
-DENABLE_<engine>=0(example:-DENABLE_ASM_SDPA_ENGINE=0)
- If you would like to enable/disable a specific engine, add the argument
- Finally, run
ninjato build the plugin.
Build Requirements
- hipDNN SDK packages installed (
hipdnn_data_sdk,hipdnn_plugin_sdk) - ROCm with HIP and HIPRTC
- CMake 3.25+
- Ninja build system
- C++17 compatible compiler (amdclang++ recommended)
Testing
After building, run the test suites:
# Unit tests (CPU + basic GPU tests)
./bin/hip_kernel_plugin_tests
# Integration tests (full GPU pipeline tests)
./bin/hip_kernel_plugin_integration_tests
Kernel Embedding System
Kernel source files (.cpp, .hpp, .h) under engines/ are embedded as C++ string literals at CMake configure time. Use the CMake function add_kernels_for_embedding in any engine you define that implements HIP kernels. This allows runtime compilation via HIPRTC while keeping kernel sources as regular C++ files (with syntax highlighting, IDE support, etc.).
The embedding is handled by the embed_kernel_sources() CMake function in src/cmake/KernelEmbedding.cmake.
Contributing
When adding new operations:
- Add kernel sources to
kernels/<operation>/ - Implement plan class inheriting from
IPlan<HipKernelHandle> - Implement plan builder inheriting from
IPlanBuilder<...> - Add applicability checks
- Register plan builder with engine
- Add unit tests for plan builder and plan
- Add integration tests for end-to-end verification
Follow the existing patterns from the codebase.
License
Copyright © Advanced Micro Devices, Inc., or its affiliates. SPDX-License-Identifier: MIT