Beautiful, modular GDB pretty printers for AMD Composable Kernel (CK-Tile) types.
ck_tile::tensor_descriptorck_tile::tensor_adaptorck_tile::tensor_coordinateck_tile::tensor_adaptor_coordinateck_tile::tensor_viewck_tile::tile_distributionck_tile::tile_distribution_encodingck_tile::tile_window(all variants)ck_tile::static_distributed_tensor
git clone <repo-url> /path/to/ck-tile-gdb-printersCopy the example configuration to your home directory and edit the path:
cp /path/to/ck-tile-gdb-printers/examples/example.gdbinit ~/.gdbinitEdit ~/.gdbinit and change this line:
ck_tile_printers_path = '/path/to/ck-tile-gdb-printers' # Update this path!rocgdb ./your_program
source /path/to/ck-tile-gdb-printers/gdbinit_ck_tile.py
endFor optimal debugging experience, you need to compile Composable Kernel with debug symbols. Important: Comment out these lines in CK's CMakeLists.txt:
# Comment out these lines for debug builds:
# add_compile_options(
# "$<$<CONFIG:Debug>:-Og>"
# "$<$<CONFIG:Debug>:-gdwarf64>"
# )Then build with debug flags:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS_DEBUG="-O0 -g -ggdb3 -fno-inline -fno-omit-frame-pointer" \
-DCMAKE_HIP_FLAGS_DEBUG="-O0 -g -ggdb3"
cmake --build build -j$(nproc)rocgdb ./build/bin/your_program
# You should see:
# CK-Tile pretty printers registered successfully
# Registered printers for: tensor_descriptor, tensor_adaptor, ...# Start debugging
rocgdb ./build/bin/my_program
# Set breakpoints at specific lines
(gdb) break filename.hpp:123
(gdb) break /full/path/to/file.hpp:456
# Set breakpoints at functions
(gdb) break my_function
(gdb) break ck_tile::MyClass::operator()
# Run the program
(gdb) run
# When stopped at breakpoint, pretty print CK-Tile types
(gdb) print my_tensor_descriptor
(gdb) print my_tensor_view
# Navigate through execution
(gdb) next # Next line
(gdb) step # Step into functions
(gdb) continue # Continue execution
(gdb) backtrace # Show call stack(gdb) info breakpoints # List all breakpoints
(gdb) break pool_kernel.hpp:377 # Set breakpoint at line 377
(gdb) break main if argc > 1 # Conditional breakpoint
(gdb) disable 1 # Disable breakpoint #1
(gdb) delete 1 # Delete breakpoint #1
(gdb) clear filename:line # Remove breakpoint at locationThe pretty printers also work with VS Code's debugger. See the .vscode/ configuration files in your CK project for setup details.
(gdb) print a_lds_block.desc_
$1 = tensor_descriptor{
element_space_size: 8192
ntransform: 8
ndim_hidden: 13
ndim_top: 2
ndim_bottom: 1
bottom_dimension_ids: [0]
top_dimension_ids: [11, 12]
Transforms:
[0] embed
lower: [0]
upper: [1, 2, 3]
up_lengths: [8, 128, 8]
coefficients: [8, 64, 1]
[1] pass_through
lower: [2, 1]
upper: [4, 5]
up_lengths: [128, 8]
...
}
# Run full regression suite
./tests/run_regression_tests.sh
# Run unit tests
python3 tests/test_cpp_parser.py- Create
gdbinit_ck_tile/printers/my_new_type.py:
from ..core.base_printer import BaseCKTilePrinter
class MyNewTypePrinter(BaseCKTilePrinter):
def to_string(self):
# Your implementation here
return "my_new_type{...}"- Register in
gdbinit_ck_tile.py:
from gdbinit_ck_tile.printers.my_new_type import MyNewTypePrinter
# In build_pretty_printer():
pp.add_printer('my_new_type', '^ck_tile::my_new_type<.*>$', MyNewTypePrinter)- Add tests and run regression suite
gdbinit_ck_tile/
├── core/
│ ├── base_printer.py # Base class for all printers
│ └── transform_mixin.py # Shared transform extraction logic
├── utils/
│ ├── cpp_type_parser.py # C++ template parsing utilities
│ ├── tuple_extractor.py # CK-Tile tuple extraction
│ └── constants.py # Shared constants
└── printers/
├── tensor_descriptor.py # Individual printer modules
├── tensor_adaptor.py
└── ...
[Your license here]
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Run the test suite:
./tests/run_regression_tests.sh - Submit a pull request
Developed for AMD Composable Kernel (CK-Tile) debugging.