Skip to main content

Tile

Struct Tile 

Source
pub struct Tile<const SIZE: usize> { /* private fields */ }
Expand description

A thread block tile of SIZE threads.

All threads within a tile are guaranteed active — shuffle is always safe. Created by partitioning a Warp<All> via warp.tile::<N>().

§Supported Sizes

4, 8, 16, 32 — matching NVIDIA’s cooperative groups API. Only power-of-two sizes that divide 32 are valid.

Implementations§

Source§

impl<const SIZE: usize> Tile<SIZE>
where Tile<SIZE>: ValidTileSize,

Source

pub fn shuffle_xor<T: GpuValue + GpuShuffle>( &self, data: PerLane<T>, mask: u32, ) -> PerLane<T>

Shuffle XOR within the tile.

Each thread exchanges with the thread at (thread_rank XOR mask) within the tile. Caller must ensure mask < SIZE (no automatic clamping).

Always safe: all SIZE threads in the tile participate.

On GPU: emits shfl.sync.bfly.b32 with c = ((32-SIZE)<<8)|0x1F, confining the shuffle to SIZE-lane segments.

Source

pub fn shuffle_down<T: GpuValue + GpuShuffle>( &self, data: PerLane<T>, delta: u32, ) -> PerLane<T>

Shuffle down within the tile (confined to tile-sized segments).

Source

pub fn reduce_sum<T: GpuValue + GpuShuffle + Add<Output = T>>( &self, data: PerLane<T>, ) -> T

Sum reduction across all tile lanes.

Uses butterfly reduction with log2(SIZE) shuffle-XOR steps.

Source

pub fn inclusive_sum<T: GpuValue + GpuShuffle + Add<Output = T>>( &self, data: PerLane<T>, ) -> PerLane<T>

👎Deprecated:

Not correct on any target — Hillis-Steele without lane_id guard. Use SimWarp for tested scan.

Inclusive prefix sum within the tile.

WARNING: Not correct on any target. On CPU, shfl_up is identity, so each stage doubles (result: val × SIZE). On GPU, lanes where lane_id < stride get clamped (own value), doubling instead of preserving. Needs if lane_id >= stride guard (requires lane_id()). Retained for type-system demonstration.

Source

pub const fn size(&self) -> usize

Number of threads in this tile.

Source§

impl Tile<32>

Source

pub fn partition_16(&self) -> Tile<16>

Sub-partition into tiles of 16.

Source

pub fn partition_8(&self) -> Tile<8>

Sub-partition into tiles of 8.

Source

pub fn partition_4(&self) -> Tile<4>

Sub-partition into tiles of 4.

Source§

impl Tile<16>

Source

pub fn partition_8(&self) -> Tile<8>

Sub-partition into tiles of 8.

Source

pub fn partition_4(&self) -> Tile<4>

Sub-partition into tiles of 4.

Source§

impl Tile<8>

Source

pub fn partition_4(&self) -> Tile<4>

Sub-partition into tiles of 4.

Trait Implementations§

Source§

impl ValidTileSize for Tile<16>

Source§

const TILE_MASK: u32 = 0xFFFF

Mask for this tile within a warp (based on thread position).
Source§

impl ValidTileSize for Tile<32>

Source§

const TILE_MASK: u32 = 0xFFFFFFFF

Mask for this tile within a warp (based on thread position).
Source§

impl ValidTileSize for Tile<4>

Source§

const TILE_MASK: u32 = 0xF

Mask for this tile within a warp (based on thread position).
Source§

impl ValidTileSize for Tile<8>

Source§

const TILE_MASK: u32 = 0xFF

Mask for this tile within a warp (based on thread position).

Auto Trait Implementations§

§

impl<const SIZE: usize> Freeze for Tile<SIZE>

§

impl<const SIZE: usize> RefUnwindSafe for Tile<SIZE>

§

impl<const SIZE: usize> Send for Tile<SIZE>

§

impl<const SIZE: usize> Sync for Tile<SIZE>

§

impl<const SIZE: usize> Unpin for Tile<SIZE>

§

impl<const SIZE: usize> UnsafeUnpin for Tile<SIZE>

§

impl<const SIZE: usize> UnwindSafe for Tile<SIZE>

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.