Swizzle

Struct Swizzle 

Source
pub struct Swizzle { /* private fields */ }
Expand description

Swizzling strategy for a buffer. See the following docs from cutlass:

0bxxxxxxxxxxxxxxxYYYxxxxxxxZZZxxxx ^–^ MBase is the number of least-sig bits to keep constant ^-^ ^-^ BBits is the number of bits in the mask ^———^ SShift is the distance to shift the YYY mask (pos shifts YYY to the right, neg shifts YYY to the left)

§Example

Given: 0bxxxxxxxxxxxxxxxxYYxxxxxxxxxZZxxx the result is: 0bxxxxxxxxxxxxxxxxYYxxxxxxxxxAAxxx where AA = ZZ xor YY

Some newer features, as well as cutlass in places, use a different terminology of span and atom. For shared memory swizzle specifically, the parameters map as follows:

  • bits = log2(span / atom), or the number of atoms within one span, converted to address bits
  • base = log2(atom), the size of the atom, converted to address bits
  • shift = log2(all_banks_bytes / atom), or the total number of atoms in all 32 shared memory banks, converted to address bits

For example:

  • 32-byte span with a 16-byte atom = [1, 4, 3]
  • 128-byte span with a 32-byte atom = [3, 5, 2]

Implementations§

Source§

impl Swizzle

Source

pub fn new(bits: u32, base: u32, shift: i32) -> Self

Create a new swizzle with comptime parameters

Source

pub fn none() -> Self

Create a new noop swizzle object

Source

pub fn apply(&self, offset: u32, type_size: u32) -> u32

Apply the swizzle to a coordinate with a given item size. This is the size of the full type, including line size. Use type_size helper for lines. offset should be in terms of lines from the start of the buffer, and the buffer should be aligned to repeats_after. This is to work around the fact we don’t currently support retrieving the actual address of an offset. If you’re using absolute/unlined indices, pass E::type_size() instead of the full line size.

Source

pub fn repeats_after(&self) -> u32

After how many elements this pattern repeats. Can be used to align the buffer (i.e. smem) so offsets match addresses.

Source

pub fn __expand_new( scope: &mut Scope, bits: u32, base: u32, shift: i32, ) -> <Self as CubeType>::ExpandType

Source

pub fn __expand_none(scope: &mut Scope) -> <Self as CubeType>::ExpandType

Source

pub fn __expand_apply( scope: &mut Scope, this: <Self as CubeType>::ExpandType, offset: <u32 as CubeType>::ExpandType, type_size: u32, ) -> <u32 as CubeType>::ExpandType

Source

pub fn __expand_repeats_after( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> u32

Trait Implementations§

Source§

impl Clone for Swizzle

Source§

fn clone(&self) -> Swizzle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CubeType for Swizzle

Source§

type ExpandType = SwizzleExpand

Source§

fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType

Wrapper around the init method, necessary to type inference.
Source§

impl LaunchArg for Swizzle

Source§

type RuntimeArg<'a, R: Runtime> = SwizzleLaunch<'a, R>

The runtime argument for the kernel.
Source§

type CompilationArg = SwizzleCompilationArg

Compilation argument.
Source§

fn compilation_arg<'a, R: Runtime>( runtime_arg: &Self::RuntimeArg<'a, R>, ) -> Self::CompilationArg

Source§

fn expand( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType

Register an input variable during compilation that fill the KernelBuilder.
Source§

fn expand_output( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType

Register an output variable during compilation that fill the KernelBuilder.
Source§

impl Copy for Swizzle

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V