Code Inspection
Compiling a signature
cuTile.code_tiled — Function
code_tiled([io::IO], job::TileJob; debuginfo=false, remarks=false)
code_tiled([io::IO], f, argtypes; debuginfo=false, remarks=false, kwargs...)Print the CUDA Tile IR for a Julia function as a textual MLIR representation. Analogous to code_llvm. Keyword arguments are those of tile_job: by default the code targets the current CUDA device, as a launch would. To inspect the job of an actual launch, use @device_code_tiled.
Set remarks=true to also run tileiras and print its optimization remarks. This requires tileiras 13.4 or newer.
cuTile.code_typed — Function
code_typed(job::TileJob) -> Vector{Pair{IRCode, DataType}}
code_typed(f, argtypes; kwargs...) -> Vector{Pair{IRCode, DataType}}Return typed code for a cuTile function. Analogous to Base.code_typed. Keyword arguments are those of tile_job; without any, no toolchain or device is needed.
cuTile.code_ircode — Function
code_ircode(mi::MethodInstance; world, always_inline=true) -> (IRCode, rettype)Get optimized IRCode for a MethodInstance using cuTile's overlay method table. If always_inline=true (default), forces all functions to be inlined.
cuTile.code_structured — Function
code_structured(job::TileJob; optimize=true) -> Vector{Pair{StructuredIRCode, DataType}}
code_structured(f, argtypes; optimize=true, kwargs...)Return the structured IR for a cuTile function, after the optimization passes unless optimize=false. Keyword arguments are those of tile_job; without any, no toolchain or device is needed.
cuTile.code_ptx — Function
code_ptx([io::IO], job::TileJob)
code_ptx([io::IO], f, argtypes; kwargs...)Print the PTX that tileiras generates for a Julia function. This shows the thread-level SIMT program the tile-level kernel is lowered to, with every compiler decision (thread mapping, CTA size, pipelining, synchronization) already made. Keyword arguments are those of tile_job; to inspect the job of an actual launch, use @device_code_ptx.
cuTile.code_sass — Function
code_sass([io::IO], job::TileJob)
code_sass([io::IO], f, argtypes; kwargs...)Print the SASS machine code that a Julia function compiles to, by assembling the Tile IR with tileiras and disassembling the resulting CUBIN with nvdisasm. Keyword arguments are those of tile_job. For the binary a launch actually loaded, use CUDA.@device_code_sass.
Jobs
cuTile.TileJob — Type
TileJobA compilation request containing a MethodInstance, its world age and any constant arguments, plus the target architecture, bytecode version, compilation hints, and kernel name. Construct jobs with tile_job and pass them to the reflection functions to inspect that configuration.
Jobs are immutable and compare structurally, so equal jobs are ===.
cuTile.tile_job — Function
tile_job(f, argtypes; world=Base.get_world_counter(), kwargs...) -> TileJob
tile_job(mi::MethodInstance, world; const_argtypes=nothing, kwargs...) -> TileJobCreate a TileJob for f and argtypes (which may contain Constant{T,V} types), or for a method instance with the given const-seeded argument types. Keyword arguments configure the compilation:
bytecode_version: the Tile IR bytecode version to emit; defaults tobytecode_version(), i.e. thebytecode_versionpreference or the newest version the selectedtileirasaccepts.sm_arch: the target architecture; defaults to the current CUDA device's. Combinations the bytecode does not support are rejected.opt_level,num_ctas,occupancy,num_worker_warps: compilation hints overriding the kernel's@compiler_options.name: the kernel's name in the bytecode; defaults to the method's.
Intercepting a launch
cuTile.@device_code_tiled — Macro
@device_code_tiled [io=stdout] [remarks=false] expressionPrint the Tile IR (MLIR) for all kernels compiled while evaluating the expression. With remarks=true, also print tileiras optimization remarks for each kernel.
Example
@device_code_tiled @cuda backend=cuTile blocks=grid vadd(a, b, c)cuTile.@device_code_structured — Macro
@device_code_structured [io=stdout] [optimize=true] expressionPrint the StructuredIRCode for all kernels compiled while evaluating the expression.
Example
@device_code_structured @cuda backend=cuTile blocks=grid vadd(a, b, c)cuTile.@device_code_ptx — Macro
@device_code_ptx [io=stdout] expressionPrint the PTX generated by tileiras for all kernels compiled while evaluating the expression. Unstable, like code_ptx.
Example
@device_code_ptx @cuda backend=cuTile blocks=grid vadd(a, b, c)@device_code_typed and @device_code_warntype are shared with GPUCompiler; they work for cuTile kernels through the shared compile hook.
CUDA.@device_code_sass works for cuTile kernels: it intercepts module loads at the driver level (via CUPTI), so it captures any backend's kernels without backend-specific support.