Skip to main content

DnHandle

Struct DnHandle 

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

Dense cuSOLVER handle.

Implementations§

Source§

impl DnHandle

Source

pub fn new() -> Result<Self>

Create a new cuSOLVER dense handle (cusolverDnCreate).

Examples found in repository?
examples/qr.rs (line 23)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19    baracuda_driver::init()?;
20    let device = Device::get(0)?;
21    println!("device: {}", device.name()?);
22    let ctx = Context::new(&device)?;
23    let handle = DnHandle::new()?;
24
25    // 3×3 column-major:
26    //   A = [[12, -51,   4],
27    //        [ 6, 167, -68],
28    //        [-4,  24, -41]]
29    // Stored as columns: [12, 6, -4,  -51, 167, 24,  4, -68, -41]
30    let m: i32 = 3;
31    let n: i32 = 3;
32    let lda: i32 = m;
33    let a_host: [f32; 9] = [12.0, 6.0, -4.0, -51.0, 167.0, 24.0, 4.0, -68.0, -41.0];
34
35    let mut a = DeviceBuffer::from_slice(&ctx, &a_host)?;
36    let mut tau: DeviceBuffer<f32> = DeviceBuffer::new(&ctx, m.min(n) as usize)?;
37    let mut info: DeviceBuffer<i32> = DeviceBuffer::new(&ctx, 1)?;
38
39    geqrf::<f32>(&handle, m, n, &mut a, lda, &mut tau, &mut info)?;
40
41    let mut info_host = [42i32];
42    info.copy_to_host(&mut info_host)?;
43    assert_eq!(info_host[0], 0, "geqrf info = {}", info_host[0]);
44
45    let mut a_out = [0.0f32; 9];
46    a.copy_to_host(&mut a_out)?;
47    let mut tau_out = vec![0.0f32; tau.len()];
48    tau.copy_to_host(&mut tau_out)?;
49
50    // Print R (the upper triangle of `a` after geqrf, column-major).
51    println!("R (upper triangle, in column-major positions):");
52    for i in 0..m as usize {
53        for j in 0..n as usize {
54            if i <= j {
55                print!("{:10.4} ", a_out[j * lda as usize + i]);
56            } else {
57                print!("{:>10} ", "·");
58            }
59        }
60        println!();
61    }
62    println!("tau = {tau_out:?}");
63
64    // For this fixture the magnitude of R[0,0] is sqrt(12^2 + 6^2 + 4^2) = 14.
65    let r00 = a_out[0].abs();
66    assert!((r00 - 14.0).abs() < 1e-3, "R[0,0]={r00}, expected 14");
67    println!("OK (|R[0,0]| = {r00})");
68    Ok(())
69}
Source

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

Bind this handle to stream; subsequent cuSOLVER calls dispatch on it (cusolverDnSetStream).

Source

pub fn stream(&self) -> Result<*mut c_void>

Read back the raw stream pointer this handle is currently bound to. Returns a raw *mut c_void rather than an owned Stream because the cuSOLVER handle didn’t create the stream and isn’t entitled to destroy it. The pointer aliases CUstream / cudaStream_t.

Source

pub fn version() -> Result<i32>

cuSOLVER library version (cusolverGetVersion), e.g. 12604 for cuSOLVER 12.6.4.

Source

pub fn as_raw(&self) -> cusolverDnHandle_t

Raw cusolverDnHandle_t. Use with care.

Trait Implementations§

Source§

impl Debug for DnHandle

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for DnHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for DnHandle

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.