MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / new

Method new

crates/blastoff/src/context.rs:79–92  ·  view source on GitHub ↗

Creates a new cuBLAS context, allocating all of the required host and device memory. # Example ``` # fn main() -> Result<(), Box > { # let _ctx = cust::quick_init()?; use blastoff::CublasContext; let ctx = CublasContext::new()?; # Ok(()) # } ```

()

Source from the content-addressed store, hash-verified

77 /// # }
78 /// ```
79 pub fn new() -> Result<Self> {
80 let mut raw = MaybeUninit::uninit();
81 unsafe {
82 sys::v2::cublasCreate_v2(raw.as_mut_ptr()).to_result()?;
83 sys::v2::cublasSetPointerMode_v2(
84 raw.assume_init(),
85 sys::v2::cublasPointerMode_t::CUBLAS_POINTER_MODE_DEVICE,
86 )
87 .to_result()?;
88 Ok(Self {
89 raw: raw.assume_init(),
90 })
91 }
92 }
93
94 /// Tries to destroy a [`CublasContext`], returning an error if it fails.
95 pub fn drop(mut ctx: CublasContext) -> DropResult<CublasContext> {

Callers

nothing calls this directly

Calls 2

to_resultMethod · 0.45
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected