Skip to content

Conversation

@nilsvu
Copy link
Member

@nilsvu nilsvu commented Oct 18, 2021

Proposed changes

At some point the elliptic solver builds a matrix representation of a Poisson operator by feeding it unit vectors, so most of the data is actually zero (i.e. sparse). This PR makes the DG operator a lot faster when it operates on sparse data.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@nilsvu nilsvu requested review from nikwit and wthrowe October 18, 2021 21:39
@nilsvu nilsvu force-pushed the optimize_elliptic_solver branch from afc11d8 to 7e2a583 Compare October 18, 2021 22:30
const std::tuple<FluxesArgs...>& fluxes_args,
const std::tuple<SourcesArgs...>& sources_args,
const DirectionMap<Dim, std::tuple<FluxesArgs...>>& fluxes_args_on_faces,
const std::function<bool(const ElementId<Dim>&)>& data_is_zero =
Copy link
Member

Choose a reason for hiding this comment

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

I haven't looked at any of the code in detail. Note that std::function is pretty slow compared to lambdas or a template parameter. If the std::function is needed in a loop you might want to think about an alternative way of handling this. Basically, std::function does type erasure internally, which is why it's slower

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 making the argument type a template argument will work without having to change anything else. (And all this appears again below.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in a fixup, please take a look

const std::tuple<FluxesArgs...>& fluxes_args,
const std::tuple<SourcesArgs...>& sources_args,
const DirectionMap<Dim, std::tuple<FluxesArgs...>>& fluxes_args_on_faces,
const std::function<bool(const ElementId<Dim>&)>& data_is_zero =
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 making the argument type a template argument will work without having to change anything else. (And all this appears again below.)

}
}
ASSERT(
false,
Copy link
Member

Choose a reason for hiding this comment

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

ERROR? Evaluating the condition is free, no reason to skip it.

Copy link
Member

@wthrowe wthrowe left a comment

Choose a reason for hiding this comment

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

You can squash this change directly.

<< neighbors_neighbor_id
<< " is part of the subdomain, but we didn't find its "
"overlap ID. This is a bug, so please file an issue.");
return std::nullopt;
Copy link
Member

Choose a reason for hiding this comment

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

Remove statement after ERROR.

@nilsvu nilsvu force-pushed the optimize_elliptic_solver branch from e537b9b to f9c4868 Compare November 1, 2021 21:29
@nilsvu
Copy link
Member Author

nilsvu commented Nov 2, 2021

@wthrowe pushed another fixup to avoid timeouts in unit tests.

@nikwit Could you do the second review here?

@wthrowe
Copy link
Member

wthrowe commented Nov 2, 2021

Timeout fix looks good. Squash.

@nilsvu nilsvu force-pushed the optimize_elliptic_solver branch from 454e047 to 1232d58 Compare November 2, 2021 19:05
Copy link
Contributor

@nikwit nikwit left a comment

Choose a reason for hiding this comment

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

LGTM

@nilsvu nilsvu merged commit 03f55cb into sxs-collaboration:develop Nov 8, 2021
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.

4 participants