Skip to content

Commit

Permalink
Wrestle with coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Oct 18, 2024
1 parent bec3ac6 commit 0a454af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
27 changes: 3 additions & 24 deletions yard-rs/krnl-xp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Adapted from krnl official example
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![feature(stmt_expr_attributes)]

use krnl::{
macros::module,
anyhow::Result,
device::Device,
buffer::{Buffer, Slice, SliceMut},
anyhow::{anyhow, Result}, buffer::{Buffer, Slice, SliceMut}, device::Device, macros::module
};

#[module]
Expand Down Expand Up @@ -48,23 +44,7 @@ fn saxpy(alpha: f32, x: Slice<f32>, mut y: SliceMut<f32>) -> Result<()> {
return Ok(());
}

let build_kernel =
#[cfg_attr(coverage_nightly, coverage(off))]
| | {
if true {
kernels::saxpy::builder()?
.build(y.device())?
.dispatch(alpha, x, y)
} else {
// or
kernels::saxpy_global::builder()?
.build(y.device())?
.with_global_threads(y.len() as u32)
.dispatch(alpha, x, y)
}
};

build_kernel()
return Err(anyhow!("slice not on host"));
}

pub fn run_saxpy() -> Result<Vec<f32>> {
Expand All @@ -76,6 +56,5 @@ pub fn run_saxpy() -> Result<Vec<f32>> {
let mut y = Buffer::from(y).into_device(device.clone())?;
saxpy(alpha, x.as_slice(), y.as_slice_mut())?;
let y = y.into_vec()?;
// println!("{y:?}");
Ok(y)
}
}
2 changes: 1 addition & 1 deletion yard-rs/krnl-xp/tests/test_saxpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ fn test_saxpy() {
assert!(res.is_ok());
let y = res.unwrap();
assert_eq!(y, vec![2.0]);
}
}

0 comments on commit 0a454af

Please sign in to comment.