-
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
Support for julia 0.7 #3
Comments
Yes! As mentioned in #1 (comment), this macro should be a lot simpler in 0.7. I sadly can't promise when I'll get to it, but PRs are welcome. |
Unfortunately both me and DynamicalBilliards.jl however is an excellent real-life usage and test-case of your package. If you progress this into 0.7, we will gladly test it and report possible issues. You can let us know of a working transition branch if and when one opens up and we can test it there. |
Should be fixed on |
Well, we can definitely import Unrolled now. However, while testing this function function next_collision(p::AbstractParticle{T}, bt::Tuple)::Tuple{T,Int} where {T}
findmin(unrolled_map(x -> collisiontime(p, x), bt))
end we noticed a massive performance loss compared to v0.6.3. > bd = billiard_stadium(); p = randominside(bd)
> @btime next_collision($p, $(b.obstacles)) On the old julia version, the function took about 40 ns, now it needs 210 ns. |
Dammit. I always press the wrong button |
I am making this a bit more concrete. The function we are talking about is what Lukas cited,
We have checked and the function We use the following code to have reproducible results:
On the master branch of
On the branch
I think it is clear that the problem is in the allocations, but I do not really know where it comes from. Also, due to the nature of the complexity we have (which requires us to use Unrolled in the first place), I am not sure on how to make a MWE to post on discourse. |
I have to report something more: Unrolled as a package in general seems to have no impact. Compare the following two functions: function next_collision(
p::AbstractParticle{T}, bt::Tuple)::Tuple{T,Int} where {T}
tmin::T = T(Inf)
ind::Int = 0
for i in eachindex(bt)
tcol::T = collisiontime(p, bt[i])
# Set minimum time:
if tcol < tmin
tmin = tcol
ind = i
end
end#obstacle loop
return tmin, ind
end
@unroll function next_collision2(p::AbstractParticle{T}, bt::Tuple) where {T}
tmin::T = T(Inf)
ind::Int = 0
i::Int = 0
@unroll for obst in bt
tcol::T = collisiontime(p, obst)
i+=1
# Set minimum time:
if tcol < tmin
tmin = tcol
ind = i
end
end#obstacle loop
return tmin, ind
end They seem to have indentical performance:
(julia 0.7 and master branch of Unrolled) |
I have also started a discussion here: https://discourse.julialang.org/t/manually-unroll-operations-with-objects-of-tuple/11604 on how to make a "minimal unrolled version" of the function we need, so I can better pinpoint where is the regression ( |
Thank you for the detailed report. I'll look into it when I get a chance, hopefully tonight. Unrolled relies on compiler details to a certain extent, so I'm not surprised that performance decreased, but there should be a fix. If not, then maybe we can file it as a performance regression. |
Hi cstjean, thanks a lot for helping us with this. |
@cstjean big update. Unrolled may be totally fine after all, see here: https://discourse.julialang.org/t/manually-unroll-operations-with-objects-of-tuple/11604/18 If indeed it is StaticArray's fault, I am very sorry for the confusion. I just "assumed" that static arrays were ok in 0.7 |
No worries. But if I'm reading this right, on top of the SVector problems, it's also slower with tuples, right? If so, we should investigate where that slowdown comes from.
(for, say, a tuple of three elements) and comparing performance? |
It may not be at all that it is slower. When I run the code of my own meta-programmed unrolled function, i.e.
I got same speed with the 0.6 version. I am assuming that Unrolled will do the same as well, but I will test it after static arrays have been updated (so I am sure that I know where the problems are ;) ). I am closing this for now, and when I test it thoroughly, after StaticArrays are good to go I will open a separate issue if need be! |
Ok. But I would still be curious to try function next_collision(p::AbstractParticle{T}, bt::Tuple{Any, Any, Any})::Tuple{T,Int} where {T}
findmin((collisiontime(p, bt[1]), collisiontime(p, bt[2]), collisiontime(p, bt[3])))
end vs. |
Yeap, I will do that once I am sure StaticArrays are good to go! |
Sadly, this package does not load in julia 0.7 alpha as of today (11 June).
Precompilation fails with this error message
Will support for 0.7 (and eventually 1.0) be added to Unrolled.jl?
The text was updated successfully, but these errors were encountered: