-
Notifications
You must be signed in to change notification settings - Fork 437
Closed
Closed
Copy link
Description
- Type: Correctness / Rank-space mismatch
- Severity: Medium
- Component: Print utilities
- Location:
Src/Base/AMReX_Print.H:64Src/Base/AMReX_Print.H:70Src/Base/AMReX_Print.H:145Src/Base/AMReX_Print.H:151Src/Base/AMReX_Print.H:184
Problem
Both classes accept a user-provided MPI_Comm and store it in comm, but rank checks use ParallelContext::MyProcSub() unconditionally:
if (rank == AllProcs || rank == ParallelContext::MyProcSub())This ignores the supplied communicator and compares rank in the wrong rank space.
Impact
- Printing can happen on the wrong rank (or not happen) when using non-default communicators.
- Behavior contradicts the API contract documented in constructors taking
(rank, comm).
Suggested patch
Use communicator-relative rank for filtering, and only use sub-context file stream plumbing when communicator matches sub-communicator.
--- a/Src/Base/AMReX_Print.H
+++ b/Src/Base/AMReX_Print.H
@@
- if (rank == AllProcs || rank == ParallelContext::MyProcSub()) {
+ int const my_rank = ParallelDescriptor::MyProc(comm);
+ if (rank == AllProcs || rank == my_rank) {
@@
- if (rank == AllProcs || rank == ParallelContext::MyProcSub()) {
+ int const my_rank = ParallelDescriptor::MyProc(comm);
+ if (rank == AllProcs || rank == my_rank) {
@@
- int my_proc = ParallelContext::MyProcSub();
+ int my_proc = ParallelDescriptor::MyProc(comm);Prepared by Codex
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels