pub trait UnalignedVector<E: Scalar, N: Size>:
RudaType
+ Sized
+ RudaType<ExpandType: UnalignedVectorExpand<E, N>> {
// Required methods
fn unaligned_vector_read(&self, index: usize) -> Vector<E, N>;
fn unaligned_vector_write(&mut self, index: usize, value: Vector<E, N>);
// Provided methods
fn __expand_unaligned_vector_read(
scope: &mut Scope,
this: <Self as RudaType>::ExpandType,
index: <usize as RudaType>::ExpandType,
) -> <Vector<E, N> as RudaType>::ExpandType { ... }
fn __expand_unaligned_vector_write(
scope: &mut Scope,
this: <Self as RudaType>::ExpandType,
index: <usize as RudaType>::ExpandType,
value: <Vector<E, N> as RudaType>::ExpandType,
) -> <() as RudaType>::ExpandType { ... }
}Expand description
An extension trait for expanding the ruda frontend with the ability to request unaligned vector reads and writes
Typically in ruda, a buffer is declared as having a certain vector size
at kernel compilation time. The buffer can then be indexed to produce
vectors that are aligned to the vector_size.
This trait allows the user to request a vector_read from a buffer where the
start of the read is not aligned to the vector_read requested.
As an example, imagine a buffer of scalar length 4. With vector_size = 1,
this could be illustrated like so
[1, 2, 3, 4]
Imagine the same buffer, now with vector_size = 2.
[[1, 2], [3, 4]]
Vectors can now be accessed from this buffer, but only those that that are aligned
with the vector_size. I.e. we can get the vectors [1, 2] or [3, 4], but not [2, 3]
This trait allows you to treat the buffer as having no vector_size = 1, yet asking
for a vector of some kernel-compile-time known length at some offset in the buffer.
I.e. if for the buffer buf = [1, 2, 3, 4], buf.unaligned_vector_read(1, 2)
will produce the vector [2, 3].
Required Methods§
Sourcefn unaligned_vector_read(&self, index: usize) -> Vector<E, N>
fn unaligned_vector_read(&self, index: usize) -> Vector<E, N>
Perform an unchecked read of a vector of the given length at the given index
§Safety
Out of bounds indexing causes undefined behaviour and may segfault. Ensure index..index+vector_size is
always in bounds
Sourcefn unaligned_vector_write(&mut self, index: usize, value: Vector<E, N>)
fn unaligned_vector_write(&mut self, index: usize, value: Vector<E, N>)
Perform an unchecked write of a vector of the given length at the given index
§Safety
Out of bounds indexing causes undefined behaviour and may segfault. Ensure index..index+vector_size is
always in bounds
Provided Methods§
fn __expand_unaligned_vector_read( scope: &mut Scope, this: <Self as RudaType>::ExpandType, index: <usize as RudaType>::ExpandType, ) -> <Vector<E, N> as RudaType>::ExpandType
fn __expand_unaligned_vector_write( scope: &mut Scope, this: <Self as RudaType>::ExpandType, index: <usize as RudaType>::ExpandType, value: <Vector<E, N> as RudaType>::ExpandType, ) -> <() as RudaType>::ExpandType
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".