OpenLB 1.7
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > > Class Template Referencefinal

#include <blockLattice.h>

+ Inheritance diagram for olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >:
+ Collaboration diagram for olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >:

Classes

struct  CopyTask
 Wrapper for a local plain-copy block communication request. More...
 
class  HomogeneousCopyTask
 Wrapper for a local homogeneous CPU block communication request. More...
 
class  RecvTask
 Wrapper for a non-blocking block propagation receive request. More...
 
class  SendTask
 Wrapper for a non-blocking block propagation send request. More...
 

Public Member Functions

 ConcreteBlockCommunicator (SuperLattice< T, DESCRIPTOR > &super, LoadBalancer< T > &loadBalancer, SuperCommunicationTagCoordinator< T > &tagCoordinator, MPI_Comm comm, int iC, const BlockCommunicationNeighborhood< T, DESCRIPTOR::d > &neighborhood)
 
 ~ConcreteBlockCommunicator ()
 
void receive () override
 
void send () override
 
void unpack () override
 
void wait () override
 
- Public Member Functions inherited from olb::BlockCommunicator
virtual ~BlockCommunicator ()
 

Detailed Description

template<typename T, typename DESCRIPTOR, Platform PLATFORM>
class olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >

Definition at line 698 of file blockLattice.h.

Constructor & Destructor Documentation

◆ ConcreteBlockCommunicator()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >::ConcreteBlockCommunicator ( SuperLattice< T, DESCRIPTOR > & super,
LoadBalancer< T > & loadBalancer,
SuperCommunicationTagCoordinator< T > & tagCoordinator,
MPI_Comm comm,
int iC,
const BlockCommunicationNeighborhood< T, DESCRIPTOR::d > & neighborhood )

Definition at line 741 of file blockLattice.hh.

749 :
750 _iC(iC)
751#ifdef PARALLEL_MODE_MPI
752, _mpiCommunicator(comm)
753#endif
754{
755#ifdef PARALLEL_MODE_MPI
756 neighborhood.forNeighbors([&](int remoteC) {
757 if (loadBalancer.isLocal(remoteC)) {
758 const Platform remotePlatform = loadBalancer.platform(loadBalancer.loc(remoteC));
759 if (!neighborhood.getCellsInboundFrom(remoteC).empty()) {
760 switch (remotePlatform) {
761#ifdef PLATFORM_GPU_CUDA
762 case Platform::GPU_CUDA:
763 // Use manual copy for local GPU-CPU communication due to better performance
764 _copyTasks.emplace_back(new HeterogeneousCopyTask<T,DESCRIPTOR,Platform::GPU_CUDA,PLATFORM>(
765 neighborhood.getFieldsCommonWith(remoteC),
766 neighborhood.getCellsInboundFrom(remoteC), super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(_iC),
767 neighborhood.getCellsRequestedFrom(remoteC), super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,Platform::GPU_CUDA>>(loadBalancer.loc(remoteC))));
768 break;
769#endif
770 default:
771 // Use manual copy for local CPU-CPU communication due to better performance
772 _copyTasks.emplace_back(new HomogeneousCopyTask(
773 neighborhood.getFieldsCommonWith(remoteC),
774 neighborhood.getCellsInboundFrom(remoteC), super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(_iC),
775 neighborhood.getCellsRequestedFrom(remoteC), super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(loadBalancer.loc(remoteC))));
776 break;
777 }
778 }
779 } else {
780 if (!neighborhood.getCellsOutboundTo(remoteC).empty()) {
781 _sendTasks.emplace_back(std::make_unique<SendTask>(
782 _mpiCommunicator, tagCoordinator.get(loadBalancer.glob(_iC), remoteC),
783 loadBalancer.rank(remoteC),
784 neighborhood.getFieldsCommonWith(remoteC),
785 neighborhood.getCellsOutboundTo(remoteC),
786 super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(_iC)));
787 }
788 if (!neighborhood.getCellsInboundFrom(remoteC).empty()) {
789 _recvTasks.emplace_back(std::make_unique<RecvTask>(
790 _mpiCommunicator, tagCoordinator.get(remoteC, loadBalancer.glob(_iC)),
791 loadBalancer.rank(remoteC),
792 neighborhood.getFieldsCommonWith(remoteC),
793 neighborhood.getCellsInboundFrom(remoteC),
794 super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(_iC)));
795 }
796 }
797 });
798
799#else // not using PARALLEL_MODE_MPI
800 neighborhood.forNeighbors([&](int localC) {
801 if (!neighborhood.getCellsInboundFrom(localC).empty()) {
802 _copyTasks.emplace_back(new HomogeneousCopyTask(
803 neighborhood.getFieldsCommonWith(localC),
804 neighborhood.getCellsInboundFrom(localC), super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(_iC),
805 neighborhood.getCellsRequestedFrom(localC), super.template getBlock<ConcreteBlockLattice<T,DESCRIPTOR,PLATFORM>>(loadBalancer.loc(localC))));
806 }
807 });
808#endif
809}

References olb::BlockCommunicationNeighborhood< T, D >::forNeighbors(), olb::BlockCommunicationNeighborhood< T, D >::getCellsInboundFrom(), olb::BlockCommunicationNeighborhood< T, D >::getCellsOutboundTo(), and olb::LoadBalancer< T >::isLocal().

+ Here is the call graph for this function:

◆ ~ConcreteBlockCommunicator()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >::~ConcreteBlockCommunicator ( )

Definition at line 812 of file blockLattice.hh.

813{ }

Member Function Documentation

◆ receive()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >::receive ( )
overridevirtual

Implements olb::BlockCommunicator.

Definition at line 818 of file blockLattice.hh.

819{
820 for (auto& task : _recvTasks) {
821 task->receive();
822 }
823}

References olb::ConcreteBlockCommunicator< BLOCK >::receive().

+ Here is the call graph for this function:

◆ send()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >::send ( )
overridevirtual

Implements olb::BlockCommunicator.

Definition at line 826 of file blockLattice.hh.

827{
828 for (auto& task : _sendTasks) {
829 task->send();
830 }
831 for (auto& task : _copyTasks) {
832 task->copy();
833 }
834}

References olb::ConcreteBlockCommunicator< BLOCK >::send().

+ Here is the call graph for this function:

◆ unpack()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >::unpack ( )
overridevirtual

Implements olb::BlockCommunicator.

Definition at line 837 of file blockLattice.hh.

838{
839 std::set<typename RecvTask::ref> pending(_recvTasks.begin(), _recvTasks.end());
840 while (!pending.empty()) {
841 auto task_iterator = pending.begin();
842 while (task_iterator != pending.end()) {
843 auto& task = *task_iterator;
844 if (task->isDone()) {
845 task->unpack();
846 task_iterator = pending.erase(task_iterator);
847 }
848 else {
849 ++task_iterator;
850 }
851 }
852 }
853}

◆ wait()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockCommunicator< ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > >::wait ( )
overridevirtual

Implements olb::BlockCommunicator.

Definition at line 856 of file blockLattice.hh.

857{
858 for (auto& task : _copyTasks) {
859 task->wait();
860 }
861 for (auto& task : _sendTasks) {
862 task->wait();
863 }
864}

References olb::ConcreteBlockCommunicator< BLOCK >::wait().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: