Skip to content

Conversation

@hexaeder
Copy link
Contributor

@hexaeder hexaeder commented Nov 20, 2025

This PR adds a simple (mutating) DAE as a testcase for GPU compat. Mainly fixes BrownInit for mutating DAEs with mass matrix and cu arrays.

Not tested:

EDIT: the spares jacobian additionaly fails because

function algebraic_jacobian(jac_prototype::T, algebraic_eqs,
algebraic_vars) where {T <: AbstractMatrix}
jac_prototype[algebraic_eqs, algebraic_vars]
end

does not work for sparse cuda matrices (this type of indexing is not implemented).

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Comment on lines 399 to 400
algebraic_vars = mapreduce(iszero, &, M, dims = 1)[:]
algebraic_eqs = mapreduce(iszero, &, M, dims = 2)[:]
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
algebraic_vars = mapreduce(iszero, &, M, dims = 1)[:]
algebraic_eqs = mapreduce(iszero, &, M, dims = 2)[:]
algebraic_vars = mapreduce(iszero, &, M, dims = 1)
algebraic_eqs = mapreduce(iszero, &, M, dims = 2)

Is that part needed?

Copy link
Contributor Author

@hexaeder hexaeder Nov 20, 2025

Choose a reason for hiding this comment

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

yes i think so, otherwise those are not vectors but 1xN and Nx1 matrices, the rest of the code assumes vectors. But i'll check again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the vector is indeed needed. I changed it to

    algebraic_vars = vec(all(iszero, M, dims = 1))
    algebraic_eqs = vec(all(iszero, M, dims = 2))

which is more readable and faster.

@hexaeder
Copy link
Contributor Author

hexaeder commented Nov 20, 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.

2 participants