pub struct Device {
pub name: String,
pub cc: String,
pub driver_version: String,
/* private fields */
}Expand description
An initialized CUDA device with a primary context retained.
Opening one is what a machine without a GPU cannot do; every other type here borrows from it, so nothing can outlive the context it was allocated in.
Fields§
§name: StringProduct name as the driver reports it, e.g. NVIDIA A10G.
cc: StringCompute capability as "<major>.<minor>".
driver_version: StringDriver version, recorded in results.v1 for provenance.
Implementations§
Source§impl Device
impl Device
Sourcepub fn open() -> Result<Self, String>
pub fn open() -> Result<Self, String>
Load the driver, initialize it, and retain a primary context on device 0.
Fails with a readable message rather than a panic when there is no driver to load — which is the normal state on CI and on the Mac.
Sourcepub fn load_module(&self, ptx: &str, entry: &str) -> Result<Module<'_>, String>
pub fn load_module(&self, ptx: &str, entry: &str) -> Result<Module<'_>, String>
Load PTX and resolve one entry function by name.
Sourcepub fn alloc(&self, bytes: usize) -> Result<Buffer<'_>, String>
pub fn alloc(&self, bytes: usize) -> Result<Buffer<'_>, String>
Allocate bytes of device memory.
Sourcepub fn copy_in(&self, buffer: &Buffer<'_>, data: &[u8]) -> Result<(), String>
pub fn copy_in(&self, buffer: &Buffer<'_>, data: &[u8]) -> Result<(), String>
Copy host bytes into a device buffer. data must fit.
Sourcepub fn copy_out(
&self,
buffer: &Buffer<'_>,
out: &mut [u8],
) -> Result<(), String>
pub fn copy_out( &self, buffer: &Buffer<'_>, out: &mut [u8], ) -> Result<(), String>
Copy device bytes back into a host slice. out must fit.
Sourcepub fn synchronize(&self) -> Result<(), String>
pub fn synchronize(&self) -> Result<(), String>
Block until the context’s queued work has finished.
Timings come from CUDA events rather than from wrapping this, so a
measurement excludes launch and transfer overhead that a real
application pays (docs/LIMITATIONS.md).