Skip to content

Suggestions for efficient scheme for elementwise reduction across ranks on MultiFabs? #4473

Discussion options

You must be logged in to vote

Do these MultiFabs have the same BoxArray? How many boxes do they have? Do they have ghost cells? If so, are the number of ghost cells the same? I suppose the BoxArrays are the same and the number of ghost cells are the same too, otherwise it probably does not make sense. If that is the case and there are not that many boxes, you can do

for (MFiter mfi(mf); mfi.isValid(); ++mfi) {
    auto& fab = mf[mfi];
    ParallellReduce::Sum(fab.dataPtr(), int(fab.size()), 0, ParallelDescriptor::Communicator()); 
}

If you have lots of boxes, you can allocate a single chunk of memory for a MultiFab. For example, MultiFab mf(ba,dm,ncomp,nghost,MFInfo{}.SetAllocSingleChunk(true). Then you can do

Parall…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ElloiseFangelLloyd
Comment options

Answer selected by ElloiseFangelLloyd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants