use digital_gpu::*;
use std::time::Instant;
#[test]
fn boot_digital_gpu_with_default_spec() {
let gpu = GpuHandle::boot(GpuSpec::new().effective_gb(32))
.expect("should boot a default 32 GB digital GPU");
assert!(gpu.effective_capacity_gb() >= 32);
}
#[test]
fn boot_with_compression_expansion() {
let gpu = GpuHandle::boot(GpuSpec::new()
.effective_gb(32)
.physical_gb(2));
assert!(gpu.is_ok(), "should boot with 2 GB physical / 32 GB effective");
}
#[test]
fn boot_with_int4_compression() {
let gpu = GpuHandle::boot(GpuSpec::new()
.effective_gb(64)
.compression(CompressionMode::Int4)
.physical_gb(8));
assert!(gpu.is_ok());
}
#[test]
fn large_physical_gb_oversubscribes() {
let gpu = GpuHandle::boot(GpuSpec::new()
.effective_gb(128)
.physical_gb(64 * 1024));
let _ = gpu;
}
#[test]
fn curve_sample_is_monotonic() {
let gpu = GpuHandle::boot(GpuSpec::new().effective_gb(64))
.expect("boot ok");
let samples = gpu.curve_sample(64 * 1024 * 1024 * 1024, 10);
assert!(samples.len() <= 11 && samples.len() >= 1);
let mut last_bw = f64::MAX;
for s in &samples {
assert!(s.bandwidth_gib_s <= last_bw + 1e-9,
"bandwidth should never increase: {} -> {}",
last_bw, s.bandwidth_gib_s);
last_bw = s.bandwidth_gib_s;
}
}
#[test]
fn bandwidth_query_first_gib_in_fast_pool() {
let gpu = GpuHandle::boot(GpuSpec::new().effective_gb(64))
.expect("boot ok");
let bw = gpu.bandwidth_at_effective(1024 * 1024 * 1024);
assert!(bw > 10.0,
"1 GB virtual should give > 10 GiB/s, got {}", bw);
}
#[test]
fn compressed_arena_allocate_8x_over_physical() {
let gpu = GpuHandle::boot(GpuSpec::new()
.physical_gb(6)
.effective_gb(192)) .expect("boot ok");
if let Some(arena) = gpu.compressed_arena() {
let alloc = arena.allocate_effective(4 * 1024 * 1024 * 1024);
assert!(alloc.is_ok(), "4 GB virtual allocation failed");
}
}
#[test]
fn boot_speed_smoke_test() {
let start = Instant::now();
let _ = GpuHandle::boot(GpuSpec::new().effective_gb(8));
let elapsed = start.elapsed();
assert!(elapsed.as_secs() < 60,
"boot took {}s, should be < 60s", elapsed.as_secs());
}
#[test]
fn explicit_no_compression_works() {
let gpu = GpuHandle::boot(GpuSpec::new()
.effective_gb(8)
.compression(CompressionMode::None)
.physical_gb(8));
assert!(gpu.is_ok());
assert!(gpu.unwrap().compressed_arena().is_none());
}
#[test]
fn cluster_enabled_boots_with_discovery() {
let gpu = GpuHandle::boot(GpuSpec::new()
.effective_gb(8)
.enable_cluster());
assert!(gpu.is_ok(), "cluster-enabled boot should succeed");
}