Skip to content

Conversation

@THargreaves
Copy link

When writing CUDA.jl kernels, one should favour Int32 indexing for performance. This currently isn't possible when using the adjoint wrapper since this has hard-coded Int types.

This PR relaxes these types to use the abstract Integer type, inline with other parts of the package (e.g. here).

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.89%. Comparing base (59a20b6) to head (af939bc).

Files with missing lines Patch % Lines
src/adjtrans.jl 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1482      +/-   ##
==========================================
- Coverage   93.90%   93.89%   -0.01%     
==========================================
  Files          34       34              
  Lines       15946    15946              
==========================================
- Hits        14974    14973       -1     
- Misses        972      973       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dkarrasch
Copy link
Member

For most other abstract matrix types provided by LinearAlgebra.jl (like the triangular ones, for instance), there seems to be the same type restriction on the index arguments. Has that never come up earlier? Perhaps we should then relax all getters and setters?

@propagate_inbounds getindex(A::AdjOrTransAbsMat{T}, i::Int, j::Int) where {T} = wrapperop(A)(A.parent[j, i])::T
@propagate_inbounds setindex!(v::AdjOrTransAbsVec, x, i::Int) = (setindex!(v.parent, _wrapperop(v)(x), i-1+first(axes(v.parent)[1])); v)
@propagate_inbounds setindex!(A::AdjOrTransAbsMat, x, i::Int, j::Int) = (setindex!(A.parent, _wrapperop(A)(x), j, i); A)
@propagate_inbounds Base.isassigned(v::AdjOrTransAbsVec, i::Integer) = isassigned(v.parent, i - one(i) + first(axes(v.parent)[one(i)]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the uses of one should be replaced by oneunit. These are equivalent for Integers, but oneunit conveys the intent more clearly.

@propagate_inbounds setindex!(A::AdjOrTransAbsMat, x, i::Integer, j::Integer) = (setindex!(A.parent, _wrapperop(A)(x), j, i); A)
# AbstractArray interface, additional definitions to retain wrapper over vectors where appropriate
@propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Int}) = wrapperop(v)(v.parent[is])
@propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Integer}) = wrapperop(v)(v.parent[is])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Integer}) = wrapperop(v)(v.parent[is])
@propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{<:Integer}) = wrapperop(v)(v.parent[is])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants