Memory
Load and store
cuTile.load — Function
load(arr::TileArray, index, shape; order=nothing, padding_mode=PaddingMode.Undetermined,
check_bounds=true, latency=nothing, allow_tma=nothing) -> TileLoad 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]andshape[i]describe tile dimi, which maps to source dimorder[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 accessPaddingMode.Zero: Return zero for OOB elementsPaddingMode.NegZero: Return negative zero for OOB elementsPaddingMode.Nan: Return NaN for OOB elementsPaddingMode.PosInf: Return positive infinity for OOB elementsPaddingMode.NegInf: Return negative infinity for OOB elements
Optimization Hints
check_bounds: Set tofalseto promise the entire tile is in bounds. Requires Tile IR v13.4+.latency: Optional latency hint (1-10), or nothing for compiler defaultallow_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))load(view::GatherScatterTileView, shape; padding_mode=PaddingMode.Undetermined,
check_bounds=true, latency=nothing, allow_tma=nothing) -> TileMaterialize 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.
cuTile.store — Function
store(arr::TileArray, index, tile::Tile; order=nothing, check_bounds=true,
latency=nothing, allow_tma=nothing) -> TileStore 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 theorderused in the correspondingloadfor permuted arrays.index[i]andshape[i]describe tile dimi, which maps to destination dimorder[i]. Default:nothing→ identity(1, 2, ..., N).
Optimization Hints
check_bounds: Set tofalseto promise the entire tile is in bounds. Requires Tile IR v13.4+.latency: Optional latency hint (1-10), or nothing for compiler defaultallow_tma: Whether TMA (Tensor Memory Accelerator) is allowed (default: nothing, compiler decides)
store(view::GatherScatterTileView, tile; check_bounds=true,
latency=nothing, allow_tma=nothing) -> TileStore through a Julia gather/scatter view. Repeated sparse indices retain Tile IR's undefined conflicting-store semantics and are conservatively token-ordered.
cuTile.PaddingMode — Module
Padding mode for load operations. Use these constants with ct.load to specify out-of-bounds behavior.
Gather and scatter
cuTile.gather — Function
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: OptionalTile{Bool}— additional mask AND'd with automatic bounds checkpadding_value: Value for masked-out elements (default:zero(T))check_bounds::Bool: Compute automatic bounds mask (default:true). Set tofalsewhen 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)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: OptionalTile{Bool}— additional mask AND'd with automatic bounds checkpadding_value: Value for masked-out elements (default:zero(T))check_bounds::Bool: Compute automatic bounds mask (default:true). Set tofalsewhen indices are known to be in-bounds to skip the comparisons.latency: Optional latency hint (1-10), or nothing for compiler default
cuTile.scatter — Function
scatter(array::TileArray{T, 1}, indices::Tile{I, S}, tile::Tile{T, S}; kwargs...) -> NothingScatter elements to a 1D array at index tile positions. Indices are 1-indexed. Out-of-bounds indices are ignored.
Keyword Arguments
mask: OptionalTile{Bool}— additional mask AND'd with automatic bounds checkcheck_bounds::Bool: Compute automatic bounds mask (default:true). Set tofalsewhen 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)scatter(array::TileArray{T, 2}, indices::Tuple{Tile, Tile}, tile::Tile; kwargs...) -> NothingScatter 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: OptionalTile{Bool}— additional mask AND'd with automatic bounds checkcheck_bounds::Bool: Compute automatic bounds mask (default:true). Set tofalsewhen indices are known to be in-bounds to skip the comparisons.latency: Optional latency hint (1-10), or nothing for compiler default
Tile windows
cuTile.eachtile — Function
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.