Skip to main content

TestContext

Struct TestContext 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn new() -> Result<Self>

Create test context with default 1GB memory budget.

Source

pub fn large() -> Result<Self>

Create test context with large 4GB memory budget for stress tests.

Source

pub fn sync_and_check(&self) -> Result<()>

Force device synchronization and check for async errors.

Source

pub fn memory_used(&self) -> usize

Get current memory usage in bytes.

Source

pub fn memory_budget(&self) -> usize

Get memory budget in bytes.

Source

pub fn reset_transfer_counters(&self)

Reset host/device transfer counters (in bytes).

Source

pub fn transfer_counters(&self) -> (u64, u64)

Snapshot transfer counters (htod_bytes, dtoh_bytes).

Source

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.

Source

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.

Source

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.

Source

pub fn measure_gpu_ms<F>(&self, f: F) -> Result<f32>
where F: FnOnce() -> Result<()>,

Measure GPU time (in milliseconds) for work enqueued on the device stream.

Source

pub fn multi_gpu_available(&self) -> bool

Check if multi-GPU is available.

Source

pub fn compute_capability(&self) -> Result<(u32, u32)>

Get compute capability of current device.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V