tilelang.cuda.language.kernel¶
CUDA dialect of T.Kernel: the common launch plus CUDA launch annotations.
Functions¶
|
Construct a kernel launch frame for CUDA: a grid of thread blocks. |
Module Contents¶
- tilelang.cuda.language.kernel.Kernel(*blocks, threads=None, prelude=None, cluster_dims=None)¶
Construct a kernel launch frame for CUDA: a grid of thread blocks.
Code inside the launch operates at the block level:
T.Parallel,T.copyand friends are mapped onto threads by the compiler.T.get_thread_binding()exposesthreadIdxfor thread-level code. The keyword arguments are recorded at trace time and materialized by the CUDA pipeline once the target is known.- Parameters:
*blocks (int | PrimExpr) – Grid extent along each axis (1-3 dimensions,
gridDim.(x|y|z)). The launch yields one block index per axis (blockIdx.(x|y|z)).threads (int | list[int] | tuple[int, ...], optional) – Threads per block: a count for
blockDim.xor up to three per-dimension extents forblockDim.(x|y|z). Defaults to 128 when omitted.prelude (str, optional) – CUDA source injected before the generated kernel, e.g.
#includelines or helper functions.cluster_dims (int | tuple[int, int, int] | list[int], optional) – Thread block cluster shape (SM90+).
2or(2, 1, 1)launches 2-CTA clusters viacudaLaunchKernelEx.T.ClusterKernelis the same launch with a requiredcluster_dims.
- Return type:
Examples
with T.Kernel(T.ceildiv(N, 128), threads=128) as bx: ... with T.Kernel(grid_x, grid_y, threads=(64, 2)) as (bx, by): tx, ty = T.get_thread_bindings() ...