summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs2
-rw-r--r--src/solvers/gpu/manager.rs19
-rw-r--r--src/solvers/gpusolver.rs5
3 files changed, 22 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index cfc4cb0..c7997bb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,7 +3,7 @@ mod solvers;
mod structs;
use crate::solvers::{IteratorSolver, Solver};
-pub static N: u32 = 8;
+pub static N: u32 = 6;
fn main() {
//let mut solver = solvers::single::NormalSolver::new(N);
//solver.solve();
diff --git a/src/solvers/gpu/manager.rs b/src/solvers/gpu/manager.rs
index ede6a85..42af314 100644
--- a/src/solvers/gpu/manager.rs
+++ b/src/solvers/gpu/manager.rs
@@ -27,6 +27,9 @@ impl RequestBuffer {
}
None
}
+ fn flush(&mut self) {
+ while self.read(CheckRequest::new(vec![], 0, 0)).is_none() {}
+ }
}
pub struct OclManager {
@@ -118,7 +121,21 @@ impl OclManager {
}
}
Message::CpuDone => {
- //TODO panic!("flush buffers");
+ for (i, b) in self.buffers.iter_mut().enumerate() {
+ b.flush();
+ self.host_sender
+ .send(Message::HostMessage((
+ self.job_id,
+ i as u32,
+ b.mask_buff.clone(),
+ )))
+ .unwrap();
+ self.output_sender
+ .send(Message::OutputMessage((self.job_id, b.row_buff.clone())))
+ .unwrap();
+ self.job_id += 1;
+ }
+ println!("flushing buffers");
self.host_sender.send(Message::CpuDone);
self.host_handle.take().unwrap().join();
}
diff --git a/src/solvers/gpusolver.rs b/src/solvers/gpusolver.rs
index 36c6328..99274cb 100644
--- a/src/solvers/gpusolver.rs
+++ b/src/solvers/gpusolver.rs
@@ -33,6 +33,7 @@ impl GpuSolver {
while let Ok(Message::RowResult(wall)) = receiver.recv() {
walls.push(wall);
}
+ sender.send(Message::Terminate).unwrap();
//println!("{:?}", walls);
handle.join().unwrap();
walls
@@ -96,10 +97,10 @@ impl GpuSolver {
if index == 1 {
let mut data = self.progress.lock().unwrap();
*data += 1;
- let bias = self.n - (self.h - 1 - index as u32);
+ let bias = self.n - (self.h - 1);
println!(
"progress: {}%",
- *data as f64 / self.chunk as f64 * 100.0 / bias as f64
+ *data as f64 / self.chunk as f64 * 50.0 / bias as f64
);
}
}