AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
553 stars 352 forks source link

Use The_Comms_Arena in particle communication. #4175

Closed atmyers closed 1 month ago

atmyers commented 1 month ago

The proposed changes:

WeiqunZhang commented 1 month ago

Because The_Comms_Arena is an alias to The_Pinned_Arena when gpu aware mpi is not used, the code like below might be problematic.

    // assuming ParallelDescriptor::UseGpuAwareMpi() is false                                                                                                                

    amrex::PODVector<char, PolymorphicArenaAllocator<char> > rcv_buffer;
    rcv_buffer.setArena(The_Comms_Arena()); // pinned memory if not using gpu aware mpi                                                                                      

    if (ParallelDescriptor::UseGpuAwareMpi())
    {
        // ...                                                                                                                                                               
    }
    else
    {
        ...
        // rcv_buffer is not device memory                                                                                                                                   
        Gpu::htod_memcpy_async(rcv_buffer.dataPtr(), pinned_rcv_buffer.dataPtr(), pinned_rcv_buffer.size());
    }
atmyers commented 1 month ago

Maybe we can use The_Comms_Arena() with gpu-aware MPI, and The_Arena() without it.

WeiqunZhang commented 1 month ago

Maybe we can use The_Comms_Arena() with gpu-aware MPI, and The_Arena() without it.

Yes, that would require the least amount of changes.