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

514 create a builder class that can make a backward euler solver #527

Merged

Conversation

K20shores
Copy link
Collaborator

Closes #514

  • Temporarily removes backward euler from running in the analytical policy test until we finish implementing the builder such that any solver could be run with those tests
  • Adds a solver builder, which has options to build different solvers, right now only BackwardEuler is supported
  • Adds a solver class which wraps any solver (backward euler, rosenbrock). This may be a useless class
  • Removes template template parameters from many different places

@K20shores K20shores linked an issue May 17, 2024 that may be closed by this pull request
@K20shores K20shores requested a review from mwaxmonsky May 17, 2024 17:29
@sjsprecious sjsprecious added the enhancement New feature or request label May 17, 2024
@sjsprecious sjsprecious added this to the MICM in CAM-SIMA milestone May 17, 2024
Copy link
Collaborator

@sjsprecious sjsprecious left a comment

Choose a reason for hiding this comment

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

Thanks @K20shores for working on this giant PR. Really nice work and I just have a few clarification questions besides the three failing tests.

return micm::LinearSolver<double, Group10000SparseVectorMatrix>{ matrix, initial_value };
},
10000);
micm::LinearSolver<Group10000SparseVectorMatrix>>(10000);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't we need the lambda function here any more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not clear to me that we ever needed it here. we can call the construction directly in the linear solver function. I can put these back if we like having the lamdas with explicit creation

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks. @mattldawson do you recall why we use the lambda function argument before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was for the JITed version of things. We needed to pass the jit compiler around, but, I made the jit compiler into a singleton and now the interface to all solvers and their components are the same

Copy link
Collaborator

@boulderdaze boulderdaze left a comment

Choose a reason for hiding this comment

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

Looks good! Just have minor change requests. I like the removal of template template parameter.

include/micm/solver/solver_builder.hpp Outdated Show resolved Hide resolved
include/micm/solver/backward_euler.hpp Outdated Show resolved Hide resolved
include/micm/util/matrix.hpp Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 23, 2024

Codecov Report

Attention: Patch coverage is 85.99222% with 36 lines in your changes are missing coverage. Please review.

Project coverage is 92.25%. Comparing base (5afd404) to head (a0aa13e).
Report is 1 commits behind head on main.

Files Patch % Lines
include/micm/solver/solver_builder.inl 71.92% 32 Missing ⚠️
include/micm/jit/jit_compiler.hpp 91.89% 3 Missing ⚠️
include/micm/solver/jit_linear_solver.inl 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #527      +/-   ##
==========================================
- Coverage   92.90%   92.25%   -0.65%     
==========================================
  Files          42       45       +3     
  Lines        3268     3408     +140     
==========================================
+ Hits         3036     3144     +108     
- Misses        232      264      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@boulderdaze boulderdaze left a comment

Choose a reason for hiding this comment

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

That makes sense that the Jit class is singleton. Looks cleaner!

Copy link
Collaborator

@mattldawson mattldawson left a comment

Choose a reason for hiding this comment

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

looks great! this was a lot of work! Just a couple minor questions, but nothing important

include/micm/jit/jit_function.hpp Show resolved Hide resolved
Comment on lines +98 to +111
template<class DenseMatrixPolicy, class SparseMatrixPolicy>
inline auto SolverBuilder<DenseMatrixPolicy, SparseMatrixPolicy>::Build()
{
if (std::holds_alternative<RosenbrockSolverParameters>(options_))
{
throw std::runtime_error("Not implemented yet");
}
if (std::holds_alternative<BackwardEulerSolverParameters>(options_))
{
return BuildBackwardEulerSolver();
}

throw std::runtime_error("No solver type set");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the ProcessBuilder we have a Process(ProcessBuilder&) constructor instead of a ProcessBuilder::Build() function. Would it make sense to use the same approach here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have a preference on if we do that or not. Maybe you could do that in the next PR? This one already has so much

test/tutorial/test_README_example.cpp Outdated Show resolved Hide resolved
@K20shores
Copy link
Collaborator Author

Intel failure seems to be in other repositories as well

@K20shores
Copy link
Collaborator Author

Tracking the intel issue: https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Cannot-update-any-packages-using-intel-oneapi-hpckit-latest/td-p/1600608

Copy link
Collaborator

@sjsprecious sjsprecious left a comment

Choose a reason for hiding this comment

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

Thanks @K20shores for working on this giant PR.

All the 44 tests pass on Derecho's A100 GPU, using nvhpc/23.7.

Copy link
Collaborator

@mwaxmonsky mwaxmonsky left a comment

Choose a reason for hiding this comment

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

Great job @K20shores!

Just had a few comments/questions but nothing that should hold this up.

Comment on lines 163 to 169
// if constexpr (std::is_same_v<decltype(solver.process_set_), micm::ProcessSet>)
// {
// auto linear_solver = solver.linear_solver_;
// auto process_set = solver.process_set_;
// be.Solve(
// time_step, be_state, micm::BackwardEulerSolverParameters(), linear_solver, process_set, processes, solver.state_parameters_.jacobian_diagonal_elements_);
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we delete this now or is this going to be re-used in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I do think we can delete this. I'm hoping that all of these tests can be passed any type of solver and check the results. I can dream and hope to make it come true by deleting those

test/integration/analytical_policy.hpp Outdated Show resolved Hide resolved
test/integration/analytical_policy.hpp Outdated Show resolved Hide resolved
test/unit/solver/test_solver_builder.cpp Show resolved Hide resolved
@K20shores K20shores merged commit 369aede into main May 29, 2024
44 of 45 checks passed
@K20shores K20shores deleted the 514-create-a-builder-class-that-can-make-a-backward-euler-solver branch May 29, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a builder class that can make a Backward euler solver
6 participants