pub mod host; pub mod manager; pub mod output; pub use manager::*; type MaskMessage = (u64, u32, Vec); type RowMessage = (u64, Vec>); #[derive(Debug)] pub enum Message { CheckRequest(CheckRequest), HostMessage(MaskMessage), OutputMessage(RowMessage), ResultMessage(ResultMessage), RowResult(RowResult), Terminate, CpuDone, GpuDone, } #[derive(Debug)] pub struct ResultMessage { data: Vec, offset: usize, size: usize, wg_size: usize, id: u64, } impl ResultMessage { fn new(data: Vec, offset: usize, size: usize, wg_size: usize, id: u64) -> Self { Self { data, offset, size, wg_size, id, } } fn valid_walls(&self) -> Vec> { let mut result = vec![Vec::new(); self.wg_size]; for (j, r) in self.data.iter().enumerate() { for b in 0..64 { if r & (1 << b) != 0 { let permutation = j / self.size + self.offset; let instruction = (j % self.size) * 64 + b; result[instruction].push(permutation as u32); } } } result } } #[derive(Debug)] pub struct CheckRequest { rows: Vec, bitmask: u64, queue: u32, } impl CheckRequest { pub fn new(rows: Vec, bitmask: u64, queue: u32) -> Self { Self { rows, bitmask, queue, } } } #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub struct RowResult { rows: Vec, } impl RowResult { fn new(mut rows: Vec) -> Self { //rows.push(0); rows.sort(); Self { rows } } fn output(&self) { /*let s = self .rows .iter() .fold(String::new(), |s, d| s + &d.to_string() + " "); println!("{}", s);*/ let i = self.rows[0]; for r in self.rows.iter() { println!("{}\t{}", i, r); } } }