ptiede / Comrade.jl

MIT License
47 stars 7 forks source link

Phasecenter optimization #209

Closed dominic-chang closed 1 year ago

dominic-chang commented 1 year ago

https://github.com/ptiede/Comrade.jl/blob/252a073d6abef84444029a63edc886869a746631/src/models/modelimage/fft_alg.jl#L150-L154

Could this be optimized by reusing the input visibility matrix and threading the calculation? Maybe something like this:

function phasecenter(vis, uu, vv, x0, y0, dx, dy, executor=SequentialEx())
    lenu = length(uu)
    lenv = length(vv)

    @floop executor for i in 1:(lenu*lenv)
        ix = Int(i%lenv+1)
        iy = Int(floor((i-1)/lenu))+1
        vis[ix, iy] = conj(vis[(ix, iy)...])*cispi(2*(uu[ix]*x0 + vv[iy]*y0))
    end
    return vis
end

and then allow the user to swap out the SequentialEx() with a ThreadedEx() if they want.

ptiede commented 1 year ago

Fixed in #210