Skip to content
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

remove shape tuple allocation in reshape #153

Open
vpuri3 opened this issue Feb 24, 2023 · 0 comments
Open

remove shape tuple allocation in reshape #153

vpuri3 opened this issue Feb 24, 2023 · 0 comments

Comments

@vpuri3
Copy link
Member

vpuri3 commented Feb 24, 2023

example thanks to @dgleich

function myfun(u)
    rval = zero(eltype(u))
    z=reshape(@view(u[1:end]), 100, 10000)
    for j in 1:size(z,2)
        sum2 = zero(eltype(z))
        for i in 1:size(z,1);
            sum2 += z[i,j];
        end
        rval += sum2^2
    end
    return rval
end
julia> @btime myfun($u)
  534.792 μs (0 allocations: 0 bytes)
2.5071715895145908e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant