diff --git a/src/svm.rs b/src/svm.rs index b1f2fc6..56eb568 100644 --- a/src/svm.rs +++ b/src/svm.rs @@ -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)?; } diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 1559057..73cca9b 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -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, &[])?; }