Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

remove unnecessary EnforceLimits on old state #668

Merged
merged 1 commit into from
Jul 7, 2024

Conversation

BenWibking
Copy link
Collaborator

@BenWibking BenWibking commented Jul 6, 2024

Description

Immediately after a regrid, the old state state_old_cc_ is uninitialized (and unused, because all of the times of the regridded levels are synchronized at that moment). Therefore, EnforceLimits does not need to be called on it.

Since the old state is unused, this PR doesn't affect the simulation evolution in any way. However, this avoids spurious FPEs from trying to process zero or NaN values in the old state array.

Related issues

Fixes #401.

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues see (see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • I have tested this PR on my local computer and all tests pass.
  • I have manually triggered the GPU tests with the magic comment /azp run.
  • I have requested a reviewer for this PR.

Immediately after a regrid, the old state `state_old_cc_` is uninitialized (and unused). `EnforceLimits` does not need to be called on it.

This avoids spurious FPEs from trying to process the uninitialized or NaN values.
@BenWibking BenWibking requested a review from psharda July 6, 2024 18:35
@BenWibking
Copy link
Collaborator Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@BenWibking BenWibking mentioned this pull request Jul 6, 2024
7 tasks
@BenWibking BenWibking enabled auto-merge July 6, 2024 21:09
@BenWibking BenWibking added this pull request to the merge queue Jul 7, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 7, 2024
Merged via the queue into development with commit 080145d Jul 7, 2024
21 checks passed
@BenWibking BenWibking deleted the BenWibking/avoid-unneeded-enforcelimits branch July 7, 2024 16:02
github-merge-queue bot pushed a commit that referenced this pull request Jul 11, 2024
### Description
Enables signal handling and floating-point exception (FPE) traps for
NANs when running the test suite, so it will stop and report an error
when NANs are encountered. (This only works on CPUs.)

In order for this to work, we change the signal handling settings back
to AMReX defaults. We also have to suppress FPEs when importing `numpy`
(see numpy/numpy#20504).

By default, many compilers perform optimizations that assume that
floating-point exceptions are disabled, and will often produce spurious
FPEs for vectorized code (however, this does not affect the results in
any way). There are compiler-specific options to disable this behavior
for Intel and Clang.

Note that `AMReX_FPE=ON` only sets the compiler option `-ftrapv` (or
similar). We instead add the runtime options `amrex.fpe_trap_invalid=1`,
`amrex.fpe_trap_zero=1`, and `amrex.fpe_trap_overflow=1` to the
command-line arguments for each test. These options can also be added to
the input file (or command line) to debug individual problems.

**Depends on:**
* #667
* #668
* #671

### Related issues
Partially resolves #556.

### Checklist
_Before this pull request can be reviewed, all of these tasks should be
completed. Denote completed tasks with an `x` inside the square brackets
`[ ]` in the Markdown source below:_
- [x] I have added a description (see above).
- [x] I have added a link to any related issues see (see above).
- [x] I have read the [Contributing
Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md).
- [ ] I have added tests for any new physics that this PR adds to the
code.
- [x] I have tested this PR on my local computer and all tests pass.
- [x] I have manually triggered the GPU tests with the magic comment
`/azp run`.
- [x] I have requested a reviewer for this PR.

---------

Co-authored-by: Piyush Sharda <34922596+psharda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
lgtm This PR has been approved by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EnforceLimits is sometimes called with rho = 0, resulting in NANs
2 participants