-
Notifications
You must be signed in to change notification settings - Fork 194
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
Are we actually @unroll
ing when we think we are?
#3374
Comments
(Indeed "tsunami" is more appropriate here rather than "avalanche".) |
Hm... removing all unrolls from |
aren't there more than that |
don't remove them all because some could be legit |
Sure, I only removed them just to see if they were the culprit. |
That was just an example. There's a lot of erroneous usage. This might help:
|
Any place where the loop limits are not types, it's wrong. It only works if the limits are known via types (so they are known at compile time rather than runtime). Typically this would require uusing |
I'm not sure I understand what you mean here. Can you give an example that's OK and one that's not? help?> KernelAbstractions.Extras.LoopInfo.@unroll
@unroll expr
Takes a for loop as expr and informs the LLVM unroller to fully unroll it, if it is safe to do so and the loop count is known.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@unroll N expr
Takes a for loop as expr and informs the LLVM unroller to unroll it N times, if it is safe to do so. In particular, I don't know what "if it is safe to do so" refers to. |
Do you simply mean that @unroll for j in 1:4; do_this(); end is OK but N=4
@unroll for j in 1:N; do_this(); end is not? |
Both are fine the way you have written them, because even in the second case the compiler is able to infer that If one is careful to pass the limits of the loop as compile-time information, then we can pass information into a function. Typically this is done with objects like like |
The example that is ok is when the limit of the loop |
Gotcha! |
Here's the basic structure Not ok because loop limits are runtime values: function loop(N)
@unroll for i = 1:N
# etc.
end Maybe ok because, in principle, loop limit is encoded in type information function loop(::Val{N}) where N
@unroll for i = 1:N
# etc.
end The second case is called with |
see #3403 (comment) regarding https://github.com/cstjean/Unrolled.jl |
On Julia 1.10 users are met with an
avalanchetsunami of warningsFor example we try
Oceananigans.jl/src/Solvers/batched_tridiagonal_solver.jl
Lines 133 to 148 in 7291ada
but this loop probably can't be unrolled because
Nx
is a runtime value, not a compile time constant.I don't know if we ever
@unroll
properly...Seems like the easiest thing is just to stop pretending that we
@unroll
.@jlk9
The text was updated successfully, but these errors were encountered: