Skip to content

Conversation

@AntoineBut
Copy link

Hi! Recently @gdalle told me he might use this package, but it is currently missing the SELL matrix format which we worked on a few months ago. I mostly copied over this from my previous repo, trying to match the design choices made in this repo. (More info on this format available in the CuSparse documentation)

Here are a few points I think are worth addressing before merging:

  • I had not previously implemented the 3-argument dot product. I made a "quick and dirty" version, but it is currently allocating, so it should be optimised first (probably not hard to do).
  • I didn't implement the kernels for Transpose and Adjoint, and don't really have the time to do this now. Also, I don't fully understand how you did this with your for loops and @eval (but it looks clean)
  • Because some functions are missing, a lot of your JET tests are failing. I was not able to determine whether adding the missing functions for Transposed and Adjoint matrices will solve all these issues or if there are actual issues with the current code (regarding JET). The basic test JET.test_package(DeviceSparseArrays; target_defined_modules = true) passes.
  • It's currently not possible to do c = A * b (but mul!(c, A, b) works just fine), I'm not used to defining new methods for Base functions, I'm sure its just a small thing missing somewhere but I couldn't find it.

Finally, I recently started to play around with the idea of permuting rows in sparse matrices to "group" together rows according to the number of non-zeros. This functionality is implemented for SELL matrices but not used as I still need to figure out a clean and user friendly way to integrate the feature. For now, the constructor can permute the rows as it constructs the matrix, and use the perm field in the struct to save the permutation that was performed. This allows the user to apply the same permutation on their other arrays. It"s not super user-friendly, it might be possible to create a Permuted wrapper similar to the how Transpose is usually managed but I haven't tried.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

slice_size::Int = 32,
::Type{Ti} = Int32,
) where {Tv,Ti<:Integer}
sparse_matrix_csc_t = convert(SparseMatrixCSC{Tv,Ti}, sparse(transpose(m)))
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need to convert it? Isn't sparse(... already doing it?

#sliceptr(A::DeviceSparseMatrixSELL) = A.slice_ptr

# KA functions
KernelAbstractions.get_backend(A::DeviceSparseMatrixSELL) = get_backend(A.nzval)
Copy link
Owner

Choose a reason for hiding this comment

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

This should be already defined for the abstract type. Let's avoid to define specific methods if not necessary.

Comment on lines +460 to +461
ResVec<:AbstractVector{ResType},
InputVec<:AbstractVector{InputType},
Copy link
Owner

Choose a reason for hiding this comment

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

Better to use DenseVector

Comment on lines +550 to +551
ResMat<:AbstractMatrix{ResType},
InputMat<:AbstractMatrix{InputType},
Copy link
Owner

Choose a reason for hiding this comment

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

If you use DenseMatrix, the ambiguity error should go away.

@albertomercurio
Copy link
Owner

Hi @AntoineBut,

Thank you for contributing!

I'm not an expert of this format, but eveything seems ok. There are several errors. I don't understand if the benchmark regression is related or not, but in principle you haven't touched anything.

It would be great if you can align the definition of mul! functions to the previous implementations (with the @eval macro).

@gdalle
Copy link

gdalle commented Nov 11, 2025

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