pub struct Gpu { /* private fields */ }Expand description
A GPU that can run the sweep.
Holds a device and queue. Creating one enumerates adapters, which is slow enough that it should happen once per process rather than once per sweep.
Implementations§
Source§impl Gpu
impl Gpu
Sourcepub fn new() -> Option<Gpu>
pub fn new() -> Option<Gpu>
Open the default adapter, or None if this machine exposes none.
None means not found on this machine, never “impossible”. A headless CI runner with no
driver is the common case, which is why every test here skips rather than fails on it.
Sourcepub fn adapter(&self) -> &AdapterInfo
pub fn adapter(&self) -> &AdapterInfo
What the driver says this is.
Read it before quoting a speedup. DeviceType::Cpu is a software rasteriser — lavapipe,
SwiftShader, WARP — which runs the shader correctly and tells you nothing about a GPU, and a
benchmark that does not check this reports the wrong machine with full confidence.
Sourcepub fn is_hardware(&self) -> bool
pub fn is_hardware(&self) -> bool
True when the adapter is real silicon rather than a software rasteriser.
Sourcepub fn sweep(
&self,
m: &GpuModel,
spins: &mut [i8],
beta: f64,
sweeps: u32,
) -> Result<(), String>
pub fn sweep( &self, m: &GpuModel, spins: &mut [i8], beta: f64, sweeps: u32, ) -> Result<(), String>
Run sweeps chromatic sweeps over spins, in place.
One dispatch per colour class per sweep, which is what makes the update correct: nodes in a class share no edge, so they can be resampled simultaneously without any of them reading a neighbour another lane is writing. Dispatching all nodes at once would be faster and wrong.