use super::fixtures::*;
use crate::commands;
use crate::db::GpuDb;
use rusqlite::params;
#[test]
fn smoke_all_commands() {
let mut db = build_session();
commands::cmd_stats(&db);
commands::cmd_layers(&db);
commands::cmd_suggest(&db);
commands::cmd_kernels(&db, &[]);
commands::cmd_kernels(&db, &["3"]);
commands::cmd_kernels(&db, &["5", "sgemm"]);
commands::cmd_kernels(&db, &["cutlass"]);
commands::cmd_ops(&db, &[]);
commands::cmd_ops(&db, &["5", "linear"]);
commands::cmd_top_ops(&db, &[]);
commands::cmd_top_ops(&db, &["3", "aten"]);
commands::cmd_compare_ops(&db, &[]);
commands::cmd_hotpath(&db);
commands::cmd_inspect(&db, &["sgemm"]);
commands::cmd_inspect(&db, &["cutlass"]);
commands::cmd_bound(&db, &["sgemm"]);
commands::cmd_bound(&db, &["cutlass"]);
commands::cmd_trace(&db, &["linear"]);
commands::cmd_callers(&db, &["sgemm"]);
commands::cmd_breakdown(&db, &["linear"]);
commands::cmd_breakdown(&db, &["batch_norm"]);
commands::cmd_roofline(&db, &[]);
commands::cmd_roofline(&db, &["sgemm"]);
commands::cmd_occupancy(&db, &[]);
commands::cmd_variance(&db, &["bn_fw"]);
commands::cmd_warmup(&db);
commands::cmd_small(&db, &[]);
commands::cmd_fuse(&db, &[]);
commands::cmd_concurrency(&db);
commands::cmd_transfers(&db, &[]);
commands::cmd_gaps(&db, &[]);
commands::cmd_overlap(&db);
commands::cmd_streams(&db);
commands::cmd_timeline(&db, &[]);
commands::cmd_idle_between(&db, &["linear", "batch_norm"]);
commands::cmd_focus(&mut db, &["cutlass"]);
commands::cmd_kernels(&db, &[]); commands::cmd_ignore(&mut db, &["sgemm"]);
commands::cmd_kernels(&db, &[]);
commands::cmd_region(&mut db, &["Step#1"]);
commands::cmd_kernels(&db, &[]); commands::cmd_region(&mut db, &[]); commands::cmd_reset(&mut db);
commands::cmd_kernels(&db, &[]);
commands::cmd_bandwidth(&db, &[]);
commands::cmd_bandwidth(&db, &["3"]);
commands::cmd_bandwidth(&db, &["5", "sgemm"]);
commands::cmd_critical_path(&db, &[]);
commands::cmd_critical_path(&db, &["50"]);
commands::cmd_stream_graph(&db, &[]);
commands::cmd_stream_graph(&db, &["60"]);
commands::cmd_hotspot(&db, &[]); commands::cmd_hotspot(&db, &["10000"]);
commands::cmd_hotspot(&db, &["500"]); commands::cmd_launches(&db, &[]); commands::cmd_launches(&db, &["sgemm"]);
commands::cmd_launches(&db, &["cutlass", "3"]);
commands::cmd_launches(&db, &["nonexistent_kernel_xyz"]);
commands::cmd_compare(&db, &["sgemm"]); commands::cmd_compare(&db, &["sgemm", "cutlass"]);
commands::cmd_compare(&db, &["sgemm", "nonexistent_xyz"]);
commands::cmd_regressions(&db, &[]);
commands::cmd_inspect(&db, &["nonexistent_kernel_xyz"]);
commands::cmd_bound(&db, &["nonexistent_kernel_xyz"]);
commands::cmd_trace(&db, &["nonexistent_op_xyz"]);
commands::cmd_idle_between(&db, &["nonexistent_a", "nonexistent_b"]);
}
#[test]
fn unicode_kernel_names_no_panic() {
let db = build_session();
commands::cmd_kernels(&db, &["αβ"]);
commands::cmd_inspect(&db, &["αβ"]);
commands::cmd_timeline(&db, &["50"]); }
#[test]
fn breakdown_no_double_count() {
let db = build_session();
let nsys_total: f64 = db.conn.query_row(
"SELECT SUM(duration_us) FROM launches
WHERE kernel_name LIKE '%cutlass%' AND layer_id = (
SELECT id FROM layers WHERE source = 'nsys' LIMIT 1
)",
[],
|row| row.get(0),
).unwrap();
assert!((nsys_total - 3005.0).abs() < 0.1, "nsys cutlass total: {nsys_total}");
let all_total: f64 = db.conn.query_row(
"SELECT SUM(duration_us) FROM launches WHERE kernel_name LIKE '%cutlass%'",
[],
|row| row.get(0),
).unwrap();
assert!((all_total - 3985.0).abs() < 0.1, "all layers cutlass total: {all_total}");
let tl_id: i64 = db.timeline_layer_id().unwrap();
let nsys_id: i64 = db.conn.query_row(
"SELECT id FROM layers WHERE source = 'nsys' LIMIT 1", [], |r| r.get(0),
).unwrap();
assert_eq!(tl_id, nsys_id, "timeline should prefer nsys layer");
commands::cmd_breakdown(&db, &["linear"]);
}
#[test]
fn gaps_handles_overlapping_streams() {
let dir = tempfile::tempdir().unwrap();
let path = dir.into_path().join("gaps.gpu.db");
let db = GpuDb::create(&path).unwrap();
db.set_meta("wall_time_us", "1000").unwrap();
let lid = db.add_layer("nsys", "test", None, None, None).unwrap();
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('k1', 400.0, 0.0, 1, ?1)", params![lid],
).unwrap();
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('k2', 400.0, 200.0, 2, ?1)", params![lid],
).unwrap();
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('k3', 200.0, 800.0, 1, ?1)", params![lid],
).unwrap();
commands::cmd_gaps(&db, &[]);
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('k4', 300.0, 550.0, 3, ?1)", params![lid],
).unwrap();
let dir2 = tempfile::tempdir().unwrap();
let path2 = dir2.into_path().join("gaps2.gpu.db");
let db2 = GpuDb::create(&path2).unwrap();
let lid2 = db2.add_layer("nsys", "test", None, None, None).unwrap();
db2.set_meta("wall_time_us", "2000").unwrap();
db2.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('a', 100.0, 0.0, 1, ?1)", params![lid2],
).unwrap();
db2.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('b', 750.0, 50.0, 2, ?1)", params![lid2],
).unwrap();
db2.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('c', 100.0, 600.0, 1, ?1)", params![lid2],
).unwrap();
db2.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES ('d', 100.0, 900.0, 1, ?1)", params![lid2],
).unwrap();
commands::cmd_gaps(&db2, &[]);
}
#[test]
fn gap_merge_correctness() {
let dir = tempfile::tempdir().unwrap();
let path = dir.into_path().join("gm.gpu.db");
let db = GpuDb::create(&path).unwrap();
let lid = db.add_layer("nsys", "t", None, None, None).unwrap();
for &(name, dur, start, stream) in &[
("a", 100.0_f64, 0.0_f64, 1_u32),
("b", 750.0, 50.0, 2),
("c", 100.0, 600.0, 1),
("d", 100.0, 900.0, 1),
] {
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, start_us, stream_id, layer_id)
VALUES (?1, ?2, ?3, ?4, ?5)",
params![name, dur, start, stream, lid],
).unwrap();
}
let tl = db.timeline_filter();
let sql = format!(
"SELECT start_us, start_us + duration_us AS end_us
FROM launches WHERE start_us IS NOT NULL AND {tl}
ORDER BY start_us"
);
let intervals: Vec<(f64, f64)> = db.query_vec(&sql, [], |row| {
Ok((row.get::<_,f64>(0)?, row.get::<_,f64>(1)?))
});
let mut gaps = Vec::new();
if let Some(&(_, mut cur_end)) = intervals.first() {
for &(s, e) in &intervals[1..] {
if s <= cur_end {
if e > cur_end { cur_end = e; }
} else {
let gap = s - cur_end;
if gap > 1.0 {
gaps.push((cur_end, gap));
}
cur_end = e;
}
}
}
assert_eq!(gaps.len(), 1, "expected exactly 1 gap, got: {gaps:?}");
assert!((gaps[0].0 - 800.0).abs() < 0.1, "gap should start at 800, got {}", gaps[0].0);
assert!((gaps[0].1 - 100.0).abs() < 0.1, "gap should be 100us, got {}", gaps[0].1);
}
#[test]
fn region_filter_restricts_launches() {
let mut db = build_session();
let total_before = db.total_launch_count();
db.region_filter = Some("Step#1".to_string());
let filter = db.kernel_filter();
let sql = format!(
"SELECT COUNT(*) FROM launches WHERE {filter}"
);
let filtered_count = db.count(&sql);
assert!(filtered_count > 0, "region filter should match some launches");
assert!(filtered_count < total_before,
"region filter should exclude launches outside the region (filtered={filtered_count}, total={total_before})");
let outside = db.conn.query_row(
&format!("SELECT COUNT(*) FROM launches WHERE start_us > 20500 AND {filter}"),
[],
|row| row.get::<_, i64>(0),
).unwrap();
assert_eq!(outside, 0, "launches after region end should be excluded");
}
#[test]
fn empty_db_no_panic() {
let dir = tempfile::tempdir().unwrap();
let path = dir.into_path().join("empty.gpu.db");
let mut db = GpuDb::create(&path).unwrap();
commands::cmd_stats(&db);
commands::cmd_kernels(&db, &[]);
commands::cmd_ops(&db, &[]);
commands::cmd_layers(&db);
commands::cmd_suggest(&db);
commands::cmd_streams(&db);
commands::cmd_overlap(&db);
commands::cmd_concurrency(&db);
commands::cmd_warmup(&db);
commands::cmd_small(&db, &[]);
commands::cmd_hotpath(&db);
commands::cmd_compare_ops(&db, &[]);
commands::cmd_top_ops(&db, &[]);
commands::cmd_list();
commands::cmd_focus(&mut db, &[]);
commands::cmd_ignore(&mut db, &[]);
commands::cmd_region(&mut db, &[]);
commands::cmd_reset(&mut db);
commands::cmd_inspect(&db, &[]);
commands::cmd_bound(&db, &[]);
commands::cmd_trace(&db, &[]);
commands::cmd_callers(&db, &[]);
commands::cmd_variance(&db, &[]);
commands::cmd_breakdown(&db, &[]);
commands::cmd_idle_between(&db, &[]);
}
#[test]
fn trunc_edge_cases() {
use crate::commands::trunc;
assert_eq!(trunc("hello", 10), "hello");
assert_eq!(trunc("hello world", 8), "hello...");
assert_eq!(trunc("abc", 3), "abc");
assert_eq!(trunc("αβγδ", 10), "αβγδ");
assert_eq!(trunc("αβγδ", 4), "αβγδ");
let t = trunc("αβγδεζ", 4);
assert_eq!(t, "α...");
assert_eq!(trunc("", 5), "");
}
#[test]
fn inspect_multiple_matches() {
let db = build_session();
commands::cmd_inspect(&db, &["kernel"]);
commands::cmd_inspect(&db, &["ampere"]);
}
#[test]
fn variance_single_launch() {
let dir = tempfile::tempdir().unwrap();
let path = dir.into_path().join("var.gpu.db");
let db = GpuDb::create(&path).unwrap();
let lid = db.add_layer("nsys", "t", None, None, None).unwrap();
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, layer_id) VALUES ('solo', 100.0, ?1)",
params![lid],
).unwrap();
commands::cmd_variance(&db, &["solo"]);
}
#[test]
fn cuda_only_all_commands_no_panic() {
let mut db = build_cuda_only_session();
commands::cmd_stats(&db);
commands::cmd_kernels(&db, &[]);
commands::cmd_kernels(&db, &["sgemm"]);
commands::cmd_inspect(&db, &["sgemm"]);
commands::cmd_inspect(&db, &["reduce"]);
commands::cmd_bound(&db, &["sgemm"]);
commands::cmd_roofline(&db, &[]);
commands::cmd_occupancy(&db, &[]);
commands::cmd_transfers(&db, &[]);
commands::cmd_gaps(&db, &[]);
commands::cmd_overlap(&db);
commands::cmd_streams(&db);
commands::cmd_timeline(&db, &[]);
commands::cmd_variance(&db, &["sgemm"]);
commands::cmd_warmup(&db);
commands::cmd_small(&db, &[]);
commands::cmd_fuse(&db, &[]);
commands::cmd_concurrency(&db);
commands::cmd_suggest(&db);
commands::cmd_layers(&db);
commands::cmd_ops(&db, &[]);
commands::cmd_top_ops(&db, &[]);
commands::cmd_hotpath(&db);
commands::cmd_compare_ops(&db, &[]);
commands::cmd_trace(&db, &["anything"]);
commands::cmd_callers(&db, &["anything"]);
commands::cmd_breakdown(&db, &["anything"]);
commands::cmd_idle_between(&db, &["a", "b"]);
commands::cmd_focus(&mut db, &["sgemm"]);
commands::cmd_kernels(&db, &[]);
commands::cmd_reset(&mut db);
}
#[test]
fn triton_inference_all_commands_no_panic() {
let mut db = build_triton_inference_session();
commands::cmd_stats(&db);
commands::cmd_kernels(&db, &[]);
commands::cmd_ops(&db, &[]);
commands::cmd_top_ops(&db, &[]);
commands::cmd_inspect(&db, &["flash_attention"]);
commands::cmd_inspect(&db, &["add_kernel"]);
commands::cmd_timeline(&db, &[]);
commands::cmd_gaps(&db, &[]);
commands::cmd_warmup(&db);
commands::cmd_small(&db, &[]);
commands::cmd_fuse(&db, &[]);
commands::cmd_concurrency(&db);
commands::cmd_suggest(&db);
commands::cmd_layers(&db);
commands::cmd_trace(&db, &["attention"]);
commands::cmd_callers(&db, &["matmul"]);
commands::cmd_breakdown(&db, &["attention"]);
commands::cmd_hotpath(&db);
commands::cmd_compare_ops(&db, &[]);
commands::cmd_variance(&db, &["flash_attention"]);
commands::cmd_idle_between(&db, &["attention", "linear"]);
commands::cmd_bound(&db, &["flash_attention"]);
commands::cmd_roofline(&db, &[]);
commands::cmd_occupancy(&db, &[]);
commands::cmd_transfers(&db, &[]);
commands::cmd_focus(&mut db, &["triton"]);
commands::cmd_kernels(&db, &[]);
commands::cmd_ignore(&mut db, &["add"]);
commands::cmd_kernels(&db, &[]);
commands::cmd_reset(&mut db);
}
#[test]
fn multi_stream_all_commands_no_panic() {
let mut db = build_multi_stream_session();
commands::cmd_stats(&db);
commands::cmd_kernels(&db, &[]);
commands::cmd_inspect(&db, &["gemm"]);
commands::cmd_inspect(&db, &["AllReduce"]);
commands::cmd_timeline(&db, &["20"]);
commands::cmd_gaps(&db, &[]);
commands::cmd_overlap(&db);
commands::cmd_streams(&db);
commands::cmd_warmup(&db);
commands::cmd_small(&db, &[]);
commands::cmd_fuse(&db, &[]);
commands::cmd_concurrency(&db);
commands::cmd_transfers(&db, &[]);
commands::cmd_suggest(&db);
commands::cmd_layers(&db);
commands::cmd_variance(&db, &["gemm"]);
commands::cmd_ops(&db, &[]);
commands::cmd_roofline(&db, &[]);
commands::cmd_bound(&db, &["gemm"]);
commands::cmd_region(&mut db, &[]); commands::cmd_region(&mut db, &["PipelineStage#0"]);
commands::cmd_kernels(&db, &[]); commands::cmd_reset(&mut db);
}
#[test]
fn multi_stream_gaps_account_for_overlap() {
let db = build_multi_stream_session();
commands::cmd_gaps(&db, &[]);
}
#[test]
fn ncu_only_session_no_panic() {
let dir = tempfile::tempdir().unwrap();
let path = dir.into_path().join("ncu_only.gpu.db");
let mut db = GpuDb::create(&path).unwrap();
db.set_meta("target", "kernel.cu").unwrap();
db.set_meta("device", "NVIDIA V100").unwrap();
db.set_meta("wall_time_us", "0").unwrap();
let ncu_id = db
.add_layer("ncu", "/tmp/ncu.csv", Some("ncu --set full"), Some(60.0), None)
.unwrap();
db.conn.execute(
"INSERT INTO metrics
(kernel_name, occupancy_pct, compute_throughput_pct, memory_throughput_pct,
registers_per_thread, shared_mem_static_bytes, shared_mem_dynamic_bytes,
l2_hit_rate_pct, achieved_bandwidth_gb_s, peak_bandwidth_gb_s,
boundedness, layer_id)
VALUES ('my_kernel', 50.0, 40.0, 60.0, 48, 16384, 0, 55.0, 800.0, 900.0, 'memory', ?1)",
params![ncu_id],
).unwrap();
commands::cmd_stats(&db);
commands::cmd_kernels(&db, &[]);
commands::cmd_inspect(&db, &["my_kernel"]);
commands::cmd_bound(&db, &["my_kernel"]);
commands::cmd_roofline(&db, &[]);
commands::cmd_occupancy(&db, &[]);
commands::cmd_gaps(&db, &[]);
commands::cmd_timeline(&db, &[]);
commands::cmd_warmup(&db);
commands::cmd_small(&db, &[]);
commands::cmd_fuse(&db, &[]);
commands::cmd_transfers(&db, &[]);
commands::cmd_streams(&db);
commands::cmd_concurrency(&db);
commands::cmd_suggest(&db);
commands::cmd_layers(&db);
commands::cmd_overlap(&db);
commands::cmd_focus(&mut db, &["my_kernel"]);
commands::cmd_kernels(&db, &[]);
commands::cmd_reset(&mut db);
}
#[test]
fn stats_gpu_time_equals_kernels_total() {
let db = build_cuda_only_session();
let total = db.total_gpu_time_us();
let expected = 10080.0 + 153.0 + 1590.0;
assert!((total - expected).abs() < 0.1,
"total_gpu_time_us() = {total}, expected {expected}");
}
#[test]
fn multi_layer_kernels_use_timeline_filter() {
let db = build_session();
let tl_id = db.timeline_layer_id().unwrap();
let nsys_total: f64 = db.conn.query_row(
"SELECT COALESCE(SUM(duration_us), 0) FROM launches WHERE layer_id = ?1",
params![tl_id],
|row| row.get(0),
).unwrap();
let reported_total = db.total_gpu_time_us();
assert!((reported_total - nsys_total).abs() < 0.1,
"total_gpu_time_us() should use timeline_filter: got {reported_total}, expected {nsys_total}");
}
#[test]
fn variance_math_correctness() {
let dir = tempfile::tempdir().unwrap();
let path = dir.into_path().join("var_math.gpu.db");
let db = GpuDb::create(&path).unwrap();
let lid = db.add_layer("nsys", "t", None, None, None).unwrap();
for &dur in &[100.0_f64, 200.0, 300.0, 400.0, 500.0] {
db.conn.execute(
"INSERT INTO launches (kernel_name, duration_us, layer_id)
VALUES ('test_kernel', ?1, ?2)",
params![dur, lid],
).unwrap();
}
let (avg, var): (f64, f64) = db.conn.query_row(
"SELECT AVG(duration_us),
AVG(duration_us * duration_us) - AVG(duration_us) * AVG(duration_us)
FROM launches WHERE kernel_name = 'test_kernel'",
[],
|row| Ok((row.get(0)?, row.get(1)?)),
).unwrap();
assert!((avg - 300.0).abs() < 0.1, "mean should be 300, got {avg}");
assert!((var - 20000.0).abs() < 0.1, "variance should be 20000, got {var}");
let stddev = var.sqrt();
let cv = stddev / avg;
assert!((cv - 0.4714).abs() < 0.01, "CV should be ~0.4714, got {cv}");
commands::cmd_variance(&db, &["test_kernel"]);
}
#[test]
fn kernel_percentages_sum_to_100() {
let db = build_cuda_only_session();
let sql = "SELECT SUM(total) FROM (
SELECT SUM(duration_us) as total FROM launches GROUP BY kernel_name
)";
let sum_of_totals: f64 = db.conn.query_row(sql, [], |row| row.get(0)).unwrap();
let gpu_total = db.total_gpu_time_us();
assert!((sum_of_totals - gpu_total).abs() < 0.1,
"sum of per-kernel totals ({sum_of_totals}) should equal total GPU time ({gpu_total})");
}
#[test]
fn inspect_total_matches_kernels_listing() {
let db = build_cuda_only_session();
let kernel_total: f64 = db.conn.query_row(
"SELECT SUM(duration_us) FROM launches WHERE kernel_name LIKE '%sgemm%'",
[],
|row| row.get(0),
).unwrap();
let (inspect_cnt, inspect_total): (i64, f64) = db.conn.query_row(
"SELECT COUNT(*), SUM(duration_us) FROM launches WHERE kernel_name LIKE '%sgemm%'",
[],
|row| Ok((row.get(0)?, row.get(1)?)),
).unwrap();
assert!((kernel_total - inspect_total).abs() < 0.1,
"kernels total ({kernel_total}) vs inspect total ({inspect_total})");
assert_eq!(inspect_cnt, 5);
}
#[test]
fn breakdown_sums_consistent_with_top_ops() {
let db = build_triton_inference_session();
let op_gpu: f64 = db.conn.query_row(
"SELECT gpu_time_us FROM ops WHERE name = 'attention'",
[], |row| row.get(0),
).unwrap();
let tl_id = db.timeline_layer_id().unwrap();
let kernel_total: f64 = db.conn.query_row(
"SELECT COALESCE(SUM(l.duration_us), 0)
FROM op_kernel_map okm
JOIN launches l ON l.kernel_name = okm.kernel_name AND l.layer_id = ?1
WHERE okm.op_id = (SELECT id FROM ops WHERE name = 'attention')",
params![tl_id],
|row| row.get(0),
).unwrap();
assert!((op_gpu - kernel_total).abs() < 0.1,
"op gpu_time_us ({op_gpu}) should match breakdown kernel total ({kernel_total})");
commands::cmd_breakdown(&db, &["attention"]);
}
#[test]
fn focus_filter_restricts_small_command() {
let mut db = build_cuda_only_session();
let small_count_all: i64 = db.conn.query_row(
"SELECT COUNT(DISTINCT kernel_name) FROM launches
GROUP BY kernel_name HAVING AVG(duration_us) < 10.0",
[],
|row| row.get(0),
).unwrap_or(0);
commands::cmd_focus(&mut db, &["sgemm"]);
commands::cmd_small(&db, &[]);
let filter = db.kernel_filter();
assert!(filter.contains("sgemm"), "focus filter should contain 'sgemm'");
commands::cmd_reset(&mut db);
}
#[test]
fn stream_count_consistency() {
let db = build_multi_stream_session();
let reported_count = db.stream_count();
let actual_streams: Vec<u32> = db.query_vec(
"SELECT DISTINCT stream_id FROM launches WHERE stream_id IS NOT NULL",
[],
|row| row.get(0),
);
assert_eq!(reported_count, actual_streams.len(),
"stream_count ({reported_count}) should match distinct stream IDs ({actual_streams:?})");
assert_eq!(reported_count, 4, "multi-stream session has 4 streams");
commands::cmd_streams(&db);
}
#[test]
fn suggest_detects_missing_layers() {
let db = build_triton_inference_session();
assert!(!db.has_layer("nsys"));
assert!(!db.has_layer("ncu"));
assert!(db.has_layer("proton"));
assert!(!db.has_layer("torch"));
commands::cmd_suggest(&db);
}
#[test]
fn region_filter_with_no_regions() {
let mut db = build_triton_inference_session();
commands::cmd_region(&mut db, &[]);
commands::cmd_region(&mut db, &["nonexistent"]);
commands::cmd_kernels(&db, &[]);
commands::cmd_reset(&mut db);
}
#[test]
fn warmup_with_no_warmup_effect() {
let db = build_cuda_only_session();
commands::cmd_warmup(&db);
}
#[test]
fn diff_disjoint_kernels() {
let db = build_cuda_only_session();
let other = build_triton_inference_session();
let dir = tempfile::tempdir().unwrap();
let dest = dir.path().join("other.gpu.db");
{
let mut dest_conn = rusqlite::Connection::open(&dest).unwrap();
let backup = rusqlite::backup::Backup::new(&other.conn, &mut dest_conn).unwrap();
backup.run_to_completion(100, std::time::Duration::from_millis(10), None).unwrap();
}
if let Err(e) = db.attach(dest.to_str().unwrap(), "other") {
panic!("attach failed: {e}");
}
let _ = db.detach("other");
commands::cmd_diff(&db, &[dest.to_str().unwrap()]);
}