Skip to main content

Context

Struct Context 

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

A stateful cuSOLVER handle.

Use one context per host thread or concurrent task. The handle is movable between threads, but it is intentionally not Clone or Sync.

Implementations§

Source§

impl Context

Source

pub fn create(cuda_ctx: &Arc<CudaContext>) -> Result<Self>

Creates a cuSOLVER dense handle for the given CUDA context. Call this before invoking other cuSOLVER operations through this wrapper.

cuSOLVER allocates the GPU-side resources it needs here. On the first application-defined stream passed to Context::set_stream, cuSOLVER may also allocate an internal workspace.

§Errors

Returns an error if the CUDA context cannot be bound, if cuSOLVER cannot create a handle, or if cuSOLVER returns a null handle.

Source

pub fn cuda_context(&self) -> &Arc<CudaContext>

Returns the underlying CUDA context used by this cuSOLVER handle.

Source

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

Binds the underlying CUDA context associated with this handle.

§Errors

Returns an error if the CUDA context cannot be bound.

Source

pub fn ensure_stream(&self, stream: &Stream) -> Result<()>

Ensures stream belongs to the same CUDA context as this handle.

Returns an error if the stream belongs to a different context.

Source

pub fn stream(&self) -> Result<StreamBinding>

Returns the stream currently used by this cuSOLVER handle.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER cannot report the current stream.

Source

pub fn set_stream(&self, stream: Option<&Stream>) -> Result<()>

Sets the stream used by this cuSOLVER handle.

Passing None restores the CUDA default stream.

§Errors

Returns an error if stream belongs to another CUDA context, if the CUDA context cannot be bound, or if cuSOLVER rejects the stream.

Source

pub fn deterministic_mode(&self) -> Result<DeterministicMode>

Returns the deterministic mode currently configured on this handle.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER cannot report the deterministic mode.

Source

pub fn set_deterministic_mode(&self, mode: DeterministicMode) -> Result<()>

Sets the deterministic mode for operations executed through this handle.

Allowing non-deterministic results may improve performance for some operations, including xgeqrf, xgesvd, xgesvdr, and xgesvdp.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER rejects the deterministic mode.

Source

pub fn math_mode(&self) -> Result<MathMode>

Returns the math mode currently configured on this handle.

See MathMode for the supported wrapper values.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER cannot report the math mode.

Source

pub fn set_math_mode(&self, mode: MathMode) -> Result<()>

Sets the math mode for operations executed through this handle.

See MathMode for the supported wrapper values and combinations.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER rejects the math mode.

Source

pub fn emulation_strategy(&self) -> Result<EmulationStrategy>

Returns the emulation strategy configured on this handle.

This only affects operations that use one of the emulated math modes described by MathMode.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER cannot report the emulation strategy.

Source

pub fn set_emulation_strategy(&self, strategy: EmulationStrategy) -> Result<()>

Sets the emulation strategy for operations executed through this handle.

This only affects operations that use one of the emulated math modes described by MathMode.

§Errors

Returns an error if the CUDA context cannot be bound or if cuSOLVER rejects the emulation strategy.

Source

pub unsafe fn set_logger_callback( callback: cusolverDnLoggerCallback_t, ) -> Result<()>

Installs the cuSOLVER logger callback.

§Safety

callback, if present, must remain valid for use by cuSOLVER and must follow the callback ABI expected by the library.

§Errors

Returns an error if cuSOLVER rejects the callback.

Source

pub fn set_logger_level(level: i32) -> Result<()>

Sets the cuSOLVER logger verbosity level.

§Errors

Returns an error if cuSOLVER rejects the logging level.

Source

pub fn set_logger_mask(mask: i32) -> Result<()>

Sets the cuSOLVER logger mask.

§Errors

Returns an error if cuSOLVER rejects the logging mask.

Source

pub unsafe fn set_logger_file(file: *mut FILE) -> Result<()>

Sets the FILE handle used for cuSOLVER logging.

Once registered, the file handle must remain open until another handle is installed or logging is disabled.

§Safety

file must be a valid FILE handle for as long as cuSOLVER may write to it.

§Errors

Returns an error if cuSOLVER rejects the file handle.

Source

pub fn set_logger_path(path: impl AsRef<Path>) -> Result<()>

Sets the cuSOLVER logging output file by path.

§Errors

Returns an error if path cannot be converted to a C string or if cuSOLVER cannot open the log file.

Source

pub fn disable_logger() -> Result<()>

Disables cuSOLVER logging for the current process.

§Errors

Returns an error if cuSOLVER cannot disable logging.

Source

pub fn as_raw(&self) -> cusolverDnHandle_t

Returns the raw cuSOLVER dense handle.

The returned handle is borrowed and remains valid only while this context and its underlying CUDA context are alive.

Trait Implementations§

Source§

impl Debug for Context

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
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.