Skip to content

Commit

Permalink
Declare set_len unsafe for issue #69
Browse files Browse the repository at this point in the history
  • Loading branch information
kenba committed Dec 15, 2024
1 parent 96df90b commit 5c8e67b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/svm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'a, T> SvmVec<'a, T> {
///
/// # Safety
/// May fail to grow buf if memory is not available for new_len.
pub fn set_len(&mut self, new_len: usize) -> Result<()> {
pub unsafe fn set_len(&mut self, new_len: usize) -> Result<()> {
if self.cap() < new_len {
self.buf.grow(new_len)?;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ fn test_opencl_svm_example() -> Result<()> {
println!("kernel execution duration (ns): {}", duration);
} else {
// !is_fine_grained_svm
// unsafe { ones.set_len(ARRAY_SIZE) };
// unsafe { sums.set_len(ARRAY_SIZE) };

// Map the input SVM vectors, before setting their data
// Resize and map the input SVM vectors, before setting their data
unsafe {
ones.set_len(ARRAY_SIZE)?;
sums.set_len(ARRAY_SIZE)? ;
queue.enqueue_svm_map(CL_BLOCKING, CL_MAP_WRITE, &mut ones, &[])?;
queue.enqueue_svm_map(CL_BLOCKING, CL_MAP_WRITE, &mut sums, &[])?;
}
Expand Down

0 comments on commit 5c8e67b

Please sign in to comment.