Skip to main content

CudaRuntime

Struct CudaRuntime 

Source
pub struct CudaRuntime { /* private fields */ }
Expand description

CubeCL CUDA runtime wrapper.

§Examples

use tenferro_gpu::cuda::CudaRuntime;

let _ctor: fn(tenferro_gpu::cuda::CudaDeviceId) ->
    Result<CudaRuntime, tenferro_gpu::cuda::CudaDeviceError> = CudaRuntime::new;
let _sync: fn(&CudaRuntime) -> tenferro_tensor::Result<()> =
    CudaRuntime::synchronize;

Implementations§

Source§

impl CudaRuntime

Source

pub fn new(device_id: CudaDeviceId) -> Result<Self, CudaDeviceError>

Initialize the CubeCL CUDA runtime on the caller-selected device.

§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId, cuda::CudaRuntime};

let _ctor: fn(CudaDeviceId) -> Result<CudaRuntime, CudaDeviceError> = CudaRuntime::new;
§Errors

Returns CudaDeviceError::Discovery when fallback discovery for an invalid selected ordinal fails, CudaDeviceError::Unavailable when that ordinal is not available, or CudaDeviceError::Initialization when CUDA driver, runtime, context, or CubeCL client initialization fails.

Source

pub fn device_id(&self) -> CudaDeviceId

Return the caller-selected CUDA device identity that this runtime targets.

§Examples
use tenferro_gpu::{cuda::CudaDeviceId, cuda::CudaRuntime};

let _device_id: fn(&CudaRuntime) -> CudaDeviceId = CudaRuntime::device_id;
Source

pub fn device_info(&self) -> &CudaDeviceInfo

Return immutable metadata for the runtime’s device.

§Examples
use tenferro_gpu::cuda::CudaRuntime;

let _info: fn(&CudaRuntime) -> &tenferro_gpu::cuda::CudaDeviceInfo =
    CudaRuntime::device_info;
Source

pub fn allocation_domain(&self) -> AllocationDomainId

Return the allocation ownership domain of this runtime.

§Examples
use tenferro_gpu::cuda::CudaRuntime;

let _domain: fn(&CudaRuntime) -> tenferro_tensor::AllocationDomainId =
    CudaRuntime::allocation_domain;
Source

pub fn supports_extension(&self, capability: GpuExtensionCapability) -> bool

Report whether this CUDA session supports a GPU extension capability.

The CUDA provider supports the full extension vocabulary: external CubeCL kernels, native module loading, runtime compilation (NVRTC), raw stream borrowing, and same-device copy. PeerCopy is reported as a directional query; availability is hardware-dependent and is checked per source/destination pair rather than here.

§Examples
use tenferro_gpu::cuda::GpuExtensionCapability;
use tenferro_gpu::cuda::CudaRuntime;

let _supports: fn(&CudaRuntime, GpuExtensionCapability) -> bool =
    CudaRuntime::supports_extension;
Source

pub fn with_current_context<R>( &self, op: &'static str, f: impl FnOnce() -> R, ) -> Result<R>

Run f with the tenferro primary context current on this thread.

Saves the calling thread’s current CUDA device/context, activates the tenferro primary context for the duration of f, and attempts to restore the saved state on every exit path (normal return, Err, and unwind). Restoration is best-effort: a failure to restore the caller’s previous device/context is logged to stderr rather than returned. This is the scoped context authority used by vendor-library lifecycle paths (plan creation/retirement) that run outside a raw-session callback.

§Errors

Returns crate::Error::BackendSource when the tenferro primary context cannot be activated (device or context driver failure); a partial activation is best-effort rolled back before the error is returned (rollback failures are discarded).

§Examples
use tenferro_gpu::cuda::CudaRuntime;

let _check: fn(&CudaRuntime) -> tenferro_tensor::Result<u64> = |rt| {
    rt.with_current_context("test.context", || 7)
};
Source

pub fn runtime_identity(&self) -> CudaRuntimeIdentity

Return the opaque identity of this exact executable runtime instance.

§Examples
use tenferro_gpu::cuda::CudaRuntime;

let _identity: fn(&CudaRuntime) -> tenferro_gpu::cuda::CudaRuntimeIdentity =
    CudaRuntime::runtime_identity;
Source

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

Block the current thread until work submitted to the current CUDA stream completes.

§Examples
use tenferro_gpu::cuda::CudaRuntime;

let _sync: fn(&CudaRuntime) -> tenferro_tensor::Result<()> =
    CudaRuntime::synchronize;
§Errors

Returns crate::Error::RuntimeState when CubeCL cannot expose the current stream, or crate::Error::BackendSource when CUDA context or stream synchronization fails.

Trait Implementations§

Source§

impl Clone for CudaRuntime

Source§

fn clone(&self) -> CudaRuntime

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CudaRuntime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<C> CloneExpand for C
where C: Clone,

§

fn __expand_clone_method(&self, _scope: &mut Scope) -> C

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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.

§

impl<T> IntoComptime for T

§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

§

type At<'a> = T

The concrete input type at lifetime 'a.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,