Skip to main content

trueno_explain/
lib.rs

1//! trueno-explain: PTX/SIMD/wgpu Visualization and Tracing CLI
2//!
3//! A CLI tool that visualizes and traces code generation flows across
4//! Trueno's execution targets. Implements the Toyota Way principle of
5//! **Genchi Genbutsu** (Go and See) by making invisible compiler
6//! transformations visible.
7//!
8//! # Features
9//!
10//! - PTX register pressure analysis
11//! - Memory access pattern detection
12//! - Warp divergence visualization (Heijunka)
13//! - Muda (waste) detection and elimination suggestions
14//!
15//! # Example
16//!
17//! ```rust
18//! use trueno_explain::ptx::PtxAnalyzer;
19//! use trueno_explain::analyzer::Analyzer;
20//!
21//! let ptx = r#"
22//!     .entry test() {
23//!         .reg .f32 %f<16>;
24//!         ret;
25//!     }
26//! "#;
27//!
28//! let analyzer = PtxAnalyzer::new();
29//! let report = analyzer.analyze(ptx).expect("PTX analysis should succeed");
30//! assert_eq!(report.registers.f32_regs, 16);
31//! ```
32
33// Allow some pedantic lints for this CLI tool
34#![cfg_attr(test, allow(clippy::disallowed_methods))] // Tests use unwrap() freely
35#![cfg_attr(test, allow(clippy::float_cmp))] // Tests compare exact float values
36#![allow(clippy::cast_precision_loss)] // Acceptable for display percentages
37#![allow(clippy::cast_possible_truncation)] // Instruction counts won't exceed u32
38#![allow(clippy::format_push_string)] // Performance not critical for CLI
39#![allow(clippy::too_many_lines)] // Will refactor in future sprints
40#![allow(clippy::unwrap_used)] // Safe for compile-time constant regex
41#![allow(clippy::unused_self)] // Methods may need self for future extensibility
42#![allow(clippy::map_unwrap_or)] // Style preference
43#![allow(clippy::unnecessary_literal_bound)] // Trait signature constraint
44
45pub mod analyzer;
46pub mod compare;
47pub mod diff;
48pub mod error;
49pub mod output;
50pub mod ptx;
51pub mod simd;
52pub mod tui;
53pub mod wgpu;
54
55pub use analyzer::{AnalysisReport, Analyzer, MudaWarning, RegisterUsage};
56pub use compare::{compare_analyses, format_comparison_json, format_comparison_text};
57pub use diff::{compare_reports, format_diff_json, format_diff_text, DiffReport, DiffThresholds};
58pub use error::{ExplainError, Result};
59pub use output::{format_json, format_text, OutputFormat};
60pub use ptx::{
61    BugSeverity, PtxAnalyzer, PtxBug, PtxBugAnalyzer, PtxBugClass, PtxBugReport, PtxCoverageReport,
62    PtxCoverageTracker, PtxCoverageTrackerBuilder, PtxFeature,
63};
64pub use simd::{SimdAnalyzer, SimdArch, SimdInstructionCounts};
65pub use tui::{run_tui, TuiApp};
66pub use wgpu::{WgpuAnalyzer, WorkgroupSize};