Struct BufferReadEvent

Source
pub struct BufferReadEvent<T: ClNumber> { /* private fields */ }

Implementations§

Source§

impl<T: ClNumber> BufferReadEvent<T>

Source

pub fn new(event: ClEvent, host_buffer: Option<Vec<T>>) -> BufferReadEvent<T>

Source

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§

Source§

impl<T: ClNumber> Drop for BufferReadEvent<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.