trixi-framework / trixi-framework/Trixi.jl
Finding cells to refine may be inefficient
- Dominant language
- Julia
- Stars
- 731
- Forks
- 166
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 25
Description
In #361, the line
```julia
# The "Ref(...)" is such that we can vectorize the search but not the array that is searched
elements_to_refine = searchsortedfirst.(Ref(cache.elements.cell_ids[1:nelements(dg, cache)]),
cells_to_refine)
```
was replaced by
```julia
# Find all indices of elements whose cell ids are in cells_to_refine
elements_to_refine = findall(cell_id -> cell_id in cells_to_refine, cache.elements.cell_ids)
```
While the latter is more readable and works if `cell_ids` is smaller than `cells_to_refine` (which is important for MPI, see [this comment](https://github.com/trixi-framework/Trixi.jl/pull/361#discussion_r535064054)), the former utilizes the fact that `cell_ids` is sorted.
As discussed with @sloede, this is currently not relevant for performance, but in case it eventually becomes relevant, this issue could help us identify the problem.
Contributor guide
Research direction
Start with the two cell-selection expressions shown in the issue and the discussion in pull request #361, especially the linked comment. Compare their behavior and cost when cache.elements.cell_ids is sorted and when it is smaller than cells_to_refine for MPI. Done means documenting a measured conclusion or making a justified improvement supported by relevant checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- distributed-systems, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100