The framework follows a three-phase workflow:
- Specification Phase: Define task requirements, interface contracts, and correctness criteria
- Generation Phase: Use LLM prompts to generate CUDA kernel implementations
- Validation Phase: Test correctness and measure performance, feeding results back to generation
- Purpose: Define kernel requirements and interface contracts
- Format: YAML for shapes/config, Markdown for specifications
- Examples:
fctd3d/(3D stencil),matmul/(matrix multiplication)
- Purpose: Guide language model to generate correct and optimized kernels
- Components:
system.md: System-level constraints and prioritiestask_template.md: Task-specific generation templatefew_shots.md: Example kernels for few-shot learning
- Purpose: Standardized interface between CPU reference and CUDA kernels
- Key Structures:
dataobj: Multi-dimensional array representationprofiler: Timing instrumentation- Function signatures:
Kernel()(CPU),Kernel_cuda()(CUDA)
- Purpose: Reference implementation and baseline performance
- Components:
- Benchmark harness
- Performance sweeps
- Roofline analysis
- Correctness verification
- Purpose: CUDA kernel development and benchmarking
- Status: Complete
- Components:
- Benchmark harness (
bench_cuda.cpp) - Kernel attempts (
kernels/XXX_name/) - Build system (Makefile)
- Device bandwidth measurement (
dev_bw.cu) - Endpoint-agnostic benchmark runner (
run_benchmark.sh)
- Benchmark harness (
- Purpose: Automated correctness and performance validation
- Categories:
- Correctness: Numerical parity verification
- Performance: Regression detection
- Integration: End-to-end workflow validation
- Purpose: Performance comparison and visualization
- Tools:
- CPU vs GPU comparison
- Stencil visualization
- Performance plotting
Task Spec → LLM Prompt → Generated Kernel
↓
Compilation Test
↓
Correctness Test (vs CPU)
↓
Performance Benchmark
↓
Analysis & Feedback
↓
Next Iteration
- Verify numerical parity before performance optimization
- Prevents incorrect optimizations
- Establishes trust in generated code
- Each optimization attempt in separate directory
- Enables A/B comparison
- Preserves history of optimization attempts
- Correctness tests run automatically
- Performance regression detection
- CI/CD ready structure
- Quantitative performance characterization
- Identifies memory-bound vs compute-bound kernels
- Guides optimization strategy
- Reduces dependencies
- Focuses on kernel optimization
- Easier to integrate into various frameworks
- Create task directory in
tasks/ - Define specification and shapes
- Update prompts if needed
- Add task-specific tests
- Create kernel directory in
cuda/kernels/(once CUDA infrastructure is migrated) - Implement
Kernel_cuda()function - Add to build system
- Run correctness and performance tests
- Add scripts to
analysis/ - Integrate with benchmark output
- Generate visualizations or reports