Repository navigation
bugfix for spurious reflections caused by single-precision rounding errors - #1882
Merged
Merged
Conversation
Member
|
looks good - although it breaks the fault examples for now, i'll figure out a way to fix that later. |
Member
Author
|
As I help others check if they were affected by this issue, I have learned a bit more and will keep that info updated here incase others run into this issue in the future.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix MPI interface point mismatch in
xgenerate_databases(fixes #1866)Hi @danielpeter, I think I have found the numerical reflection issue that was affecting my simulations. The PR text below as well as the bugfix were generated by Claude but I have reviewed them and tested the new bugfix. I did the testing on our institute GPU cluster, but also saw the issue when running in CPU mode. I'm not sure why I didn't catch this on the CPU version before, I don't think I was testing the exact same setup so perhaps that prevented me from running into the issue.
Re-compiling and re-running
xgenerate_databasesappears to have fixed the issue. I have confirmed that there are no longer spurious reflections along partition boundaries when looking at wavefield snapshots of the bugfixed code. The changes are minimal but I am not sure if the modifications have any unexpected effects, hope you can review and decide if this is a good approach. Happy to run further tests or modify as you see fit.Problem
Simulations with large mesh coordinates (e.g., UTM, ~10⁶ m) could show spurious reflections along partition boundaries. These artifacts moved when
NPROCchanged, appeared in both CPU and GPU runs that used the same databases, and were absent with a single process.Cause
get_MPI_interface()sorts each interface's points by x, then y, then z, so that both neighboring partitions list shared points in the same order. The solver then pairs points purely by their position in that list during assembly.The coordinates were taken from the
CUSTOM_REALarrays (x/y/zstore_unique). In single precision, a coordinate of ~4.6e6 m is only resolved to ~0.5 m, while the sort tolerance (SMALLVAL_TOL * (x_max - x_min)) is ~1e-5 m. If the same physical point rounded to different single-precision values on two partitions, the sort grouped it differently on each side. From that point on, the two interface lists no longer lined up, and physically different points (tens of km apart, in our case) were assembled together.The existing assembly test in
xgenerate_databasescan't detect this. Assembly is symmetric, so both sides still end up with identical sums.Fix
Sort the interface points using the double-precision GLL coordinates (
xstore/ystore/zstorefromgenerate_databases_par), mapped onto the global points throughibool. In double precision the two partitions' copies of a point differ by ~1e-9 m, well within the tolerance, so both sides produce the same order.Only the sort input changes. The output database format is the same, and no solver or mesher changes are needed. Existing meshes only need
xgenerate_databasesto be rerun.Verification
Tested on an affected mesh (
xmeshfem3D, 2 doubling layers, 16 processes, UTM coordinates). A temporary check compared the coordinates of shared interface points across neighboring ranks:After the fix, the boundary artifacts are gone in both CPU and GPU runs.
🤖 Generated with Claude Code