Skip to content

add ReduceToPlaneMF2Patchy#4958

Merged
WeiqunZhang merged 6 commits intoAMReX-Codes:developmentfrom
BenWibking:reducetoplane-sparse
Feb 25, 2026
Merged

add ReduceToPlaneMF2Patchy#4958
WeiqunZhang merged 6 commits intoAMReX-Codes:developmentfrom
BenWibking:reducetoplane-sparse

Conversation

@BenWibking
Copy link
Copy Markdown
Contributor

@BenWibking BenWibking commented Feb 20, 2026

Summary

Adds ReduceToPlaneMF2Patchy to reduce a sparse 3D MultiFab to a sparse 2D MultiFab without constructing a full-domain 2D BaseFab. This should produce the same result as ReduceToPlane up to machine precision, but with less memory usage.

Additional background

ReduceToPlane does not work in practice if the 2D plane is larger than INT_MAX (unless the MPI implementation is fully compliant with the MPI-4 large count specification). Even in this case, the memory usage may be excessive.

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@BenWibking BenWibking marked this pull request as ready for review February 20, 2026 21:03
@BenWibking
Copy link
Copy Markdown
Contributor Author

Failures appear to be unrelated.

github-merge-queue bot pushed a commit to quokka-astro/quokka that referenced this pull request Feb 21, 2026
### Description
Fixes an MPI bug in the plane projection machinery. It probably only
affected very large-scale simulations.

### Related issues
Depends on AMReX-Codes/amrex#4958.

### 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 (if applicable; 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.
- [ ] *(For quokka-astro org members)* I have manually triggered the GPU
tests with the magic comment `/azp run`.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@WeiqunZhang
Copy link
Copy Markdown
Member

The CI failures are due to this. llvm/llvm-project#182462

@WeiqunZhang
Copy link
Copy Markdown
Member

D:\a\amrex\amrex\Tests\ReduceToPlanePatchy\main.cpp(70,25): error : capturing a structured binding is not yet supported in OpenMP [D:\a\amrex\amrex\build\Tests\ReduceToPlanePatchy\Test_ReduceToPlanePatchy_3d.vcxproj]
D:\a\amrex\amrex\Tests\ReduceToPlanePatchy\main.cpp(71,30): error : capturing a structured binding is not yet supported in OpenMP [D:\a\amrex\amrex\build\Tests\ReduceToPlanePatchy\Test_ReduceToPlanePatchy_3d.vcxproj]

The Windows CI failure might be real.

@BenWibking
Copy link
Copy Markdown
Contributor Author

@WeiqunZhang Windows CI passes now.

@WeiqunZhang
Copy link
Copy Markdown
Member

Looks like the Windows issue is still there. And GCC/Clang has the same issue

2026-02-23T20:36:13.6011166Z /home/runner/work/amrex/amrex/Tests/ReduceToPlanePatchy/main.cpp:70:25: error: capturing a structured binding is not yet supported in OpenMP [clang-diagnostic-error]
2026-02-23T20:36:13.6012576Z    70 |         for (MFIter mfi(plane_unique); mfi.isValid(); ++mfi) {
2026-02-23T20:36:13.6013127Z       |                         ^
2026-02-23T20:36:13.6014464Z /home/runner/work/amrex/amrex/Tests/ReduceToPlanePatchy/main.cpp:54:28: note: 'plane_unique' declared here
2026-02-23T20:36:13.6015703Z    54 |         auto [plane_patch, plane_unique] = ReduceToPlaneMF2Patchy<ReduceOpSum>(dir, domain, mf,
2026-02-23T20:36:13.6016495Z       |                            ^
2026-02-23T20:36:13.6017869Z /home/runner/work/amrex/amrex/Tests/ReduceToPlanePatchy/main.cpp:71:30: error: capturing a structured binding is not yet supported in OpenMP [clang-diagnostic-error]
2026-02-23T20:36:13.6019299Z    71 |             auto const& pa = plane_unique.const_array(mfi);
2026-02-23T20:36:13.6030097Z       |                              ^
2026-02-23T20:36:13.6031188Z /home/runner/work/amrex/amrex/Tests/ReduceToPlanePatchy/main.cpp:54:28: note: 'plane_unique' declared here
2026-02-23T20:36:13.6032510Z    54 |         auto [plane_patch, plane_unique] = ReduceToPlaneMF2Patchy<ReduceOpSum>(dir, domain, mf,
2026-02-23T20:36:13.6033281Z       |                            ^

@BenWibking
Copy link
Copy Markdown
Contributor Author

I will just remove OpenMP from this test.

@WeiqunZhang
Copy link
Copy Markdown
Member

You really like structured binding. 😆

@BenWibking
Copy link
Copy Markdown
Contributor Author

@WeiqunZhang Let me know how this version looks.

@WeiqunZhang WeiqunZhang merged commit c635c2a into AMReX-Codes:development Feb 25, 2026
74 checks passed
@BenWibking BenWibking deleted the reducetoplane-sparse branch February 25, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants