Skip to content

Conversation

LeonHibnik
Copy link
Contributor

Describe the changes

This PR adds support for using icicle_memset in icicle rust wrapper

Linked Issues

Resolves #

(optional) CUDA backend branch

cuda-backend-branch: main # specify the branch here

@LeonHibnik LeonHibnik requested a review from yshekel April 8, 2025 11:57
return Ok(());
}
if !self.is_on_active_device() {
panic!("not allocated on an inactive device");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is wrong

@@ -241,6 +241,30 @@ impl<T> DeviceSlice<T> {
.wrap()
}
}

pub fn memset(&mut self, value: u8) -> Result<(), eIcicleError> {
Copy link
Collaborator

@yshekel yshekel Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it take size too? Does it set the entire slice?

&mut self[..]
}

pub fn memset(&mut self, value: u8) -> Result<(), eIcicleError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we can memset a deviceSlice why do we need it also for DeviceVec?
And here also it's memset the entire vector but usually we want to to memset offset+:size.

Can we implement it on HostOrDeviceSlice instead? If yes then we can memset any memory with offest+size, regardless being host/device memory. We probably also would need to sub-slice HostOrDeviceSlice to be fully flexible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved impl to HostOrDeviceSlice

@@ -81,6 +84,32 @@ impl<T> HostOrDeviceSlice<T> for HostSlice<T> {
fn is_empty(&self) -> bool {
self.len() == 0
}

fn memset(&mut self, value: u8, size: usize) -> Result<(), eIcicleError> {
if size == 0 || self.is_empty() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a strange case, why not panic? should be super rare but why would someone do it?

@LeonHibnik LeonHibnik merged commit 119fccf into main Apr 10, 2025
18 checks passed
@LeonHibnik LeonHibnik deleted the feat/rust-memset branch April 10, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants