JuliaDiff / FiniteDiff.jl

Fast non-allocating calculations of gradients, Jacobians, and Hessians with sparsity support
Other
241 stars 39 forks source link

Remove `allowed_getindex` when possible, for faster GPU operations #150

Open albertomercurio opened 1 year ago

albertomercurio commented 1 year ago

Hello,

I'm able to use this package with CUDA Arrays, since the allowed_getindex (for example used here) does not handle the indexing error of the CuArrays. However this slow down the computation, since this process would be transfered and than executed on the CPU.

Is it possible, for example in that for loop I linked, to avoid using the allowed_getindex function? It would be a very good improvement, not only for GPU calculations.

ChrisRackauckas commented 1 year ago

I mean, it would make it faster to remove it, but it would also make it incorrect. Do you have an idea for how to do it with also keeping the correctness? You do have to somehow change the value by epsilon and put it back, and that will require a kernel call each time.

Also for the allowed_getindex handling, did you follow https://github.com/JuliaDiff/FiniteDiff.jl#note-about-sparse-differentiation-of-gpuarrays-bandedmatrices-and-blockbandedmatrices ?