Repository navigation
Conversation
Signed-off-by: vxnuaj <jv.100420@gmail.com>
Contributor
|
Thank you for the patch! It looks correct but I'm a bit worried about quality of codegen: using comparison+select may not be ideal. To the best of my knowledge, there is no way to express saturating arithmetic directly in TileIR, unfortunately. I suspect that the next best option may be using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a miscompilation in the loop split pass. For
if i > candif i <= cthe pass splits the loop atc + 1. Whencis the maximum value of the loop index type, the addition wraps to the type minimum and every iteration takes the wrong branch. The kernel then returns incorrect results with no error.This change saturates the split point at the type maximum instead. That is correct because the loop stop can never exceed the maximum, so for
<=the first loop covers the whole range and for>the second loop is empty. The saturation is emitted aswhere(c == max, max, c + 1), so the result does not depend on how the wrappedc + 1is interpreted. Splits for<and>=do not add one and are unchanged.Regression tests cover both predicates at
cequal to -1, 0, 1, 3, 4, INT32_MAX minus 1 and INT32_MAX with a 4 iteration loop, checked against a Python reference.Tested on an NVIDIA L4 (sm_89) with CUDA 13.5 by building cuTile from source at
mainand at this branch, then runningtest/test_loop_split.py,test/test_control_flow.pyandtest/test_range.pywith-m "not benchmark and not use_mlir".maingives 254 passed, 2 failed (the new INT32_MAX cases), 2 xfailedflake8andscripts/check_license.pypass.closes #127
Checklist