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
impl Context
Sourcepub fn create(cuda_ctx: &Arc<CudaContext>) -> Result<Self>
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.
Sourcepub fn cuda_context(&self) -> &Arc<CudaContext>
pub fn cuda_context(&self) -> &Arc<CudaContext>
Returns the underlying CUDA context used by this cuSOLVER handle.
Sourcepub fn bind(&self) -> Result<()>
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.
Sourcepub fn ensure_stream(&self, stream: &Stream) -> Result<()>
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.
Sourcepub fn stream(&self) -> Result<StreamBinding>
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.
Sourcepub fn set_stream(&self, stream: Option<&Stream>) -> Result<()>
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.
Sourcepub fn deterministic_mode(&self) -> Result<DeterministicMode>
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.
Sourcepub fn set_deterministic_mode(&self, mode: DeterministicMode) -> Result<()>
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.
Sourcepub fn set_math_mode(&self, mode: MathMode) -> Result<()>
pub fn set_math_mode(&self, mode: MathMode) -> Result<()>
Sourcepub fn emulation_strategy(&self) -> Result<EmulationStrategy>
pub fn emulation_strategy(&self) -> Result<EmulationStrategy>
Sourcepub fn set_emulation_strategy(&self, strategy: EmulationStrategy) -> Result<()>
pub fn set_emulation_strategy(&self, strategy: EmulationStrategy) -> Result<()>
Sourcepub unsafe fn set_logger_callback(
callback: cusolverDnLoggerCallback_t,
) -> Result<()>
pub unsafe fn set_logger_callback( callback: cusolverDnLoggerCallback_t, ) -> Result<()>
Sourcepub fn set_logger_level(level: i32) -> Result<()>
pub fn set_logger_level(level: i32) -> Result<()>
Sets the cuSOLVER logger verbosity level.
§Errors
Returns an error if cuSOLVER rejects the logging level.
Sourcepub fn set_logger_mask(mask: i32) -> Result<()>
pub fn set_logger_mask(mask: i32) -> Result<()>
Sourcepub fn set_logger_path(path: impl AsRef<Path>) -> Result<()>
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.
Sourcepub fn disable_logger() -> Result<()>
pub fn disable_logger() -> Result<()>
Disables cuSOLVER logging for the current process.
§Errors
Returns an error if cuSOLVER cannot disable logging.
Sourcepub fn as_raw(&self) -> cusolverDnHandle_t
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.