SeisNoise.jl icon indicating copy to clipboard operation
SeisNoise.jl copied to clipboard

resample! is slow on the gpu

Open stepholinger opened this issue 2 years ago • 3 comments

At the moment, resample! is quite slow on the gpu. Optimizing code therefore requires designing a workflow in which data is resampled before being moved to the gpu so other preprocessing steps can enjoy the gpu speedup. This may not be ideal in all cases. The example below should demonstrate the issue.

# choose original fs and new fs
fs = 100.
resample_fs = 10.

# generate some 'data'
data = rand(500,500)

# resample on cpu
C = CorrData(corr=data,fs=fs)
cpu_time = @elapsed resample!(C,resample_fs)

# resample on gpu
C = CorrData(corr=data,fs=fs) |> gpu
gpu_time = @elapsed resample!(C,resample_fs)

# print results
print("CPU time: ", cpu_time, " s\n")
print("GPU time: ", gpu_time, " s\n")

CPU time: 0.029605658 s
GPU time: 108.995494081 s

stepholinger avatar Feb 03 '23 18:02 stepholinger

I'm a little surprised resample works on the GPU...I don't believe I wrote a version of resample specifically for the GPU, so I think there's some data transfer to/from CPU/GPU going on here that is gumming things up. The resample code just calls an FIR filter, which I do have for the GPU but is slow because it's using an FFT. All that's to say that, yes definitely can speed things up!

tclements avatar Feb 04 '23 00:02 tclements

Should we close this since it's related to https://github.com/tclements/SeisNoise.jl/issues/107#issue-1570303031? The performance elements of both issues are with SeisIO, not SeisNoise. One overall fix would be to implement resample for NodalData in SeisNoise, and to eventually add GPU support for resample in general.

stepholinger avatar Feb 06 '23 21:02 stepholinger

Let's keep this open - I think GPU resampling is different enough to keep in mind.

tclements avatar Feb 06 '23 23:02 tclements