-
Notifications
You must be signed in to change notification settings - Fork 41
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
unwrapping nested structs performance problem #122
Comments
Sorry it took me such a long time to look into this! I'm not too sure what's going on, I suspect it may be somehow related to #86, where nested things can fail on the gpu in some cases. There is something fishy going on, as the This does not make any sense to me: julia> n, m = 50, 51
(50, 51)
julia> A = ForwardDiff.Dual.(randn(n, m), randn(n, m), randn(n, m));
julia> S = structify(A);
julia> @btime for i in eachindex($A)
$S[i] = $A[i]
end
91.066 μs (10200 allocations: 278.91 KiB) Why would it allocate? The unnested case does not allocate and is much faster. Hopefully I'll have time to investigate in the next few days. The main function used here is A thing that I'm curious to try is to have |
Yes, the problem is indeed something that was pointed out a while ago. julia> let
n, m = 50, 51
A = ForwardDiff.Dual.(randn(n, m), randn(n, m), randn(n, m))
@btime StructArray($A) # 56.916 μs (4594 allocations: 171.55 KiB)
@btime structify( $A) # 62.633 μs (4604 allocations: 171.84 KiB)
end; Before merging #141 I need to check if it also handles the other issue we had with GPU code generation, which should be related. |
Currently, if you're using the
unwrap
functionality #85, it can impose a quite heavy performance cost, e.g.Naïvely, it seems that the unwrapping shouldn't add too much overhead if it's done intelligently, since it's the same amount of data to traverse and copy, but maybe that's incorrect. Any thoughts? Is there something that can be done to make this faster?
The text was updated successfully, but these errors were encountered: