SeisNoise.jl
SeisNoise.jl copied to clipboard
resample! is slow on the gpu
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
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!
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.
Let's keep this open - I think GPU resampling is different enough to keep in mind.