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(()) # } ```
()
| 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> { |
nothing calls this directly
no test coverage detected