JuliaLinearAlgebra / IterativeSolvers.jl

Iterative algorithms for solving linear systems, eigensystems, and singular value problems
MIT License
403 stars 106 forks source link

Scalar indexing of CuArray in lsqr #354

Closed oscarvanderheide closed 1 month ago

oscarvanderheide commented 10 months ago

When I run lsqr on CuArrays, the lines

    for i = 1:n
        isfinite(x[i]) || error("Initial guess for x must be finite")
    end

result in poor performance due to scalar indexing. I replaced this with

  if !(all(isfinite.(x)))
      error("Initial guess for x must be finite")
  end

but before I submit a PR I thought it would be better to file and issue and discuss potential implications of the proposed approach.

amontoison commented 10 months ago

The implementation of lsqr in Krylov.jl works on GPUs if it can help.