Skip to content
Snippets Groups Projects
Commit f7a35a6d authored by Russel Arbore's avatar Russel Arbore
Browse files

use box in dot test

parent 69d7a09c
No related branches found
No related tags found
1 merge request!190Set up cava benchmark
Pipeline #201763 failed
...@@ -2,36 +2,20 @@ ...@@ -2,36 +2,20 @@
#[cfg(feature = "cuda")] #[cfg(feature = "cuda")]
use hercules_rt::CUDABox; use hercules_rt::CUDABox;
use hercules_rt::{runner, HerculesCPURef}; use hercules_rt::{runner, HerculesImmBox, HerculesImmBoxTo};
juno_build::juno!("dot"); juno_build::juno!("dot");
fn main() { fn main() {
async_std::task::block_on(async { async_std::task::block_on(async {
#[cfg(not(feature = "cuda"))] let a: [f32; 8] = [0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0];
{ let b: [f32; 8] = [0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0];
let a: [f32; 8] = [0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0]; let a = HerculesImmBox::from(&a as &[f32]);
let a = HerculesCPURef::from_slice(&a); let b = HerculesImmBox::from(&b as &[f32]);
let b: [f32; 8] = [0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0]; let mut r = runner!(dot);
let b = HerculesCPURef::from_slice(&b); let c = r.run(8, a.to(), b.to()).await;
let mut r = runner!(dot); println!("{}", c);
let c = r.run(8, a, b).await; assert_eq!(c, 70.0);
println!("{}", c);
assert_eq!(c, 70.0);
}
#[cfg(feature = "cuda")]
{
let mut a: [f32; 8] = [0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0];
let a_box = CUDABox::from_cpu_ref(HerculesCPURef::from_slice(&mut a));
let a = a_box.get_ref();
let mut b: [f32; 8] = [0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0];
let b_box = CUDABox::from_cpu_ref(HerculesCPURef::from_slice(&mut b));
let b = b_box.get_ref();
let mut r = runner!(dot);
let c = r.run(8, a, b).await;
println!("{}", c);
assert_eq!(c, 70.0);
}
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment