Skip to content
Snippets Groups Projects
Commit 44edca09 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'ref-into' into 'main'

HerculesRefInto trait

See merge request !185
parents 3a178bba de396b2c
No related branches found
No related tags found
1 merge request!185HerculesRefInto trait
Pipeline #201719 passed
......@@ -811,3 +811,19 @@ where
self.as_cuda_ref()
}
}
pub trait HerculesRefInto<'a> {
fn to(&'a self) -> HerculesCPURef<'a>;
}
impl<'a, T> HerculesRefInto<'a> for &'a [T] {
fn to(&'a self) -> HerculesCPURef<'a> {
HerculesCPURef::from_slice(self)
}
}
impl<'a, T> HerculesRefInto<'a> for Box<[T]> {
fn to(&'a self) -> HerculesCPURef<'a> {
HerculesCPURef::from_slice(self)
}
}
......@@ -2,9 +2,9 @@
use rand::random;
use hercules_rt::{runner, HerculesRefInto};
#[cfg(feature = "cuda")]
use hercules_rt::CUDABox;
use hercules_rt::{runner, HerculesCPURef};
use hercules_rt::{CUDABox, HerculesCPURef};
juno_build::juno!("matmul");
......@@ -25,12 +25,8 @@ fn main() {
}
#[cfg(not(feature = "cuda"))]
{
let a = HerculesCPURef::from_slice(&a);
let b = HerculesCPURef::from_slice(&b);
let mut r = runner!(matmul);
let c = r
.run(I as u64, J as u64, K as u64, a.clone(), b.clone())
.await;
let c = r.run(I as u64, J as u64, K as u64, a.to(), b.to()).await;
assert_eq!(c.as_slice::<i32>(), &*correct_c);
}
#[cfg(feature = "cuda")]
......
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