Add functions mapreduce_neighbor and mapreduce_neighbor_unsafe#158
Add functions mapreduce_neighbor and mapreduce_neighbor_unsafe#158efaulhaber wants to merge 5 commits into
mapreduce_neighbor and mapreduce_neighbor_unsafe#158Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #158 +/- ##
==========================================
+ Coverage 86.06% 86.38% +0.31%
==========================================
Files 15 15
Lines 739 771 +32
==========================================
+ Hits 636 666 +30
- Misses 103 105 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces mapreduce_neighbor / mapreduce_neighbor_unsafe as new public APIs to compute per-point reductions over neighbors, and refactors the existing neighbor-iteration internals so foreach_neighbor is implemented as a special case of the new map-reduce kernel.
Changes:
- Add
mapreduce_neighborandmapreduce_neighbor_unsafeto the public API (exports) and implement them for all neighborhood-search backends. - Refactor backend-specific neighbor loops (
GridNeighborhoodSearch,PrecomputedNeighborhoodSearch, and the generic fallback) to return a reduction value (mapreduce_neighbor_inner) and adaptforeach_neighborto use it. - Update tests to use
push!for neighbor collection and add allocation tests forforeach_neighbor/mapreduce_neighborplus keyword-argument error checks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/neighborhood_search.jl |
Fix neighbor list construction (push!) and add tests for mapreduce_neighbor(*), plus allocation and missing-init checks. |
src/PointNeighbors.jl |
Export the new mapreduce_neighbor and mapreduce_neighbor_unsafe APIs. |
src/nhs_precomputed.jl |
Implement reduction-returning neighbor loop for PrecomputedNeighborhoodSearch. |
src/nhs_grid.jl |
Implement reduction-returning neighbor loop for GridNeighborhoodSearch. |
src/neighborhood_search.jl |
Add the new APIs and refactor generic/unsafe neighbor iteration to use the map-reduce inner loop. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR allows us to convert the awkward
to a cleaner
in trixi-framework/TrixiParticles.jl#1211.
This is necessary for vectorization on the CPU.