pub struct TestContext {
pub provider: CudaKernelProvider,
pub device: Arc<CudaDevice>,
pub memory: Arc<GpuMemoryManager>,
/* private fields */
}Expand description
Test context providing CUDA resources for certification tests.
Fields§
§provider: CudaKernelProvider§device: Arc<CudaDevice>§memory: Arc<GpuMemoryManager>Implementations§
Source§impl TestContext
impl TestContext
Sourcepub fn with_budget(budget_bytes: usize) -> Result<Self>
pub fn with_budget(budget_bytes: usize) -> Result<Self>
Create test context with specific memory budget in bytes.
Backend is chosen by XLOG_USE_DEVICE_RUNTIME (default
legacy).
When XLOG_REQUIRE_CUDA=1, any initialization failure panics via
enforce_cuda_required so callers’ skip-on-error paths cannot turn
a missing GPU into a vacuous pass.
Sourcepub fn uses_device_runtime(&self) -> bool
pub fn uses_device_runtime(&self) -> bool
Return whether this context was built against the runtime-backed allocator stack (vs the legacy cudarc-only stack). Cert categories can use this to gate behavior or diagnostics.
Sourcepub fn reap_pending(&self)
pub fn reap_pending(&self)
Drain pending async frees on the runtime allocator, if
any. No-op for the legacy backend. Cert harnesses call
this between categories so the GlobalDeviceBudget
reservation bookkeeping releases bytes that have been
freed via cuMemFreeAsync but whose owning stream has
not yet been synchronized — without this, a long
sequence of small allocate-then-drop tests piles up
pending frees and exhausts the reservation pool even
though the GPU has plenty of free memory.
Sourcepub fn large() -> Result<Self>
pub fn large() -> Result<Self>
Create test context with large 4GB memory budget for stress tests.
Sourcepub fn sync_and_check(&self) -> Result<()>
pub fn sync_and_check(&self) -> Result<()>
Force device synchronization and check for async errors.
Sourcepub fn memory_used(&self) -> usize
pub fn memory_used(&self) -> usize
Get current memory usage in bytes.
Sourcepub fn memory_budget(&self) -> usize
pub fn memory_budget(&self) -> usize
Get memory budget in bytes.
Sourcepub fn reset_transfer_counters(&self)
pub fn reset_transfer_counters(&self)
Reset host/device transfer counters (in bytes).
Sourcepub fn transfer_counters(&self) -> (u64, u64)
pub fn transfer_counters(&self) -> (u64, u64)
Snapshot transfer counters (htod_bytes, dtoh_bytes).
Sourcepub fn htod_sync_copy_into<T: DeviceRepr, Dst: DevicePtrMut<T>>(
&self,
src: &[T],
dst: &mut Dst,
) -> Result<()>
pub fn htod_sync_copy_into<T: DeviceRepr, Dst: DevicePtrMut<T>>( &self, src: &[T], dst: &mut Dst, ) -> Result<()>
Track a synchronous host-to-device copy.
Sourcepub fn dtoh_sync_copy<T: DeviceRepr, Src: DevicePtr<T>>(
&self,
src: &Src,
) -> Result<Vec<T>>
pub fn dtoh_sync_copy<T: DeviceRepr, Src: DevicePtr<T>>( &self, src: &Src, ) -> Result<Vec<T>>
Track a synchronous device-to-host copy returning a Vec.
Sourcepub fn dtoh_sync_copy_into<T: DeviceRepr, Src: DevicePtr<T>>(
&self,
src: &Src,
dst: &mut [T],
) -> Result<()>
pub fn dtoh_sync_copy_into<T: DeviceRepr, Src: DevicePtr<T>>( &self, src: &Src, dst: &mut [T], ) -> Result<()>
Track a synchronous device-to-host copy into a slice.
Sourcepub fn measure_gpu_ms<F>(&self, f: F) -> Result<f32>
pub fn measure_gpu_ms<F>(&self, f: F) -> Result<f32>
Measure GPU time (in milliseconds) for work enqueued on the device stream.
Sourcepub fn multi_gpu_available(&self) -> bool
pub fn multi_gpu_available(&self) -> bool
Check if multi-GPU is available.
Sourcepub fn compute_capability(&self) -> Result<(u32, u32)>
pub fn compute_capability(&self) -> Result<(u32, u32)>
Get compute capability of current device.
Sourcepub fn device_row_count(&self, buffer: &CudaBuffer) -> u64
pub fn device_row_count(&self, buffer: &CudaBuffer) -> u64
Read device-resident row count for a buffer.
Panics if the count cannot be read; certification tests treat this as fatal.