JuliaApproximation / JuliaApproximation/FastTransforms.jl

sph methods slow?

Open
#191 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
281
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Maybe this is totally expected, but:

  • A lot slower than FFT. It has been a while, but I seem to recall (going back to 2018) that the first version was much more comparable to FFT
  • Allocations that don't go away with in-place (hard to make an efficient time evolution algorithm in this case)
  • Which method is the bottleneck depends on size
using FastTransforms
using FFTW
using LinearAlgebra

n,m = 1024,2047

x = randn(ComplexF64,n,m)
# FFTW
@time fft(x);
  0.033259 seconds (259 allocations: 32.001 MiB)
P! = plan_fft!(x);
@time P!*x; 
  0.035154 seconds (232 allocations: 14.969 KiB)

# Spherical 
P = plan_sph2fourier(x)
PS = plan_sph_synthesis(x)

@time PS*(P*x);
  0.235185 seconds (549 allocations: 127.972 MiB, 1.57% gc time)
@time P*x; # slow
  0.145820 seconds (8 allocations: 63.969 MiB, 1.85% gc time)
@time PS*x;
  0.051036 seconds (545 allocations: 64.003 MiB)

@time lmul!(P,x);  # slow
  0.139856 seconds (4 allocations: 31.984 MiB, 0.91% gc time)
@time lmul!(PS,x);
  0.047418 seconds (539 allocations: 32.018 MiB)

## small array
n,m = 60,121
x = randn(ComplexF64,n,m);

# FFTW
@time fft(x);
  0.000560 seconds (242 allocations: 129.836 KiB)
P! = plan_fft!(x);
@time P!*x; 
  0.000411 seconds (218 allocations: 14.492 KiB)

# Spherical 
P = plan_sph2fourier(x);
PS = plan_sph_synthesis(x);

@time PS*(P*x);
  0.101827 seconds (19.31 k allocations: 1.626 MiB)

@time P*x; 
  0.000266 seconds (8 allocations: 227.406 KiB)
@time PS*x;  # slow
  0.031964 seconds (20.48 k allocations: 1.440 MiB)

@time lmul!(P,x);  
  0.000364 seconds (4 allocations: 113.594 KiB)
@time lmul!(PS,x);  # slow
  0.037324 seconds (20.38 k allocations: 1.326 MiB)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported timings using plan_sph2fourier, plan_sph_synthesis, lmul!, and the FFTW comparisons in the issue. Start by locating those spherical-transform entry points and profiling both the large and small array cases. Done would require identifying and addressing the reported slowdown or allocations, but the issue does not define a specific target or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.