llnl / llnl/SAMRAI

Overwrite interior and priorities

Open
#170 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
250
Forks
89
Avg merge
34m
Merged PRs (30d)
1

Description

Hi,

We have a geometry that's alike the one of NodeData, meaning that we get some nodes that are shared by adjacent patches on borders/corners, and for which the value should be equal.

In the code, these border/corners nodes are assigned values from large summations over floating point numbers (particles data), and although their final value should be identical, it's not exactly because of the accumulation of truncation errors.

In serial executions, this is not a problem because overlaps are sequentially processed, and only one value prevails for all patches.

In parallel however, if we unconditionally overwrite interior nodes when exchanging data with schedules, the border nodes basically gets swapped between the two PatchDatas concerned with the processed overlap. So that if they have slightly different values as a result of truncations errors, they still do after. If we unconditionally set overwrite_interior to false, then border nodes are simply not assigned and keep their slightly different values.

Over time, this slight mismatch appears to grow until shared nodes have totally different values which crashes the model.

How to deal with this ?
We were hoping that setting overwrite_interior to true or false conditionally would help having one value only prevailing.

The documentation says :

```
The concept of ``overlap'' or data dependency is more complex for generic box geometry objects than for just cell-centered box indices in the abstract AMR index space. Problems arise in cases where data lies on the outside corners, faces, or edges of a box. For these data types, it is likely that there will exist duplicate data values on different patches.

The solution implemented here introduces the concept of ``priority'' between patches. Data of patches with higher priority can overwrite the interiors (face, node, or edge values associated with cells that constitute the interior of the patch) of patches with lower priorities, but lower priority patches can never overwrite the interiors of higher priority patches. This scheme introduces a total ordering of data and therefore eliminates the duplicate information problem.

In practice, this protocol means two things: (1) the communication routines must always process copies from low priority sources to high priority sources, and (2) patches must be given special permission to overwrite their interior values during a write. All destinations are therefore represented by three quantities: (1) the box geometry of the destination (which encodes the box, ghost cells, and geometry), (2) the box geometry of the source, and (3) a flag indicating whether the source has a higher priority than the destination (that is, whether the source can overwrite the interior of the destination). If the overwrite flag is set, then data will be copied over the specified box domain and may write into the interior of the destination. If the overwrite flag is not set, then data will be copied only into the ghost cell values and not the interior values of the patch.
```

however, in our override of boxgeometry, we don't really understand how this conditions should be set.
In 1D, where only 2 patches can share the same node, we could say that lower rank is always overwritten by largest rank.
But in 2D it seems such a condition would end-up being a race condition since a node could be shared by 3 or 4 patches, and the assignement would depend on the order in which overlaps are processed.

Is there some example or general advice as to how to set the "priority between patches" as the doc refers to?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom BoxGeometry override and the documented overwrite_interior and patch-priority protocol. Reproduce the shared-node behavior in the described 1D and 2D parallel cases, then determine a deterministic priority rule that prevents order-dependent overwrites and keeps shared values consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.