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
impl CudaRuntime
Sourcepub fn new(device_id: CudaDeviceId) -> Result<Self, CudaDeviceError>
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.
Sourcepub fn device_id(&self) -> CudaDeviceId
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;Sourcepub fn device_info(&self) -> &CudaDeviceInfo
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;Sourcepub fn allocation_domain(&self) -> AllocationDomainId
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;Sourcepub fn supports_extension(&self, capability: GpuExtensionCapability) -> bool
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;Sourcepub fn with_current_context<R>(
&self,
op: &'static str,
f: impl FnOnce() -> R,
) -> Result<R>
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)
};Sourcepub fn runtime_identity(&self) -> CudaRuntimeIdentity
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;Sourcepub fn synchronize(&self) -> Result<()>
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
impl Clone for CudaRuntime
Source§fn clone(&self) -> CudaRuntime
fn clone(&self) -> CudaRuntime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for CudaRuntime
impl !UnwindSafe for CudaRuntime
impl Freeze for CudaRuntime
impl Send for CudaRuntime
impl Sync for CudaRuntime
impl Unpin for CudaRuntime
impl UnsafeUnpin for CudaRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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