Skip to content
Snippets Groups Projects

Set up cava benchmark

Merged rarbore2 requested to merge cava_opt_3 into main
1 file
+ 9
25
Compare changes
  • Side-by-side
  • Inline
@@ -2,36 +2,20 @@
#[cfg(feature = "cuda")]
use hercules_rt::CUDABox;
use hercules_rt::{runner, HerculesCPURef};
use hercules_rt::{runner, HerculesImmBox, HerculesImmBoxTo};
juno_build::juno!("dot");
fn main() {
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 a = HerculesCPURef::from_slice(&a);
let b: [f32; 8] = [0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0];
let b = HerculesCPURef::from_slice(&b);
let mut r = runner!(dot);
let c = r.run(8, a, b).await;
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);
}
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 = HerculesImmBox::from(&a as &[f32]);
let b = HerculesImmBox::from(&b as &[f32]);
let mut r = runner!(dot);
let c = r.run(8, a.to(), b.to()).await;
println!("{}", c);
assert_eq!(c, 70.0);
});
}
Loading