8000 Enable changing the residual tolerance after a batch solver is created by Slaedr · Pull Request #1087 · ginkgo-project/ginkgo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Enable changing the residual tolerance after a batch solver is created #1087

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

Merged
merged 7 commits into from
Oct 12, 2022

Conversation

Slaedr
Copy link
Contributor
@Slaedr Slaedr commented Jul 22, 2022

This adds an interface to change the residual tolerance for subsequent runs of a solver, so that a new factory does not have to be created just for changing the tolerance. In cases where batch scaling is needed, this removes the need for redoing the setup task of scaling just for changing the tolerance, among potentially other things in the future.

A new, non-templated base class BatchSolver is added. This contains all functionality that is agnostic of the concrete type - preconditioner, generated preconditioner, scaling operators, residual tolerance, maximum iteration count. Thus, the user only needs a pointer to BatchLinOp for applying the solver, and a dynamic cast to BatchSolver to get and set/get solver-agnostic parameters like the residual tolerance.

The factory parameter is now renamed to default_residual_tol, and this is used to initialize the residual_tol_ values of generated solvers. The set_residual_tolerance(double) member funct 10000 ion directly sets the residual_tol_ on the solver object.

Drawback:

  • Casts are needed to the corresponding real_types of the solvers. This was done so that the residual tolerance can be updated independent of the concrete batched solver type - the application does not always need to know the concrete type.

@Slaedr Slaedr added the type:batched-functionality This is related to the batched functionality in Ginkgo label Jul 22, 2022
@Slaedr Slaedr self-assigned this Jul 22, 2022
@Slaedr Slaedr requested a review from pratikvn July 22, 2022 21:49
@ginkgo-bot ginkgo-bot added mod:core This is related to the core module. reg:testing This is related to testing. type:solver This is related to the solvers labels Jul 22, 2022
@Slaedr Slaedr added the 1:ST:ready-for-review This PR is ready for review label Jul 22, 2022
*
* @return The residual tolerance.
*/
double get_residual_tolerance() const { return residual_tol_; }
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 we should maintain just one copy of the tolerance instead of two separate copies. If the users sets a tolerance, then we just modify the existing one instead of adding one more parameter. the parameters_ struct already has a getter as well

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively: Get rid of the parameters member entirely. It's hidden in one of the factory macros, but TBH I dislike how well they hide the additional member they add. I worked entirely without the macros in #1082, and it felt much cleaner :)

Copy link
Member

Choose a reason for hiding this comment

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

There are two types of parameters: Ones that describe how to generate an object, but can be discarded afterwards, and ones that describe the runtime behavior of the object. IMO, we should only keep the latter inside the generated object.

Copy link
Contributor Author
@Slaedr Slaedr Jul 27, 2022

Choose a reason for hiding this comment

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

@upsj That has the advantage that I could add the residual tolerance, getter and setter only to the base class. @pratikvn The problem with the factory macros is that the entire struct needs to be in the derived class, so we'd need to duplicate the getter and setter on every batched iterative solver, which should ideally be unnecessary. That would also impose the necessity to know the derived type just to set/get the residual tolerance.

Copy link
Member

Choose a reason for hiding this comment

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

But I think having two things settable in two different ways might bring a lot more confusion, so we should unify those.

@Slaedr Slaedr added 1:ST:WIP This PR is a work in progress. Not ready for review. and removed 1:ST:ready-for-review This PR is ready for review labels Jul 27, 2022
@Slaedr Slaedr force-pushed the batch-settable-res-tol branch from deadcfb to 0cac499 Compare September 8, 2022 04:52
@Slaedr Slaedr added 1:ST:ready-for-review This PR is ready for review and removed 1:ST:WIP This PR is a work in progress. Not ready for review. labels Sep 8, 2022
@Slaedr Slaedr requested review from pratikvn and upsj September 8, 2022 04:56
@Slaedr
Copy link
Contributor Author
Slaedr commented Sep 8, 2022

format!

Copy link
Member
@pratikvn pratikvn left a comment

Choose a reason for hiding this comment

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

I like the renaming idea, though that might mean Cody might have to change a bit in his interface. I guess the XGC interface will also need to be updated. LGTM!

@Slaedr Slaedr force-pushed the batch-settable-res-tol branch from 31e5be6 to aa54714 Compare September 30, 2022 20:00
@Slaedr Slaedr added 1:ST:ready-to-merge This PR is ready to merge. and removed 1:ST:ready-for-review This PR is ready for review labels Sep 30, 2022
Copy link
Member
@pratikvn pratikvn left a comment

Choose a reason for hiding this comment

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

CI issue

@Slaedr Slaedr force-pushed the batch-settable-res-tol branch from d0ffd73 to 0977810 Compare October 11, 2022 21:00
@ginkgo-bot
Copy link
Member

Note: This PR changes the Ginkgo ABI:

Functions changes summary: 80 Removed, 60 Changed (1440 filtered out), 520 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

For details check the full ABI diff under Artifacts here

@Slaedr Slaedr merged commit f2e257f into batch-develop Oct 12, 2022
@Slaedr Slaedr deleted the batch-settable-res-tol branch October 12, 2022 02:28
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1:ST:ready-to-merge This PR is ready to merge. mod:core This is related to the core module. reg:testing This is related to testing. type:batched-functionality This is related to the batched functionality in Ginkgo type:solver This is related to the solvers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0