Skip to main content

Machine

Enum Machine 

Source
pub enum Machine {
    Asic,
    GpuInt,
    GpuFloat,
}
Expand description

Which machine to run on.

Variants§

§

Asic

The CMOS annealing ASIC. 384×384 sites, four-bit coefficients.

§

GpuInt

GPU, 32-bit integer coefficients. 512×512 sites.

§

GpuFloat

GPU, 32-bit float coefficients. 512×512 sites.

Implementations§

Source§

impl Machine

Source

pub fn side(self) -> usize

Grid side. Sites are side × side.

Examples found in repository?
examples/hitachi_run.rs (line 19)
9fn main() {
10    let mut d = match Hitachi::from_env(Machine::Asic) {
11        Ok(d) => d,
12        Err(e) => { eprintln!("{e}"); return; }
13    };
14    let f = d.fabric();
15    println!("fabric        {} | {:?} | {} sites | degree {} | coupling {:?}",
16             f.name, f.topology, f.max_spins.unwrap(), f.max_degree.unwrap(), f.coupling_precision);
17
18    // A 4x4 antiferromagnetic block, laid out row-major so every coupling is King-adjacent.
19    let side = Machine::Asic.side();
20    let mut src = format!("ftp 1\nname acw-4x4-antiferro\nspins {}\n", 3 * side + 4);
21    let mut edges = 0;
22    for y in 0..4usize {
23        for x in 0..4usize {
24            let i = y * side + x;
25            if x + 1 < 4 { src.push_str(&format!("factor -1 {i} {}\n", i + 1)); edges += 1; }
26            if y + 1 < 4 { src.push_str(&format!("factor -1 {i} {}\n", i + side)); edges += 1; }
27        }
28    }
29    let p = Program::from_ftp(&src).expect("program");
30    println!("program       {} spins declared, {edges} couplings, digest {:016x}", p.spins, p.digest());
31
32    let bad = d.program(&p);
33    if !bad.is_empty() {
34        for u in &bad { println!("REFUSED: {u}"); }
35        return;
36    }
37
38    match d.run(&Schedule::geometric(0.1, 10.0, 20, 50), 1) {
39        Err(e) => println!("run failed: {e}"),
40        Ok(state) => {
41            let g = p.to_graph().unwrap();
42            println!("machine energy (their sign) {:?}", d.last_energies);
43            println!("execution     {:.3} ms on the ASIC", d.last_execution_ns as f64 / 1e6);
44            println!("our energy    {}", g.energy(&state));
45            let ok = (0..4).all(|y| (0..4).all(|x| {
46                let i = y * side + x;
47                state[i] == if (x + y) % 2 == 0 { state[0] } else { -state[0] }
48            }));
49            println!("checkerboard  {}", if ok { "yes - every bond satisfied" } else { "no" });
50            println!("ledger        {} node updates", d.ledger().samples);
51        }
52    }
53}

Trait Implementations§

Source§

impl Clone for Machine

Source§

fn clone(&self) -> Machine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Machine

Source§

impl Debug for Machine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Machine

Source§

impl PartialEq for Machine

Source§

fn eq(&self, other: &Machine) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Machine

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.