Memory

Load and store

cuTile.loadFunction
load(arr::TileArray, index, shape; order=nothing, padding_mode=PaddingMode.Undetermined,
     check_bounds=true, latency=nothing, allow_tma=nothing) -> Tile

Load a tile from a TileArray at the given index with the specified shape. Index is 1-indexed. Shape must be compile-time constant.

Dimension Ordering

  • order: Optional tuple specifying the logical-to-physical dimension mapping (1-indexed). For example, order=(2, 1) indicates dimension 2 is contiguous in memory, enabling coalesced loads from transposed/permuted arrays. index[i] and shape[i] describe tile dim i, which maps to source dim order[i]. Default: nothing → identity (1, 2, ..., N).

Padding Modes

For a tile that partially extends beyond the array boundaries, out-of-bounds elements are filled according to padding_mode. If the tile lies entirely outside the array, the behavior is undefined regardless of padding_mode.

  • PaddingMode.Undetermined: Unspecified behavior for OOB access
  • PaddingMode.Zero: Return zero for OOB elements
  • PaddingMode.NegZero: Return negative zero for OOB elements
  • PaddingMode.Nan: Return NaN for OOB elements
  • PaddingMode.PosInf: Return positive infinity for OOB elements
  • PaddingMode.NegInf: Return negative infinity for OOB elements

Optimization Hints

  • check_bounds: Set to false to promise the entire tile is in bounds. Requires Tile IR v13.4+.
  • latency: Optional latency hint (1-10), or nothing for compiler default
  • allow_tma: Whether TMA (Tensor Memory Accelerator) is allowed (default: nothing, compiler decides)

Example

tile = ct.load(arr, (bid,), (TILE_N,); padding_mode=ct.PaddingMode.Zero, latency=3)

# Load from a transposed array with coalesced access
tile = ct.load(arr, (bidy, bidx), (TN, TM); order=(2, 1))
source
load(view::GatherScatterTileView, shape; padding_mode=PaddingMode.Undetermined,
     check_bounds=true, latency=nothing, allow_tma=nothing) -> Tile

Materialize a Julia gather/scatter view with an explicit static tile shape. The sparse tile index and dense range starts are one-based at this boundary.

source
cuTile.storeFunction
store(arr::TileArray, index, tile::Tile; order=nothing, check_bounds=true,
      latency=nothing, allow_tma=nothing) -> Tile

Store a tile to a TileArray at the given index. Index is 1-indexed. Returns the stored tile (enables chaining and helps constant folding).

For a tile that partially extends beyond the array boundaries, out-of-bounds elements are ignored. If the tile lies entirely outside the array, the behavior is undefined.

Dimension Ordering

  • order: Optional tuple specifying the logical-to-physical dimension mapping (1-indexed). Must match the order used in the corresponding load for permuted arrays. index[i] and shape[i] describe tile dim i, which maps to destination dim order[i]. Default: nothing → identity (1, 2, ..., N).

Optimization Hints

  • check_bounds: Set to false to promise the entire tile is in bounds. Requires Tile IR v13.4+.
  • latency: Optional latency hint (1-10), or nothing for compiler default
  • allow_tma: Whether TMA (Tensor Memory Accelerator) is allowed (default: nothing, compiler decides)
source
store(view::GatherScatterTileView, tile; check_bounds=true,
      latency=nothing, allow_tma=nothing) -> Tile

Store through a Julia gather/scatter view. Repeated sparse indices retain Tile IR's undefined conflicting-store semantics and are conservatively token-ordered.

source
cuTile.PaddingModeModule

Padding mode for load operations. Use these constants with ct.load to specify out-of-bounds behavior.

source

Gather and scatter

cuTile.gatherFunction
gather(array::TileArray{T, 1}, indices::Tile{I, S}; kwargs...) -> Tile{T, S}

Gather elements from a 1D array using index tile. Indices are 1-indexed. Out-of-bounds indices return padding_value (default: zero).

Keyword Arguments

  • mask: Optional Tile{Bool} — additional mask AND'd with automatic bounds check
  • padding_value: Value for masked-out elements (default: zero(T))
  • check_bounds::Bool: Compute automatic bounds mask (default: true). Set to false when indices are known to be in-bounds to skip the comparisons.
  • latency: Optional latency hint (1-10), or nothing for compiler default

Example

base = (bid - 1) * TILE
indices = base .+ ct.arange(TILE)
tile = ct.gather(arr, indices; mask=valid_mask, padding_value=-1.0f0)
source
gather(array::TileArray{T, 2}, indices::Tuple{Tile, Tile}; kwargs...) -> Tile{T, S}

Gather elements from a 2D array using a tuple of index tiles. Indices are 1-indexed. Index tiles are broadcast to a common shape.

Keyword Arguments

  • mask: Optional Tile{Bool} — additional mask AND'd with automatic bounds check
  • padding_value: Value for masked-out elements (default: zero(T))
  • check_bounds::Bool: Compute automatic bounds mask (default: true). Set to false when indices are known to be in-bounds to skip the comparisons.
  • latency: Optional latency hint (1-10), or nothing for compiler default
source
cuTile.scatterFunction
scatter(array::TileArray{T, 1}, indices::Tile{I, S}, tile::Tile{T, S}; kwargs...) -> Nothing

Scatter elements to a 1D array at index tile positions. Indices are 1-indexed. Out-of-bounds indices are ignored.

Keyword Arguments

  • mask: Optional Tile{Bool} — additional mask AND'd with automatic bounds check
  • check_bounds::Bool: Compute automatic bounds mask (default: true). Set to false when indices are known to be in-bounds to skip the comparisons.
  • latency: Optional latency hint (1-10), or nothing for compiler default

Example

base = (bid - 1) * TILE
indices = base .+ ct.arange(TILE)
ct.scatter(arr, indices, result_tile; mask=valid_mask)
source
scatter(array::TileArray{T, 2}, indices::Tuple{Tile, Tile}, tile::Tile; kwargs...) -> Nothing

Scatter elements to a 2D array at index tile positions. Indices are 1-indexed. Index tiles and value tile must broadcast to same shape.

Keyword Arguments

  • mask: Optional Tile{Bool} — additional mask AND'd with automatic bounds check
  • check_bounds::Bool: Compute automatic bounds mask (default: true). Set to false when indices are known to be in-bounds to skip the comparisons.
  • latency: Optional latency hint (1-10), or nothing for compiler default
source

Tile windows

cuTile.eachtileFunction
eachtile(a, tile_shape; step=nothing, order=nothing,
         padding_mode=PaddingMode.Undetermined)

Create an immutable device-side collection of fixed-shape tiles over a. step controls the distance between adjacent tile origins: the default and step == tile_shape create adjacent partitions, smaller values overlap, and larger values leave gaps. Unlike @view a[1:2:end], which changes element strides inside an array, eachtile changes tile origins.

order is the same 1-indexed logical-to-physical dimension mapping as the order kwarg of load/store: tile_shape[i], step[i], and tile index i describe tile dimension i, which maps to array dimension order[i].

Unequal tile shape and step require Tile IR bytecode v13.3 or newer. All are compile-time tuples; tile indices are 1-based and partial edge tiles use the given padding mode on loads and clipped stores.

source