Skip to content

Commit 87a331e

Browse files
committed
Fix the missing cl_mem retain in opencl-af example
1 parent 8d076a6 commit 87a331e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

opencl-interop/examples/ocl_af_app.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use af_opencl_interop as afcl;
33
use arrayfire as af;
44

5-
use ocl_core::{ContextProperties, Event};
5+
use ocl_core::{retain_mem_object, ContextProperties, Event};
66

77
fn main() {
88
// Set the arrayfire backend to use OpenCL first,
@@ -20,7 +20,7 @@ fn main() {
2020
let dims = [8, 1, 1];
2121

2222
// Create a `Buffer`:
23-
let mut vec = vec![0.0f32; dims[0]];
23+
let mut vec = vec![1.0f32; dims[0]];
2424
let buffer = unsafe {
2525
ocl_core::create_buffer(
2626
&context,
@@ -37,6 +37,9 @@ fn main() {
3737
afcl::set_device_context(device_id.as_raw(), context.as_ptr());
3838
af::info();
3939

40+
unsafe {
41+
retain_mem_object(&buffer).unwrap();
42+
}
4043
let mut af_buffer = af::Array::new_from_device_ptr(
4144
buffer.as_ptr() as *mut f32,
4245
af::Dim4::new(&[dims[0] as u64, 1, 1, 1]),

0 commit comments

Comments
 (0)