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

Backware Euler with vectorizable matrix types #596

Merged
merged 45 commits into from
Jul 16, 2024

Conversation

mattldawson
Copy link
Collaborator

@mattldawson mattldawson commented Jul 9, 2024

Adapts the Backward Euler solver to work with vectorizable matrices.

closes #500

Also:

  • moves physical constants and labels into dedicated namespaces
  • adapts analytical tests to solve for multiple grid cells
  • results in a net increase of only one line of code!

K20shores and others added 30 commits July 1, 2024 12:36
…senbrock-on-the-analytical-policy-tests' of https://github.com/NCAR/micm into 577-test-all-parameter-types-of-the-dense-matrix-cpu-rosenbrock-on-the-analytical-policy-tests
…senbrock-on-the-analytical-policy-tests' of https://github.com/NCAR/micm into 577-test-all-parameter-types-of-the-dense-matrix-cpu-rosenbrock-on-the-analytical-policy-tests
…senbrock-on-the-analytical-policy-tests' of github.com:NCAR/micm into 577-test-all-parameter-types-of-the-dense-matrix-cpu-rosenbrock-on-the-analytical-policy-tests
@mattldawson mattldawson marked this pull request as ready for review July 12, 2024 00:23
Copy link
Collaborator

@K20shores K20shores left a comment

Choose a reason for hiding this comment

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

Nice! Only a few questions, but nothing that would hold this up

include/micm/solver/backward_euler.inl Outdated Show resolved Hide resolved
include/micm/solver/backward_euler.inl Show resolved Hide resolved
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 @mattldawson for working on this giant PR and this functionality looks great. Just have one question as listed below.

include/micm/solver/backward_euler.inl Show resolved Hide resolved
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! I don't see anything other than what others have commented on. I left one comment but it shouldn't hold this PR getting merged.

include/micm/util/property_keys.hpp Outdated Show resolved Hide resolved
@sjsprecious
Copy link
Collaborator

Running on Derecho with NVHPC, I got the following failed tests:

         34 - analytical_rosenbrock_integration (Failed)
         35 - analytical_backward_euler (Failed)
         38 - cuda_analytical_rosenbrock_integration (Subprocess aborted)

Looking at the output log, the difference is slightly above the given tolerance. I wonder whether we can add a check to the relative error (like https://github.com/NCAR/micm/blob/main/test/unit/solver/test_rosenbrock.cpp#L138-L139) and pass the test if the relative error is small enough (say < 1.e-14?).

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.

Looks great @mattldawson! Just one quick recommendation but nothing worth holding things up.

EXPECT_EQ(matrix[0][1][1], 8);
EXPECT_EQ(matrix[1][1][1], 10);
EXPECT_EQ(matrix[2][1][1], 12);

Copy link
Collaborator

Choose a reason for hiding this comment

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

We might want to add some checks on the non-diagonal to make sure we are only incrementing the expected indices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added!

@mattldawson
Copy link
Collaborator Author

Running on Derecho with NVHPC, I got the following failed tests:

         34 - analytical_rosenbrock_integration (Failed)
         35 - analytical_backward_euler (Failed)
         38 - cuda_analytical_rosenbrock_integration (Subprocess aborted)

Looking at the output log, the difference is slightly above the given tolerance. I wonder whether we can add a check to the relative error (like https://github.com/NCAR/micm/blob/main/test/unit/solver/test_rosenbrock.cpp#L138-L139) and pass the test if the relative error is small enough (say < 1.e-14?).

I modified the analytical policy tests to include a relative error check and the two CPU tests pass now. Still waiting on the CUDA analytical test to run.

@mattldawson
Copy link
Collaborator Author

Running on Derecho with NVHPC, I got the following failed tests:

         34 - analytical_rosenbrock_integration (Failed)
         35 - analytical_backward_euler (Failed)
         38 - cuda_analytical_rosenbrock_integration (Subprocess aborted)

Looking at the output log, the difference is slightly above the given tolerance. I wonder whether we can add a check to the relative error (like https://github.com/NCAR/micm/blob/main/test/unit/solver/test_rosenbrock.cpp#L138-L139) and pass the test if the relative error is small enough (say < 1.e-14?).

I modified the analytical policy tests to include a relative error check and the two CPU tests pass now. Still waiting on the CUDA analytical test to run.

The CUDA tests now pass with some slightly adjusted tolerances.

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 @mattldawson for working on this and addressing all the comments. I could confirm that all the tests passed on Derecho's A100 GPU.

@sjsprecious sjsprecious merged commit 723585f into main Jul 16, 2024
29 checks passed
@sjsprecious sjsprecious deleted the develop-500-vector-euler branch July 16, 2024 18:59
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.

Adapt Backward Euler to work with vectorizable matrix types
6 participants