Skip to content

Keep Tile memory bounds semantics explicit - #288

Merged
maleadt merged 3 commits into
mainfrom
tb/boundscheck
Aug 6, 2026
Merged

maleadt merged 3 commits into
mainfrom
tb/boundscheck

Conversation

@maleadt

@maleadt maleadt commented Jul 29, 2026

Copy link
Copy Markdown
Member

Document tile memory bounds handling being explicit:

  • ct.load and ct.store remain checked by default. Partial loads use their
    requested padding and partial stores clip to the destination.
  • check_bounds=false is the explicit full-tile promise. It drops load padding,
    emits Tile IR's inbounds encoding, and requires Tile IR v13.4+.
  • Julia @inbounds and --check-bounds continue to apply to Julia
    @boundscheck blocks, but do not change Tile memory padding, clipping, masks,
    or view attributes.

This applies consistently to direct TileArray accesses, eachtile windows
(including strided views), gather/scatter views, and scalar indexing wrappers.

Also included:

  • Fix scalar not_int lowering for !::Bool and integer ~.
  • Add codegen regressions for the explicit bounds boundary and GPU regressions
    for ragged tiles and unchecked padded loads.
  • Document Tile memory bounds semantics, the Julia distinction, and the
    equivalent cuTile Python behavior.

@maleadt

maleadt commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

After looking into this more, I don't think we should couple Tile IR's check_bounds to Julia's @inbounds.

Julia's bounds checks are protective: eliding one should not change the result of a valid access. Tile IR's checked accesses instead define padding and clipping for partial edge tiles. A valid TiledView index can select such a partial tile, so making @inbounds tiles[i] discard its padding would change the value of a valid indexing operation.

The current pre-v13.4 fallback also loses padding_mode: the language layer drops it before the emitter discovers that it must fall back to a checked encoding.

Let's keep the boundary explicit:

maleadt added 3 commits August 6, 2026 18:23
`!` on a Bool and `~` on an integer both reach `not_int`, but its rewrite rules
were restricted to `Tile{...}` operands and so left the scalar form to fail in
codegen. The binary bitwise rules don't have this problem because they need no
type-directed constant.
@maleadt
maleadt marked this pull request as ready for review August 6, 2026 16:47
@maleadt maleadt changed the title Integrate with Julia's bounds checking infra Keep Tile memory bounds semantics explicit Aug 6, 2026
@maleadt
maleadt merged commit 650ac41 into main Aug 6, 2026
1 check passed
@maleadt
maleadt deleted the tb/boundscheck branch August 6, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant