-
Notifications
You must be signed in to change notification settings - Fork 6
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
Remove solver_.parameters_ #668
base: main
Are you sure you want to change the base?
Conversation
I do see some calls where solver.solver_.parameters_ is not being modifiedbut rather the value is getting used. Example: EXPECT_EQ(solver.solver_.parameters_.absolute_tolerance_[state.variable_map_["Ar"]], 1.0e-12); I am unsure if we need to change these as well? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #668 +/- ##
==========================================
+ Coverage 93.97% 94.28% +0.31%
==========================================
Files 61 61
Lines 4163 4179 +16
==========================================
+ Hits 3912 3940 +28
+ Misses 251 239 -12 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right direction, but we still have some more work to do. Any mechanism-specific thing (like tolerances) need to be moved somewhere else. We should spend some time figuring out where they need to go. Also, the parameters need to be any set of paramters (rosenbrock, backward euler, etc.)
d059401
to
32a16e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @montythind for working on this PR. I observed the following failures on Derecho:
15 - cuda_rosenbrock (SEGFAULT)
31 - rosenbrock (SEGFAULT)
45 - regression_test_solve (NUMERICAL)
46 - chapman_integration (SEGFAULT)
47 - analytical_rosenbrock_integration (NUMERICAL)
48 - analytical_backward_euler (NUMERICAL)
49 - terminator (NUMERICAL)
50 - integrated_reaction_rates (NUMERICAL)
52 - README_example (NUMERICAL)
53 - solve_results (NUMERICAL)
54 - multiple_grid_cells (NUMERICAL)
55 - rate_constants_no_user_defined_example_by_hand (NUMERICAL)
56 - rate_constants_user_defined_example_by_hand (NUMERICAL)
57 - solver_configuration (NUMERICAL)
59 - rate_constants_no_user_defined_example_with_config (NUMERICAL)
60 - rate_constants_user_defined_example_with_config (NUMERICAL)
61 - carbon_bond_5_example (NUMERICAL)
62 - chapman_example (NUMERICAL)
63 - robertson_example (NUMERICAL)
64 - ts1_example (NUMERICAL)
I am not sure what happened but after my latest pull and merge- lot of tests failed. I am looking what caused the test failures |
Interesting. I just ran the CUDA tests on my branch for the LU decomposition rename PR and it ran much faster.
Can you run it on a scratch directory in case it is an issue due to the filesystem for the home directory? |
Oh man. That's drastically longer. I will try scratch and see what happens |
@sjsprecious I guess it was a scratch issue?
|
@K20shores The new result is consistent with mine now. I noticed that you were running the CUDA tests on your home directory on Derecho and I think that was the problem. |
… into allowSolversToModify_621
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @K20shores and @montythind for working on this and addressing all my comments. It looks great to me and I could confirm that all the CPU & GPU tests pass on Derecho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just one minor question, but nothing that should hold up merging
solver_.parameters_ = params; | ||
return solver_.Solve(time_step, state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to have parameters_
be a data member of solver_
still? Could we just pass the parameters to the solve function as an argument by reference and avoid the copy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I just have a couple questions and suggestions.
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest initializing the struct variable in the other two constructors that don’t pass relative tolerance
as a function argument.
SolverParameters(System&& system, std::vector<Process>&& processes, RosenbrockSolverParameters&& parameters)
: system_(system),
processes_(processes),
parameters_(parameters)
{
relative_tolerance_ = 0.0;
}
@@ -959,7 +968,7 @@ namespace micm | |||
SolverParameters GetSolverParams() | |||
{ | |||
return SolverParameters( | |||
std::move(System(this->gas_phase_, this->phases_)), std::move(this->processes_), std::move(this->parameters_)); | |||
std::move(System(this->gas_phase_, this->phases_)), std::move(this->processes_), std::move(this->parameters_), std::move(this->relative_tolerance_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove std::move
? It doesn’t match the constructor and I think there's no real need for that for a double.
this->relative_tolerance_;
@@ -65,6 +65,13 @@ namespace micm | |||
return result; | |||
} | |||
|
|||
// Overloaded Solve function to change parameters | |||
SolverResult Solve(double time_step, StatePolicy& state, SolverParametersType& params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can they be passed as const ref since the objects are not modified?
SolverResult Solve(double time_step, const StatePolicy& state, const SolverParametersType& params)
|
||
|
||
this->SetAbsoluteTolerances(state_parameters.absolute_tolerance_, species_map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this additional new line isn't necessary?
This PR includes moving Parameters
absolute tolerance and relative tolearnce to state from solver
Note:
I have left
std::vector absolute_tolerance_;
double relative_tolerance_{ 1e-6 };
in rosenbrock_solver_prarameter.hpp as the CUDA tests are failing because tolerance doesnt get copied over to the device. Issue occurs in CudaRosenbrockSolver constructor when doing this->parameters_.absolute_tolerance_.size(); it comes out as zero
We can potential get rid of this line in solver_builder.inl. This is also a temporary. solution.
options.absolute_tolerance_ = state_parameters.absolute_tolerance_;
Along with that i have commented out unit tests till we don't have a solution how to deal with tolerance.
closes #621