From 1e29ce7a8c66f0b771a2a21d0768a4f78a9ada58 Mon Sep 17 00:00:00 2001 From: Anna Wellmann <a.wellmann@tu-braunschweig.de> Date: Wed, 6 Oct 2021 16:26:50 +0200 Subject: [PATCH] Use function to find send and receive neighbors in exchange --- .../Communication/ExchangeData27.cpp | 32 +++++++++++++++---- .../Communication/ExchangeData27.h | 6 ++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp index 29e5cb489..5c4ee37b4 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp @@ -111,11 +111,8 @@ void exchangeCollDataXGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe void prepareExchangeCollDataYGPU27(Parameter *para, int level, int streamIndex, bool useReducedCommunicationAfterFtoC) { cudaStream_t stream = (streamIndex == -1) ? CU_STREAM_LEGACY : para->getStreamManager()->getStream(streamIndex); - std::vector<ProcessNeighbor27> *sendProcessNeighbor; - if (useReducedCommunicationAfterFtoC) - sendProcessNeighbor = ¶->getParD(level)->sendProcessNeighborsAfterFtoCY; - else - sendProcessNeighbor = ¶->getParD(level)->sendProcessNeighborY; + std::vector<ProcessNeighbor27> *sendProcessNeighbor = + getSendProcessNeighborY(useReducedCommunicationAfterFtoC, para, level); for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) GetSendFsPostDev27(para->getParD(level)->d0SP.f[0], @@ -132,9 +129,14 @@ void prepareExchangeCollDataYGPU27(Parameter *para, int level, int streamIndex, } void exchangeCollDataYGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMemoryManager *cudaManager, int level, - int streamIndex) + int streamIndex, bool useReducedCommunicationAfterFtoC) { cudaStream_t stream = (streamIndex == -1) ? CU_STREAM_LEGACY : para->getStreamManager()->getStream(streamIndex); + std::vector<ProcessNeighbor27> *sendProcessNeighbor = + getSendProcessNeighborY(useReducedCommunicationAfterFtoC, para, level); + std::vector<ProcessNeighbor27> *recvProcessNeighbor = + getRecvProcessNeighborY(useReducedCommunicationAfterFtoC, para, level); + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //copy Device to Host for (unsigned int i = 0; i < (unsigned int)(para->getNumberOfProcessNeighborsY(level, "send")); i++) @@ -218,6 +220,24 @@ void exchangeCollDataYGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } + +std::vector<ProcessNeighbor27> *getSendProcessNeighborY(bool useReducedCommunicationAfterFtoC, Parameter *para, + int level) +{ + if (useReducedCommunicationAfterFtoC) + return ¶->getParD(level)->sendProcessNeighborsAfterFtoCY; + else + return ¶->getParD(level)->sendProcessNeighborY; +} + +std::vector<ProcessNeighbor27> *getRecvProcessNeighborY(bool useReducedCommunicationAfterFtoC, Parameter *para, + int level) +{ + if (useReducedCommunicationAfterFtoC) + return ¶->getParD(level)->recvProcessNeighborsAfterFtoCY; + else + return ¶->getParD(level)->recvProcessNeighborY; +} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h index 6b537242c..887e4d2b3 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.h @@ -17,9 +17,11 @@ extern "C" void exchangePostCollDataGPU27(Parameter* para, vf::gpu::Communicator extern "C" void prepareExchangeCollDataXGPU27(Parameter *para, int level, int streamIndex); extern "C" void exchangeCollDataXGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMemoryManager *cudaManager, int level, int streamIndex); -extern "C" void prepareExchangeCollDataYGPU27(Parameter *para, int level, int streamIndex, bool useReducedCommunicationAfterFtoC = false); +extern "C" void prepareExchangeCollDataYGPU27(Parameter *para, int level, int streamIndex, + bool useReducedCommunicationAfterFtoC = false); +std::vector<ProcessNeighbor27> *getSendProcessNeighborY(bool useReducedCommunicationAfterFtoC, Parameter *para, int level); extern "C" void exchangeCollDataYGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMemoryManager *cudaManager, - int level, int streamIndex); + int level, int streamIndex, bool useReducedCommunicationAfterFtoC = false); extern "C" void prepareExchangeCollDataZGPU27(Parameter *para, int level, int streamIndex); extern "C" void exchangeCollDataZGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMemoryManager *cudaManager, int level, int streamIndex); -- GitLab