Files
composable_kernel/script/tools/README_ck-docker.md
Max Podkorytov 086a1f8861 Add LLM-agnostic Docker and build analysis tools (#3576)
This commit introduces utility tools for building, testing, and analyzing
Composable Kernel. The tools are designed to be LLM-agnostic and can be
used with any AI assistant or directly from the command line.

Tools Added:
============

1. ck-docker - Docker container management
   - Start/stop ROCm-enabled containers
   - Build targets with CMake + Ninja
   - Run tests with gtest filters
   - Auto-detect GPU targets (gfx950, gfx942, etc.)
   - Per-user, per-branch container naming to avoid conflicts

2. ck-build-analysis - Build time profiling
   - Uses Clang's -ftime-trace for compilation analysis
   - Aggregates statistics across multiple trace files
   - Identifies template instantiation bottlenecks
   - Generates detailed Markdown reports with:
     * Compilation phase breakdown
     * Top expensive instantiations
     * Template family analysis
     * Data-driven optimization recommendations
   - Configurable granularity (1µs to 500µs)
   - PEP 723 compliant Python script with auto-dependency management via uv

Key Features:
=============

- LLM-agnostic design (works with any AI assistant)
- Zero-configuration setup with automatic dependency installation
- Comprehensive documentation in script/tools/README*.md
- Security hardening (input validation, no command injection)
- Multi-file trace aggregation for accurate build analysis
- Jinja2-based report generation for customizable output

Implementation:
===============

- script/tools/ck-docker - Main Docker orchestration script
- script/tools/ck-build-analysis - Build analysis orchestration
- script/tools/common.sh - Shared utilities (container mgmt, GPU detection)
- script/tools/analyze_build_trace.py - PEP 723 compliant Python analyzer
- script/tools/templates/ - Jinja2 templates for report generation
- script/tools/README*.md - Comprehensive documentation

Directory Structure:
====================

script/tools/
├── README.md                          # Main overview
├── README_ck-docker.md                # ck-docker documentation
├── README_ck-build-analysis.md        # ck-build-analysis documentation
├── ck-docker                          # Docker orchestration script
├── ck-build-analysis                  # Build analysis orchestration
├── common.sh                          # Shared utilities
├── analyze_build_trace.py             # Python analyzer (PEP 723)
└── templates/
    └── build_analysis_report.md.jinja # Report template

The tools follow Unix philosophy: do one thing well, compose easily,
and work from both CLI and programmatic contexts.
2026-01-15 08:30:23 -08:00

81 lines
2.1 KiB
Markdown

# ck-docker
Build and test composable_kernel in Docker with ROCm support.
## Terminal Usage
Direct command-line usage:
```bash
# From composable_kernel directory
script/tools/ck-docker start
script/tools/ck-docker build test_amdgcn_mma
script/tools/ck-docker test test_amdgcn_mma --gtest_filter=*Fp16*
script/tools/ck-docker status
script/tools/ck-docker shell
# Or add to PATH
export PATH="$PATH:$PWD/script/tools"
ck-docker start
```
## LLM Assistant Integration
If using an LLM assistant, you can ask in natural language:
- "Start the docker container"
- "Build test_amdgcn_mma"
- "Run test_amdgcn_mma with filter *Fp16*"
- "Check container status"
- "Open a shell in the container"
## Commands
```
ck-docker start [name] Start Docker container
ck-docker build [target] [--reconfigure] Build target (optionally reconfigure CMake)
ck-docker test <name> [options] Run test
ck-docker shell [name] Interactive shell
ck-docker status [name] Check status
ck-docker stop [name] Stop container
```
## Configuration
- **Image**: rocm/composable_kernel:ck_ub24.04_rocm7.0.1
- **GPU**: Auto-detected via rocminfo (fallback: gfx950)
- **Compiler**: /opt/rocm/llvm/bin/clang++
- **Build**: Ninja + CMake (Release)
- **Mount**: Current directory → /workspace
- **Container Name**: Auto-generated as `ck_<username>_<branch>` to avoid clashes
## Environment
```bash
export CK_CONTAINER_NAME=my_build # Override default container name
export CK_DOCKER_IMAGE=rocm/composable_kernel:ck_ub24.04_rocm7.0.1 # Override Docker image
export GPU_TARGET=gfx942 # Override GPU target detection
```
## Examples
```bash
# Start container
ck-docker start
# Build and run test
ck-docker build test_amdgcn_mma
ck-docker test test_amdgcn_mma
# Force clean CMake reconfiguration and build
ck-docker build --reconfigure test_amdgcn_mma
# Custom container
ck-docker start my_build
ck-docker build test_amdgcn_mma --name my_build
ck-docker test test_amdgcn_mma --name my_build
# Debug
ck-docker shell
ck-docker status
```