-
Notifications
You must be signed in to change notification settings - Fork 6
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
Loop disappears in Julia v0.7 #1
Comments
Thank you for the nicely detailed bug report. I'm not sure what's going on, but I'll try to have a look when I get a chance. Sounds like a bug in 0.7. Generated functions have changed a lot in 0.7. This will allow us to get rid of the ugly
That's already supported (... essentially) by passing |
Great, Just realized that I had already made some changes to my above examples. On the current master, I get: julia> using Unrolled
INFO: Recompiling stale cache file /home/chris/.julia/lib/v0.7/Unrolled.ji for module Unrolled.
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
'znver1' is not a recognized processor for this target (ignoring processor)
WARNING: deprecated syntax "(loopbody...)" at /home/chris/.julia/v0.7/Unrolled/src/Unrolled.jl:33.
Use "(loopbody...,)" instead.
ERROR: LoadError: syntax: expected ")"
Stacktrace:
[1] include_relative(::Module, ::String) at ./loading.jl:509
[2] include(::Module, ::String) at ./sysimg.jl:15
[3] top-level scope
[4] top-level scope at ./<missing>:2
in expression starting at /home/chris/.julia/v0.7/Unrolled/src/Unrolled.jl:33
ERROR: Failed to precompile Unrolled to /home/chris/.julia/lib/v0.7/Unrolled.ji.
Stacktrace:
[1] compilecache(::String) at ./loading.jl:637
[2] _require(::Symbol) at ./loading.jl:426
[3] require(::Symbol) at ./loading.jl:300 Example change that lets us precompile the module, but then gives us the incorrect macro unroll_loop(niter_type::Type, loop)
local niter # necessary on 0.5
@assert(@capture(loop, for var_ in seq_ loopbody__ end),
"Internal error in @unroll_loop")
try
niter = type_length(niter_type)
catch e
# Don't unroll the loop, we can't figure out its length
if isa(e, MethodError)
return esc(loop)
else rethrow() end
end
esc(
quote
$Unrolled.@unroll_loop $niter for $var in $seq
$(loopbody...) end
end
)
end Could we fix this by replace the splatting of loopbody with a loop?
julia> @unroll function my_sum(x, ::Val{N}) where N
out = zero(eltype(x))
@unroll for i ∈ @fixed_range(1:N)
out += x[i]
end
out
end
ERROR: LoadError: AssertionError: `@unroll` must precede a function definition
Stacktrace:
[1] @unroll(::LineNumberNode, ::Module, ::Any) at /home/chris/.julia/v0.7/Unrolled/src/Unrolled.jl:92
in expression starting at REPL[16]:1 while defining a type_length for val does: julia> Unrolled.type_length(::Type{Val{N}}) where N = N
julia> @unroll function my_sum(x, vn)
out = zero(eltype(x))
@unroll for i ∈ 1:length(vn)
out += x[i]
end
out
end
my_sum_unrolled_expansion_ (generic function with 1 method)
julia> my_sum(rand(32), Val(32))
15.151042302254876 |
Then fixing With regards to your example, @unroll function my_sum(x, range)
out = zero(eltype(x))
@unroll for i ∈ range
out += x[i]
end
out
end You may call my_sum(x, ::Val{N}) where N = my_sum(x, @fixed_range(1:N)) |
Superseded by #3 |
I'm not yet sure what the problem is. On 0.7:
Perhaps the problem is associated with the contents of the quoted loop body also being wrapped in an expression?
and v0.7:
An example with two lines in the loop body, in v0.7:
In v0.6:
A couple more issues:
where T
syntax.Val
s:Unrolled.type_length(::Type{Val{N}}) where N = N
; perhaps this is something people would find generally useful.The text was updated successfully, but these errors were encountered: