Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_apply_stiffness_transpose_operator: uses einsum in a way that causes high cost #143

Closed
inducer opened this issue Jul 5, 2021 · 1 comment

Comments

@inducer
Copy link
Owner

inducer commented Jul 5, 2021

Since our einsum is not smart (it doesn't identify possible common subexpressions), this:

grudge/grudge/op.py

Lines 296 to 306 in 1c44c4b

actx.einsum("dij,ej,ej,dej->ei",
reference_stiffness_transpose_matrix(
actx,
out_element_group=out_grp,
in_element_group=in_grp
),
ae_i,
vec_i,
inv_jac_t_i,
arg_names=("ref_stiffT_mat", "jac", "vec", "inv_jac_t"),
tagged=(FirstAxisIsElementsTag(),))

amounts to computing the rst derivatives once per dimension. (Together with #141, we're computing them 9 times in 3D, when once would suffice.) The problem is that the sum is computed once per d, when it is actually independent of d.

This is something I should have caught during review of #74.

cc @thomasgibson @lukeolson

@inducer
Copy link
Owner Author

inducer commented Sep 5, 2021

Again, not totally sure what I was smoking here. For general curvi, the inverse metric derivatives depend on the point, so the best one could conceivably do is precompute the sum over d, but that would lead to a matrix-per-element size temporary, which is entirely unaffordable.

More can be done for affine, but that's the domain of #161.

@inducer inducer closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant