diff --git a/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h b/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h new file mode 100644 index 0000000000000000000000000000000000000000..233ed4a2c28909e04fec8d592d7ec015ee551ae9 --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/Communication/CommunicationRoutine.h @@ -0,0 +1,17 @@ +#ifndef INDEX_EXCHANGE +#define INDEX_EXCHANGE + +#include <basics/Core/DataTypes.h> + +namespace vf::gpu +{ +class CommunicationRoutine +{ +public: + virtual void receive_send(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, + int size_buffer_send, int neighbor_rank_send) const = 0; + virtual int getPID() const = 0; +}; +} // namespace vf::gpu + +#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp b/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp index 9105ac98d45a9f98e39f224f1c67b334c8feac72..5df66c788b2186b0bdfad1afa4798cee670ba53b 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/Communicator.cpp @@ -241,15 +241,15 @@ double Communicator::sumNups(double processNups) return *buffer_recv; } -void Communicator::exchangeIndices(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, +void Communicator::receive_send(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, int size_buffer_send, int neighbor_rank_send) const { MPI_Request recv_request; MPI_Irecv(buffer_receive, size_buffer_recv, MPI_UNSIGNED, neighbor_rank_recv, 0, commGPU, &recv_request); - //printf("exchangeIndices PID: %i, nbRev: nb_rank_recv: %i", this->getPID(), nb_rank_r); + //printf("receive_send PID: %i, nbRev: nb_rank_recv: %i", this->getPID(), nb_rank_r); //fflush(stdout); MPI_Send(buffer_send, size_buffer_send, MPI_UNSIGNED, neighbor_rank_send, 0, commGPU); - //printf("exchangeIndices PID: %i, sendUintGPU: nb_rank_send: %i", this->getPID(), nb_rank_s); + //printf("receive_send PID: %i, sendUintGPU: nb_rank_send: %i", this->getPID(), nb_rank_s); //fflush(stdout); MPI_Wait(&recv_request, MPI_STATUSES_IGNORE); } diff --git a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h index 9483c1abed9a60bc645359ddaf5155fddbb8bcf3..38ee4e3c2132490ce511d47f4a7d85ab0ecb49e0 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/Communicator.h +++ b/src/gpu/VirtualFluids_GPU/Communication/Communicator.h @@ -8,7 +8,7 @@ #include "VirtualFluids_GPU_export.h" #include <basics/Core/DataTypes.h> -#include "IndexExchange.h" +#include "CommunicationRoutine.h" ////////////////////////////////// #ifdef VF_DOUBLE_ACCURACY @@ -23,7 +23,7 @@ namespace vf::gpu { -class VIRTUALFLUIDS_GPU_EXPORT Communicator : public IndexExchange +class VIRTUALFLUIDS_GPU_EXPORT Communicator : public CommunicationRoutine { public: static Communicator& getInstance(); @@ -61,7 +61,7 @@ public: std::vector<double> gatherNUPS(double processNups); double sumNups(double processNups); ////////////////////////////////////////////////////////////////////////// - void exchangeIndices(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, + void receive_send(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, int size_buffer_send, int neighbor_rank_send) const override; private: diff --git a/src/gpu/VirtualFluids_GPU/Communication/IndexExchange.h b/src/gpu/VirtualFluids_GPU/Communication/IndexExchange.h deleted file mode 100644 index 67b87c7414e4b8b1d7fc6432c30ed67d11784d26..0000000000000000000000000000000000000000 --- a/src/gpu/VirtualFluids_GPU/Communication/IndexExchange.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef INDEX_EXCHANGE -#define INDEX_EXCHANGE - -#include <basics/Core/DataTypes.h> - -namespace vf::gpu -{ -class IndexExchange -{ -public: - virtual void exchangeIndices(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, - int size_buffer_send, int neighbor_rank_send) const = 0; - virtual int getPID() const = 0; -}; -} // namespace vf::gpu - -#endif \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp index 73bc38dea0234d782258f58b7ea0dda6b26b2e62..5bc4255bddf187676c2c118d34f8f75fe6dc2eb9 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp @@ -10,7 +10,7 @@ IndexRearrangementForStreams::IndexRearrangementForStreams(std::shared_ptr<Parameter> para, std::shared_ptr<GridBuilder> builder, - vf::gpu::IndexExchange &communicator) + vf::gpu::CommunicationRoutine &communicator) : para(para), builder(builder), communicator(communicator) { } @@ -24,7 +24,7 @@ void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoar initSendIndicesForCommAfterFToCX(level, indexOfProcessNeighbor, direction); std::cout << "mpi send and receive "; - std::vector<uint> recvIndicesForCommAfterFtoCPositions = exchangeIndicesForCommAfterFtoCX( + std::vector<uint> recvIndicesForCommAfterFtoCPositions = receive_sendForCommAfterFtoCX( level, indexOfProcessNeighbor, sendIndicesForCommAfterFtoCPositions); std::cout << "reorder receive indices "; @@ -44,7 +44,7 @@ void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoar initSendIndicesForCommAfterFToCY(level, indexOfProcessNeighbor, direction); std::cout << "mpi send and receive "; - std::vector<uint> recvIndicesForCommAfterFtoCPositions = exchangeIndicesForCommAfterFtoCY( + std::vector<uint> recvIndicesForCommAfterFtoCPositions = receive_sendForCommAfterFtoCY( level, indexOfProcessNeighbor, sendIndicesForCommAfterFtoCPositions); std::cout << "reorder receive indices "; @@ -64,7 +64,7 @@ void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoar initSendIndicesForCommAfterFToCZ(level, indexOfProcessNeighbor, direction); std::cout << "mpi send and receive "; - std::vector<uint> recvIndicesForCommAfterFtoCPositions = exchangeIndicesForCommAfterFtoCZ( + std::vector<uint> recvIndicesForCommAfterFtoCPositions = receive_sendForCommAfterFtoCZ( level, indexOfProcessNeighbor, sendIndicesForCommAfterFtoCPositions); std::cout << "reorder receive indices "; @@ -111,7 +111,7 @@ std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCZ return sendIndicesForCommAfterFtoCPositions; } -std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX( +std::vector<uint> IndexRearrangementForStreams::receive_sendForCommAfterFtoCX( uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { // fill the receive vector with zeros as placeholders (0 is never a valid fluid node) @@ -119,7 +119,7 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX std::vector<uint> recvIndicesForCommAfterFtoCPositions( (size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCX[indexOfProcessNeighbor].numberOfNodes * 2, 0); - communicator.exchangeIndices( + communicator.receive_send( recvIndicesForCommAfterFtoCPositions.data(), (int)recvIndicesForCommAfterFtoCPositions.size(), para->getParH(level)->recvProcessNeighborX[indexOfProcessNeighbor].rankNeighbor, sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(), @@ -131,7 +131,7 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX return recvIndicesForCommAfterFtoCPositions; } -std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY( +std::vector<uint> IndexRearrangementForStreams::receive_sendForCommAfterFtoCY( uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { // fill the receive vector with zeros as placeholders (0 is never a valid fluid node) @@ -139,7 +139,7 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY std::vector<uint> recvIndicesForCommAfterFtoCPositions( (size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCY[indexOfProcessNeighbor].numberOfNodes * 2, 0); - communicator.exchangeIndices( + communicator.receive_send( recvIndicesForCommAfterFtoCPositions.data(), (int)recvIndicesForCommAfterFtoCPositions.size(), para->getParH(level)->recvProcessNeighborY[indexOfProcessNeighbor].rankNeighbor, sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(), @@ -151,7 +151,7 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY return recvIndicesForCommAfterFtoCPositions; } -std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ( +std::vector<uint> IndexRearrangementForStreams::receive_sendForCommAfterFtoCZ( uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { // fill the receive vector with zeros as placeholders (0 is never a valid fluid node) @@ -159,7 +159,7 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ std::vector<uint> recvIndicesForCommAfterFtoCPositions( (size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCZ[indexOfProcessNeighbor].numberOfNodes * 2, 0); - communicator.exchangeIndices( + communicator.receive_send( recvIndicesForCommAfterFtoCPositions.data(), (int)recvIndicesForCommAfterFtoCPositions.size(), para->getParH(level)->recvProcessNeighborZ[indexOfProcessNeighbor].rankNeighbor, sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(), diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h index f78e6a52b8ee406eebc76243869c253f77b41595..9a0f391ae3ef99cb8f31a35aaef81d2d0c6a8f54 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h @@ -15,14 +15,14 @@ class Parameter; class GridBuilder; namespace vf::gpu { -class IndexExchange; +class CommunicationRoutine; } class IndexRearrangementForStreams { public: //! \brief Construct IndexRearrangementForStreams object - IndexRearrangementForStreams(std::shared_ptr<Parameter> para, std::shared_ptr<GridBuilder> builder, vf::gpu::IndexExchange& communicator); + IndexRearrangementForStreams(std::shared_ptr<Parameter> para, std::shared_ptr<GridBuilder> builder, vf::gpu::CommunicationRoutine& communicator); ////////////////////////////////////////////////////////////////////////// // communication after fine to coarse @@ -52,11 +52,11 @@ protected: //! \brief send sendIndicesForCommAfterFtoCPositions to receiving process and receive //! recvIndicesForCommAfterFtoCPositions from neighboring process - std::vector<uint> exchangeIndicesForCommAfterFtoCX(uint level, int indexOfProcessNeighbor, + std::vector<uint> receive_sendForCommAfterFtoCX(uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; - std::vector<uint> exchangeIndicesForCommAfterFtoCY(uint level, int indexOfProcessNeighbor, + std::vector<uint> receive_sendForCommAfterFtoCY(uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; - std::vector<uint> exchangeIndicesForCommAfterFtoCZ(uint level, int indexOfProcessNeighbor, + std::vector<uint> receive_sendForCommAfterFtoCZ(uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; //! \brief Initializes the send indices for the communication after the interpolation from fine to coarse @@ -127,13 +127,13 @@ protected: private: std::shared_ptr<GridBuilder> builder; std::shared_ptr<Parameter> para; - vf::gpu::IndexExchange& communicator; + vf::gpu::CommunicationRoutine& communicator; // used for tests friend class IndexRearrangementForStreamsTest_reorderSendIndices; - friend class IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX; - friend class IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY; - friend class IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ; + friend class IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX; + friend class IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY; + friend class IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ; }; #endif diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp index cf6af150060891dd43a503fdc4d5cffe1396f3ad..236523b90ab97842fc7b0cdd9e53396af493e1d6 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp @@ -161,13 +161,13 @@ TEST_F(IndexRearrangementForStreamsTest_reorderSendIndices, reorderSendIndicesFo } ////////////////////////////////////////////////////////////////////////// -// Test exchangeIndicesForCommAfterFtoC +// Test receive_sendForCommAfterFtoC ////////////////////////////////////////////////////////////////////////// -class IndexExchangeDouble : public vf::gpu::IndexExchange +class CommunicationRoutineDouble : public vf::gpu::CommunicationRoutine { public: - void exchangeIndices(uint *buffer_receive, int, int, uint *, int, int) const override + void receive_send(uint *buffer_receive, int, int, uint *, int, int) const override { for (int i = 0; i < (int)receivedIndices.size(); ++i) { *(buffer_receive + i) = receivedIndices[i]; @@ -188,19 +188,19 @@ private: std::vector<uint> receivedIndices; }; -class IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX : public testing::Test +class IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX : public testing::Test { public: - void createTestSubject(vf::gpu::IndexExchange &indexExchange) + void createTestSubject(vf::gpu::CommunicationRoutine &CommunicationRoutine) { - sut = std::make_unique<IndexRearrangementForStreams>(para, builder, indexExchange); + sut = std::make_unique<IndexRearrangementForStreams>(para, builder, CommunicationRoutine); } protected: std::vector<uint> act() { - return sut->exchangeIndicesForCommAfterFtoCX(level, indexOfProcessNeighbor, + return sut->receive_sendForCommAfterFtoCX(level, indexOfProcessNeighbor, sendIndicesForCommAfterFtoCPositions); } @@ -233,9 +233,9 @@ private: }; }; -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, emptyRecvInX) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX, emptyRecvInX) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; communicator.setReceivedIndices(std::vector<uint>()); createTestSubject(communicator); @@ -243,9 +243,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, emptyR EXPECT_THAT(recvIndicesForCommAfterFtoCPositions.size(), testing::Eq(0)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, zeroRecvIndexX) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX, zeroRecvIndexX) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; communicator.setReceivedIndices({ 0 }); createTestSubject(communicator); @@ -253,9 +253,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, zeroRe EXPECT_THAT(recvIndicesForCommAfterFtoCPositions.size(), testing::Eq(0)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, oneRecvIndexX) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX, oneRecvIndexX) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10 }; std::vector<uint> receivedIndicesByComm(4, 0); std::copy(expected.begin(), expected.end(), receivedIndicesByComm.begin()); @@ -267,9 +267,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, oneRec EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, threeRecvIndicesX) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX, threeRecvIndicesX) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10, 20, 30 }; std::vector<uint> receivedIndicesByComm(5, 0); std::copy(expected.begin(), expected.end(), receivedIndicesByComm.begin()); @@ -281,9 +281,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, threeR EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, sixRecvIndicesX) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCX, sixRecvIndicesX) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10, 20, 30, 40, 50, 60 }; std::vector<uint> receivedIndicesByComm(expected.size(), 0); std::copy(expected.begin(), expected.end(), receivedIndicesByComm.begin()); @@ -295,19 +295,19 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCX, sixRec EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -class IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY : public testing::Test +class IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY : public testing::Test { public: - void createTestSubject(vf::gpu::IndexExchange &indexExchange) + void createTestSubject(vf::gpu::CommunicationRoutine &CommunicationRoutine) { - sut = std::make_unique<IndexRearrangementForStreams>(para, builder, indexExchange); + sut = std::make_unique<IndexRearrangementForStreams>(para, builder, CommunicationRoutine); } protected: std::vector<uint> act() { - return sut->exchangeIndicesForCommAfterFtoCY(level, indexOfProcessNeighbor, + return sut->receive_sendForCommAfterFtoCY(level, indexOfProcessNeighbor, sendIndicesForCommAfterFtoCPositions); } @@ -340,9 +340,9 @@ private: }; }; -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, emptyRecvInY) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY, emptyRecvInY) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; communicator.setReceivedIndices(std::vector<uint>()); createTestSubject(communicator); @@ -350,9 +350,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, emptyR EXPECT_THAT(recvIndicesForCommAfterFtoCPositions.size(), testing::Eq(0)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, zeroRecvIndexY) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY, zeroRecvIndexY) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; communicator.setReceivedIndices({ 0 }); createTestSubject(communicator); @@ -360,9 +360,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, zeroRe EXPECT_THAT(recvIndicesForCommAfterFtoCPositions.size(), testing::Eq(0)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, oneRecvIndexY) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY, oneRecvIndexY) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10 }; std::vector<uint> receivedIndicesByComm(4, 0); std::copy(expected.begin(), expected.end(), receivedIndicesByComm.begin()); @@ -374,9 +374,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, oneRec EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, threeRecvIndicesY) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY, threeRecvIndicesY) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10, 20, 30 }; std::vector<uint> receivedIndicesByComm(5, 0); std::copy(expected.begin(), expected.end(), receivedIndicesByComm.begin()); @@ -388,9 +388,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, threeR EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, sixRecvIndicesY) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCY, sixRecvIndicesY) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10, 20, 30, 40, 50, 60 }; std::vector<uint> receivedIndicesByComm(expected.size(), 0); std::copy(expected.begin(), expected.end(), receivedIndicesByComm.begin()); @@ -402,19 +402,19 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCY, sixRec EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -class IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ : public testing::Test +class IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ : public testing::Test { public: - void createTestSubject(vf::gpu::IndexExchange &indexExchange) + void createTestSubject(vf::gpu::CommunicationRoutine &CommunicationRoutine) { - sut = std::make_unique<IndexRearrangementForStreams>(para, builder, indexExchange); + sut = std::make_unique<IndexRearrangementForStreams>(para, builder, CommunicationRoutine); } protected: std::vector<uint> act() { - return sut->exchangeIndicesForCommAfterFtoCZ(level, indexOfProcessNeighbor, + return sut->receive_sendForCommAfterFtoCZ(level, indexOfProcessNeighbor, sendIndicesForCommAfterFtoCPositions); } @@ -447,9 +447,9 @@ private: }; }; -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, emptyRecvInZ) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ, emptyRecvInZ) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; communicator.setReceivedIndices(std::vector<uint>()); createTestSubject(communicator); @@ -457,9 +457,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, emptyR EXPECT_THAT(recvIndicesForCommAfterFtoCPositions.size(), testing::Eq(0)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, zeroRecvIndexZ) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ, zeroRecvIndexZ) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; communicator.setReceivedIndices({ 0 }); createTestSubject(communicator); @@ -467,9 +467,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, zeroRe EXPECT_THAT(recvIndicesForCommAfterFtoCPositions.size(), testing::Eq(0)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, oneRecvIndexZ) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ, oneRecvIndexZ) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10 }; std::vector<uint> receivedIndicesBZComm(4, 0); std::copy(expected.begin(), expected.end(), receivedIndicesBZComm.begin()); @@ -481,9 +481,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, oneRec EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, threeRecvIndicesZ) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ, threeRecvIndicesZ) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10, 20, 30 }; std::vector<uint> receivedIndicesBZComm(5, 0); std::copy(expected.begin(), expected.end(), receivedIndicesBZComm.begin()); @@ -495,9 +495,9 @@ TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, threeR EXPECT_THAT(recvIndicesForCommAfterFtoCPositions, testing::Eq(expected)); } -TEST_F(IndexRearrangementForStreamsTest_exchangeIndicesForCommAfterFtoCZ, sixRecvIndicesZ) +TEST_F(IndexRearrangementForStreamsTest_receive_sendForCommAfterFtoCZ, sixRecvIndicesZ) { - IndexExchangeDouble communicator; + CommunicationRoutineDouble communicator; std::vector<uint> expected = { 10, 20, 30, 40, 50, 60 }; std::vector<uint> receivedIndicesBZComm(expected.size(), 0); std::copy(expected.begin(), expected.end(), receivedIndicesBZComm.begin());