-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accesses inside indexing expressions should be in compute bounds #6131
Comments
This segfaults for me inside the generated code:
|
g is stack allocated, so I had to make min negative to get it to go to a bad address. |
Proposed fix: When a Func f accesses a Func g using an index which depends on any way in some third Func h, and h is not compute_at within f's produce node, and the schedule for f uses RoundUp or ShiftInwards, and the FuncValueBounds of h are smaller than the bounds of the type of h, then we should either:
|
This is because h's compute bounds cover all the points touched in f's loop bounds even though they technically don't have to, right? |
Correct. If in future we managed to give h tighter bounds that than we'd have to relax the condition. |
Cool - it's worth having that documented in our conversation here. |
Inject clamps around func calls h(...) when all the following conditions hold: 1. The call is in an indexing context, such as: f(x) = g(h(x)); 2. The schedule for f uses RoundUp or ShiftInwards 3. h is not compute_at within f's produce node 4. The FuncValueBounds of h are smaller than those of its type Conditions (3) and (4) are not yet implemented.
* Add ClampUnsafeAccesses pass. Fixes #6131 Inject clamps around func calls h(...) when all the following conditions hold: 1. The call flows into an indexing context, such as: `f(x) = g(h(x))` or `let y = h(x) in f(x) = g(y)` 2. The FuncValueBounds of h are smaller than those of its type 3. h's allocation bounds might be wider than its compute bounds Condition (3) is not yet implemented see #6297.
This is a bit of a loose thought, but I'm wondering how bounds inference handles cases like this:
It seems to me there might be a hazard with h(x) being uninitialized between x = 10-15, unless accesses inside index expressions are required to be in the compute bounds (so the mem bounds of
f
become the compute bounds ofh
) - is that how BI actually works?I couldn't find a case (at least during POPL paper crunch) to actually test this because the compiler is a bit too smart about inlining.
The text was updated successfully, but these errors were encountered: