Skip to content

Commit

Permalink
fix non unified memory comp for ocl
Browse files Browse the repository at this point in the history
  • Loading branch information
elftausend committed Jan 12, 2024
1 parent 5a58573 commit bf783b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/devices/opencl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ impl<T> HasId for CLPtr<T> {
}
}

impl<T> CLPtr<T> {
pub fn len(&self) -> usize {
self.len
}
}

impl<T> ShallowCopy for CLPtr<T> {
#[inline]
unsafe fn shallow(&self) -> Self {
Expand Down Expand Up @@ -116,6 +122,7 @@ impl<T> HostPtr<T> for CLPtr<T> {
}
}

#[cfg(unified_cl)]
impl<T> Deref for CLPtr<T> {
type Target = [T];

Expand All @@ -125,6 +132,7 @@ impl<T> Deref for CLPtr<T> {
}
}

#[cfg(unified_cl)]
impl<T> DerefMut for CLPtr<T> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
Expand Down
5 changes: 4 additions & 1 deletion src/devices/opencl/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ where
Ok(())
}
#[cfg(not(unified_cl))]
try_cl_apply_fn_mut(dev, buf, out, f);
{
try_cl_apply_fn_mut(dev, buf, out, **f)?;
Ok(())
}
})
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/two_way_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub mod tests_ex {

let buf = device.apply_fn(&buf, |x| x.mul(2.).add(4.).sin().mul(x).add(1.));
roughly_eq_slices(
buf.read(),
&buf.read(),
&[
-0.6320633326681093,
-0.6320633326681093,
Expand Down

0 comments on commit bf783b2

Please sign in to comment.