Hello,
I am trying to improve some code I have, specifically to reduce the allocations it makes in a hot inner loop. I’ve been using Profile
and julia --track-allocation=user
to inspect on what lines the bulk of the allocations are occurring. I initially cut down on quite a few by sprinkling @view
throughout my code. But the following line is puzzling me, this line of code is in the hot inner loop in question and has a lot of allocations associated with it.
tmp = @view pre_allocated_array_1[indices] # [3 element view]
pre_allocated_array_2[i] = sum(tmp .* pre_allocated_tuple) # tuple also has 3 elements
I tried sum(sum, tmp .* pre_allocated_tuple)
based on this post here, but it didn’t make a difference.
Any hints on what I am doing wrong?