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

Allocating lmul! #253

Open
rveltz opened this issue Sep 12, 2024 · 7 comments
Open

Allocating lmul! #253

rveltz opened this issue Sep 12, 2024 · 7 comments

Comments

@rveltz
Copy link

rveltz commented Sep 12, 2024

Hi,

This is not really an issue. I am wondering if the following is expected to allocate:

julia> F = zeros(31,61);

julia> PS = FastSphericalHarmonics.plan_sph_synthesis(copy(F))
FastTransforms plan for FFTW Fourier synthesis on the sphere for 31×61-element array of Float64

julia> @time lmul!(PS,F);
  0.000356 seconds (147 allocations: 10.453 KiB)

julia> @time lmul!(PS,F);
  0.000368 seconds (147 allocations: 10.453 KiB)

I am trying to optimize FastSphericalHarmonics.sph_evaluate! by caching the plans and stumbled on this allocation.

@MikaelSlevinsky
Copy link
Member

I'm getting 0 allocations when using FastTransforms alone:

julia> using FastTransforms, LinearAlgebra

julia> F = zeros(31, 61);

julia> PS = plan_sph_synthesis(copy(F))
FastTransforms plan for FFTW Fourier synthesis on the sphere for 31×61-element array of Float64

julia> @time lmul!(PS, F);
  0.000379 seconds

@rveltz
Copy link
Author

rveltz commented Sep 16, 2024

I guess it is a version problem. It seems to allocate on

[057dd010] FastTransforms v0.15.16

but I cant get higher because of FastSphericalHarmonics

@rveltz
Copy link
Author

rveltz commented Sep 16, 2024

Well:

julia> using FastTransforms, LinearAlgebra

julia> F = zeros(31, 61);

julia> PS = plan_sph_synthesis(copy(F))
FastTransforms plan for FFTW Fourier synthesis on the sphere for 31×61-element array of Float64

julia> @time lmul!(PS, F);
  0.000774 seconds (147 allocations: 10.453 KiB)

julia> @time lmul!(PS, F);
  0.000683 seconds (147 allocations: 10.453 KiB)

with:

  [7d9f7c33] Accessors v0.1.38
  [28f2ccd6] ApproxFun v0.13.27
  [b4f34e82] Distances v0.10.11
  [31c24e10] Distributions v0.25.111
  [057dd010] FastTransforms v0.16.4
  [e9467ef8] GLMakie v0.10.10
  [bdcacae8] LoopVectorization v0.12.171
  [a3a9e032] NIfTI v0.6.0
  [d96e819e] Parameters v0.12.3
  [91a5bcdd] Plots v1.40.8
  [92933f4c] ProgressMeter v1.10.2
  [2913bbd2] StatsBase v0.34.3
  [276b4fcb] WGLMakie v0.10.10

@MikaelSlevinsky
Copy link
Member

No idea!

@rveltz
Copy link
Author

rveltz commented Sep 16, 2024

It is on osx M2.

@jishnub
Copy link
Member

jishnub commented Sep 17, 2024

Could you possibly profile the code to check where the allocations arise from?

@rveltz
Copy link
Author

rveltz commented Sep 17, 2024

I am surprised. In the REPL, it does not allocate but in VS code REPL it does ...

in vscode:

julia> @which lmul!(PS, F)
lmul!(p::FastTransforms.FTPlan{Float64, 2, FastTransforms.SPHERESYNTHESIS}, x::Matrix{Float64})
     @ FastTransforms ~/.julia/packages/FastTransforms/S7huq/src/libfasttransforms.jl:771

which is a ccall so not sure what to profile

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

3 participants