singe-cuda 0.1.0-alpha.6

Safe Rust wrappers for CUDA driver, runtime, NVRTC, NVVM, NVTX, memory, streams, modules, and graphs.
Documentation
#[allow(unused_imports)]
use crate::error::Status;

use singe_cuda_sys::driver;

use crate::{error::Result, try_ffi};

/// Returns the version of CUDA supported by the driver.
/// The version is returned as `1000 * major + 10 * minor`.
/// For example, CUDA 9.2 would be represented by 9020.
///
/// # Errors
///
/// Returns an error if CUDA cannot query the driver version or if a previous asynchronous launch
/// reported an error.
pub fn version() -> Result<i32> {
    let mut version: i32 = 0;
    unsafe {
        try_ffi!(driver::cuDriverGetVersion(&raw mut version))?;
    }
    Ok(version)
}

#[cfg(all(test, feature = "testing"))]
mod tests {
    use super::*;
    use crate::testing;

    #[test]
    fn it_works() {
        match version() {
            Ok(version) => assert_ne!(version, 0),
            Err(error) if testing::is_stub_library(&error) => {}
            Err(error) => panic!("{error:?}"),
        }
    }
}