pub struct BufferReadEvent<T: ClNumber> { /* private fields */ }Implementations§
Source§impl<T: ClNumber> BufferReadEvent<T>
impl<T: ClNumber> BufferReadEvent<T>
pub fn new(event: ClEvent, host_buffer: Option<Vec<T>>) -> BufferReadEvent<T>
Sourcepub fn wait(&mut self) -> Output<Option<Vec<T>>>
pub fn wait(&mut self) -> Output<Option<Vec<T>>>
Examples found in repository?
examples/ll_simple_add/main.rs (line 155)
127fn run_with_session() {
128 let src = include_str!("simple_add.ocl");
129 unsafe {
130 let mut session = SessionBuilder::new().with_program_src(src).build().unwrap();
131
132 let vec_a = vec![1i64, 2, 3];
133 let vec_b = vec![0i64, -1, -2];
134
135 let mut mem_a = session.create_mem(&vec_a[..]).unwrap();
136 let mut mem_b = session.create_mem(&vec_b[..]).unwrap();
137 let mut mem_c: ClMem = session.create_mem::<i64, usize>(vec_a.len()).unwrap();
138
139 let mut simple_add = session.create_kernel("simple_add").unwrap();
140
141 simple_add.set_arg(0, &mut mem_a).unwrap();
142 simple_add.set_arg(1, &mut mem_b).unwrap();
143 simple_add.set_arg(2, &mut mem_c).unwrap();
144 let work: Work = Work::new(vec_a.len());
145
146 let mut vec_c = vec_a.clone();
147
148 let enqueue_event = session
149 .enqueue_kernel(0, &mut simple_add, &work, None)
150 .unwrap();
151 let () = enqueue_event.wait().unwrap();
152 let mut read_event = session
153 .read_buffer(0, &mut mem_c, &mut vec_c[..], None)
154 .unwrap();
155 let read_output = read_event.wait().unwrap();
156 assert_eq!(read_output, None);
157
158 // at this point vec_c *should* be the result of calling simple_add and reading from mem_c;
159 println!(" {}", string_from_slice(&vec_a[..]));
160 println!("+ {}", string_from_slice(&vec_b[..]));
161 println!("= {}", string_from_slice(&vec_c[..]));
162 }
163}Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for BufferReadEvent<T>
impl<T> RefUnwindSafe for BufferReadEvent<T>where
T: RefUnwindSafe,
impl<T> !Send for BufferReadEvent<T>
impl<T> !Sync for BufferReadEvent<T>
impl<T> Unpin for BufferReadEvent<T>where
T: Unpin,
impl<T> UnwindSafe for BufferReadEvent<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more