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

Feature/arkode sts #541

Open
wants to merge 383 commits into
base: develop
Choose a base branch
from
Open

Feature/arkode sts #541

wants to merge 383 commits into from

Conversation

maggul
Copy link
Collaborator

@maggul maggul commented Jul 12, 2024

This is a draft PR for feedback on new STS module.

@drreynolds
Copy link
Collaborator

Unfortunately, the rebase to develop seems to have marked hundreds of files as conflicts. I'll work on fixing this branch now, so that it will be easier for folks to review.

@balos1
Copy link
Member

balos1 commented Jul 12, 2024

Unfortunately, the rebase to develop seems to have marked hundreds of files as conflicts. I'll work on fixing this branch now, so that it will be easier for folks to review.

Yeah, I think in the future we should not rebase develop on main (if main is updated directly) and instead do a merge. I don't see a real advantage to having the same linear history for main and develop, and it seems the rebase has a pretty big downside.

@drreynolds
Copy link
Collaborator

and it seems the rebase has a pretty big downside.

Indeed. Although rebasing might be no big deal for branches with 1-2 commits, it is a huge waste of time for a branch with any appreciable amount of development.

Copy link
Collaborator

@drreynolds drreynolds left a comment

Choose a reason for hiding this comment

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

I still need to look at the changes in src/arkode, but I wanted to share my comments so far.

examples/arkode/C_serial/erk_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/erk_analytic.out Outdated Show resolved Hide resolved
examples/arkode/C_serial/ark_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@drreynolds drreynolds left a comment

Choose a reason for hiding this comment

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

One more set of comments, covering the rest of this draft PR.

src/arkode/arkode_lsrkstep_impl.h Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep_impl.h Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep_impl.h Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep_impl.h Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep_io.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
@maggul maggul marked this pull request as ready for review September 9, 2024 16:51
@balos1 balos1 added this to the SUNDIALS Next milestone Sep 10, 2024
Copy link
Collaborator

@drreynolds drreynolds left a comment

Choose a reason for hiding this comment

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

I've finished reviewing the documentation updates. I'll review the code soon.

CHANGELOG.md Outdated Show resolved Hide resolved
doc/shared/RecentChanges.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Constants.rst Show resolved Hide resolved
doc/arkode/guide/source/Mathematics.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Mathematics.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_supplied.rst Outdated Show resolved Hide resolved
doc/arkode/guide/source/Usage/LSRKStep/User_supplied.rst Outdated Show resolved Hide resolved
doc/shared/sundials.bib Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_analytic_VarJac.c Outdated Show resolved Hide resolved
examples/arkode/C_serial/lsrk_ssp_analytic.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
maggul and others added 2 commits September 11, 2024 16:01
Co-authored-by: Daniel R. Reynolds <[email protected]>
Co-authored-by: Daniel R. Reynolds <[email protected]>
@maggul
Copy link
Collaborator Author

maggul commented Oct 28, 2024

I have completed my revision of the PR. @gardner48, thanks for your comments on the RHS evaluations. I’ve found a way to reduce one more line of vectors, which aligns better with our low-storage claim. This new approach involves recomputing fn if the step fails, which should be infrequent, thereby reducing the extra line of vectors that would otherwise be needed to store fn. Please review the updates and let me know if there’s anything else you need me to address. @drreynolds @balos1 @Steven-Roberts

Copy link
Collaborator

@drreynolds drreynolds left a comment

Choose a reason for hiding this comment

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

I just finished going over the revisions to this PR, and I have a few more minor requests.

src/arkode/arkode_lsrkstep_io.c Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
drreynolds
drreynolds previously approved these changes Nov 5, 2024
Copy link
Collaborator

@Steven-Roberts Steven-Roberts left a comment

Choose a reason for hiding this comment

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

Are the changes in the .gitlab folder intended?

doc/arkode/guide/source/Mathematics.rst Outdated Show resolved Hide resolved

#ifndef SUNIfloor
#if defined(SUNDIALS_DOUBLE_PRECISION)
#define SUNIfloor(x) ((sunindextype)(floor((x)) + SUN_RCONST(0.5)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see why the +0.5 is necessary (and in round function below). This macro has the potential to cause undefined behavior if x is greater than the max sunindextype value. If we can avoid the cast that would be ideal, but if not we should document the potential for undefined behavior.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you think @drreynolds? Where do you think we should document this behavior?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that adding 0.5 is the "standard" trick to ensure that floating-point output from floor is cast to the correct integer.

SUNDIALS has no documentation for our "math" functions, so I do not have a recommendation on where to put it there. I recommend that the comments above (line 329) be updated to mention the danger when casting the output of floor to the nearest sunindextype for arguments that exceed the representable range of sunindextype.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that adding 0.5 is the "standard" trick to ensure that floating-point output from floor is cast to the correct integer.

I think this is conflating the standard trick for rounding:

(sunindextype) (x + SUN_RCONST(0.5))

with simply calling round or floor and casting. Since floor is already called, I see no need to for the +0.5.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The round function returns a double, while an int is expected. Casting a double to an int will truncate the decimal part. If round produces a value slightly less than the expected integer, casting will result in an integer that is one less than desired. To avoid this phenomena, we add 0.5 after rounding and before casting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I may be off on this, but if the algorithm to compute the number of required stages for a given step size h and spectral radius rho is updated to do the comparisons/calculations in floating-point arithmetic, and to then only cast the final result to int, do we even need these new integer-valued functions (e.g., SUNIfloor)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No matter at which stage we do, we have to cast ss to an integer. Can you check the current commit? I think your suggestion will help with limiting ss so that we will not encounter too big integer issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the change. My only recommendation is to use step_mem->req_stages = SUNIceil(ss); so that we are certain to use a "stable" number of stages.

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 ceiled the number once on the top to find ss, so ceiling one more time might end up increasing it by one for the same double argument type reasoning. round seemed to be more appropriate option for me.

src/arkode/arkode.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep.c Show resolved Hide resolved
src/arkode/arkode_lsrkstep_impl.h Outdated Show resolved Hide resolved
src/arkode/arkode_lsrkstep_io.c Outdated Show resolved Hide resolved
@drreynolds
Copy link
Collaborator

Are the changes in the .gitlab folder intended?

I'm guessing they are not intended. I noticed that after the Gitlab CI PR #595 was merged, my local repository clones showed conflicts that needed to be resolved using

git submodule update --init --recursive

I'm guessing that @maggul may have "resolved" the issue in some other way. @maggul, can you clarify what you did to update feature/arkode-sts with these changes from develop after #595 was merged, since we may need to figure out how to resolve this change correctly?

@balos1
Copy link
Member

balos1 commented Nov 6, 2024

Are the changes in the .gitlab folder intended?

I'm guessing they are not intended. I noticed that after the Gitlab CI PR #595 was merged, my local repository clones showed conflicts that needed to be resolved using

git submodule update --init --recursive

I'm guessing that @maggul may have "resolved" the issue in some other way. @maggul, can you clarify what you did to update feature/arkode-sts with these changes from develop after #595 was merged, since we may need to figure out how to resolve this change correctly?

@maggul Should just run

git fetch origin
git checkout origin/develop -- .gitlab
git submodule update
git add .gitlab
git commit

and that should fix things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants