pub struct Device { /* private fields */ }Expand description
Where a program runs.
Cloning is cheap: the GPU handle is shared, so two clones name the same adapter and the same uploaded buffers.
Implementations§
Source§impl Device
impl Device
Sourcepub fn default_gpu() -> Option<Device>
pub fn default_gpu() -> Option<Device>
The machine’s preferred adapter, or None where there is none.
The adapter is opened once per process and shared; asking twice costs nothing and hands back the same device.
Sourcepub fn with_precision(&self, p: Precision) -> Device
pub fn with_precision(&self, p: Precision) -> Device
The same device, computing in p.
Precision::F32 is an explicit request to compute a f64 program in
single precision. It is the only way a machine whose shaders have no
f64 runs anything at all on its GPU.
pub fn precision(&self) -> Precision
pub fn is_gpu(&self) -> bool
Sourcepub fn info(&self) -> Option<&DeviceInfo>
pub fn info(&self) -> Option<&DeviceInfo>
What this device is, or None for the CPU.
Sourcepub fn upload(&self, y: &Array) -> Result<Array, DeviceError>
pub fn upload(&self, y: &Array) -> Result<Array, DeviceError>
y with its elements resident on this device.
The result is an ordinary array — same shape, same values, readable by anything — that additionally holds the device allocation, so a run that reaches the device with it uploads nothing. Uploading to the CPU is the identity.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Device
impl !UnwindSafe for Device
impl Freeze for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnsafeUnpin for Device
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more