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

279 make solve function for ode solvers thread safe #322

Merged
merged 35 commits into from
Oct 27, 2023

Conversation

K20shores
Copy link
Collaborator

@K20shores K20shores commented Oct 23, 2023

Closes #279

Anything that needs to change throughout a solve for a thread now lives on the state. The solver is thread safe assuming each thread has its own state. The test for this is the openmp test. The only way I could verify this was by making each thread share a state. When the threads share a state, the solver never seems to finish, probably because each thread is overwriting the shared data and the error calculation never works properly and the solver keeps trying to divide the timestep.

Many things changed.

  • To make a state, the solver fills out a StateParamters class which should hold everything needed to create a state.
  • Createing a jacobian is now a function in its own header file since that is needed to finish creating the rosenbrock solver, but also needs to be made on the state
  • the lower and upper LU matrices live on the state
  • many tests had to change to accomdate the new state creation
  • The rate constants were also updated to accept only a Conditions class so that I didn't need to create a state except for the user defined and surface rate constants
  • ProcessSets of all types only take the variable map
    • as a side note, the variable map is created twice. Once in the constructor for the rosenbrock solver and again in the state. This implies there's still more design work that could be done to remove duplicate work. I'm not sure how to handle this

@K20shores K20shores linked an issue Oct 23, 2023 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Oct 25, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (3e4024c) 96.59% compared to head (c50352e) 96.39%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
- Coverage   96.59%   96.39%   -0.20%     
==========================================
  Files          34       36       +2     
  Lines        2728     2718      -10     
==========================================
- Hits         2635     2620      -15     
- Misses         93       98       +5     
Files Coverage Δ
include/micm/process/arrhenius_rate_constant.hpp 100.00% <100.00%> (ø)
include/micm/process/branched_rate_constant.hpp 100.00% <100.00%> (ø)
include/micm/process/jit_process_set.hpp 98.79% <ø> (+0.58%) ⬆️
include/micm/process/process.hpp 92.10% <ø> (ø)
include/micm/process/process_set.hpp 98.72% <100.00%> (ø)
...cess/ternary_chemical_activation_rate_constant.hpp 100.00% <100.00%> (ø)
include/micm/process/troe_rate_constant.hpp 100.00% <100.00%> (ø)
include/micm/process/tunneling_rate_constant.hpp 100.00% <100.00%> (ø)
include/micm/solver/jit_linear_solver.hpp 100.00% <ø> (ø)
include/micm/solver/jit_rosenbrock.hpp 96.22% <100.00%> (+0.07%) ⬆️
... and 13 more

... and 2 files with indirect coverage changes

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

@K20shores K20shores requested review from boulderdaze, mattldawson and dwfncar and removed request for boulderdaze October 26, 2023 17:39
@K20shores K20shores marked this pull request as ready for review October 26, 2023 17:39
@mattldawson mattldawson merged commit 0f8c579 into main Oct 27, 2023
58 checks passed
@mattldawson mattldawson deleted the 279-make-solve-function-for-ode-solvers-thread-safe branch October 27, 2023 21:53
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.

Make solve function for ODE solvers thread-safe
3 participants