Skip to content
Snippets Groups Projects
Commit 9cde6b7e authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Split method to reorder send and receive indices into two

parent 7be0eca6
No related branches found
No related tags found
1 merge request!104Add Communication Hiding to GPU version
...@@ -86,10 +86,12 @@ public: ...@@ -86,10 +86,12 @@ public:
virtual uint getNumberOfReceiveIndices( int direction, uint level ) = 0; virtual uint getNumberOfReceiveIndices( int direction, uint level ) = 0;
virtual void getSendIndices( int* sendIndices, int direction, int level ) = 0; virtual void getSendIndices( int* sendIndices, int direction, int level ) = 0;
virtual void getReceiveIndices( int* sendIndices, int direction, int level ) = 0; virtual void getReceiveIndices( int* sendIndices, int direction, int level ) = 0;
virtual void reorderSendRecvIndexForCommAfterFtoC(int *sendIndices, int *recvIndices, virtual void reorderSendIndexForCommAfterFtoC(int *sendIndices, int &numberOfSendNeighborsAfterFtoC,
int &numberOfSendNeighborsAfterFtoC, uint *iCellFCCBorder, uint sizeOfICellFCCBorder, int direction,
int &numberOfRecvNeighborsAfterFtoC, uint *iCellFCCBorder, int level) = 0;
uint sizeOfICellFCCBorder, int direction, int level) = 0; virtual void reorderRecvIndexForCommAfterFtoC(int *recvIndices, int &numberOfRecvNeighborsAfterFtoC,
uint *iCellFCCBorder, uint sizeOfICellFCCBorder, int direction,
int level) = 0;
virtual uint getNumberOfFluidNodes(unsigned int level) const = 0; virtual uint getNumberOfFluidNodes(unsigned int level) const = 0;
virtual void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const = 0; virtual void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const = 0;
......
...@@ -266,20 +266,15 @@ GRIDGENERATOR_EXPORT void LevelGridBuilder::getReceiveIndices(int * receiveIndic ...@@ -266,20 +266,15 @@ GRIDGENERATOR_EXPORT void LevelGridBuilder::getReceiveIndices(int * receiveIndic
} }
} }
GRIDGENERATOR_EXPORT void LevelGridBuilder::reorderSendRecvIndexForCommAfterFtoC(int *sendIndices, int *recvIndices, GRIDGENERATOR_EXPORT void LevelGridBuilder::reorderSendIndexForCommAfterFtoC(int *sendIndices, int &numberOfSendNeighborsAfterFtoC,
int &numberOfSendNeighborsAfterFtoC, uint* iCellFCCBorder, uint sizeOfICellFCCBorder,
int &numberOfRecvNeighborsAfterFtoC, int direction, int level)
uint* iCellFCCBorder,
uint sizeOfICellFCCBorder,
int direction, int level)
{ {
uint numberOfIndices = getNumberOfSendIndices(direction, level); uint numberOfIndices = getNumberOfSendIndices(direction, level);
int sparseIndexSend; int sparseIndexSend;
bool isInICellFCCBorder; bool isInICellFCCBorder;
std::vector<int> sendIndicesAfterFtoC; std::vector<int> sendIndicesAfterFtoC;
std::vector<int> sendIndicesOther; std::vector<int> sendIndicesOther;
std::vector<int> recvIndicesAfterFtoC;
std::vector<int> recvIndicesOther;
for (uint i = 0; i < numberOfIndices; i++) { for (uint i = 0; i < numberOfIndices; i++) {
sparseIndexSend = sendIndices[i]; sparseIndexSend = sendIndices[i];
...@@ -294,29 +289,60 @@ GRIDGENERATOR_EXPORT void LevelGridBuilder::reorderSendRecvIndexForCommAfterFtoC ...@@ -294,29 +289,60 @@ GRIDGENERATOR_EXPORT void LevelGridBuilder::reorderSendRecvIndexForCommAfterFtoC
} }
// add index to corresponding vector // add index to corresponding vector
if (isInICellFCCBorder) { if (isInICellFCCBorder)
sendIndicesAfterFtoC.push_back(sparseIndexSend); sendIndicesAfterFtoC.push_back(sparseIndexSend);
recvIndicesAfterFtoC.push_back(sparseIndexSend); else
} else { sendIndicesOther.push_back(sparseIndexSend);
sendIndicesOther.push_back(recvIndices[i]);
recvIndicesOther.push_back(recvIndices[i]);
}
} }
numberOfSendNeighborsAfterFtoC = sendIndicesAfterFtoC.size(); numberOfSendNeighborsAfterFtoC = sendIndicesAfterFtoC.size();
numberOfRecvNeighborsAfterFtoC = recvIndicesAfterFtoC.size();
// copy new vectors back to sendIndices and receive indices arrays // copy new vectors back to sendIndices array
for (uint i = 0; i < numberOfSendNeighborsAfterFtoC; i++) { for (uint i = 0; i < numberOfSendNeighborsAfterFtoC; i++)
sendIndices[i] = sendIndicesAfterFtoC[i]; sendIndices[i] = sendIndicesAfterFtoC[i];
recvIndices[i] = recvIndicesAfterFtoC[i];
}
for (uint i = 0; i < sendIndicesOther.size(); i++) { for (uint i = 0; i < sendIndicesOther.size(); i++) {
sendIndices[i + numberOfSendNeighborsAfterFtoC] = sendIndicesOther[i]; sendIndices[i + numberOfSendNeighborsAfterFtoC] = sendIndicesOther[i];
recvIndices[i + numberOfRecvNeighborsAfterFtoC] = recvIndicesOther[i];
} }
} }
GRIDGENERATOR_EXPORT void LevelGridBuilder::reorderRecvIndexForCommAfterFtoC(int *recvIndices, int &numberOfRecvNeighborsAfterFtoC,
uint *iCellFCCBorder, uint sizeOfICellFCCBorder,
int direction, int level)
{
uint numberOfIndices = getNumberOfReceiveIndices(direction, level);
int sparseIndexRecv;
bool isInICellFCCBorder;
std::vector<int> recvIndicesAfterFtoC;
std::vector<int> recvIndicesOther;
for (uint i = 0; i < numberOfIndices; i++) {
sparseIndexRecv = recvIndices[i];
// check if sparse index is in ICellFCC border
isInICellFCCBorder = false;
for (uint j = 0; j < sizeOfICellFCCBorder; j++) {
if (iCellFCCBorder[j] == sparseIndexRecv) {
isInICellFCCBorder = true;
break;
}
}
// add index to corresponding vector
if (isInICellFCCBorder)
recvIndicesAfterFtoC.push_back(sparseIndexRecv);
else
recvIndicesOther.push_back(sparseIndexRecv);
}
numberOfRecvNeighborsAfterFtoC = recvIndicesAfterFtoC.size();
// copy new vectors back to receiveIndices array
for (uint i = 0; i < numberOfRecvNeighborsAfterFtoC; i++)
recvIndices[i] = recvIndicesAfterFtoC[i];
for (uint i = 0; i < recvIndicesOther.size(); i++)
recvIndices[i + numberOfRecvNeighborsAfterFtoC] = recvIndicesOther[i];
}
uint LevelGridBuilder::getNumberOfNodes(unsigned int level) const uint LevelGridBuilder::getNumberOfNodes(unsigned int level) const
{ {
return grids[level]->getSparseSize(); return grids[level]->getSparseSize();
......
...@@ -149,11 +149,12 @@ public: ...@@ -149,11 +149,12 @@ public:
GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices( int direction, uint level ) override; GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices( int direction, uint level ) override;
GRIDGENERATOR_EXPORT void getSendIndices( int* sendIndices, int direction, int level ) override; GRIDGENERATOR_EXPORT void getSendIndices( int* sendIndices, int direction, int level ) override;
GRIDGENERATOR_EXPORT void getReceiveIndices( int* sendIndices, int direction, int level ) override; GRIDGENERATOR_EXPORT void getReceiveIndices( int* sendIndices, int direction, int level ) override;
GRIDGENERATOR_EXPORT void reorderSendRecvIndexForCommAfterFtoC(int *sendIndices, int *recvIndices, GRIDGENERATOR_EXPORT void reorderSendIndexForCommAfterFtoC(int *sendIndices, int &numberOfSendNeighborsAfterFtoC,
int &numberOfSendNeighborsAfterFtoC, uint *iCellFCCBorder, uint sizeOfICellFCCBorder,
int &numberOfRecvNeighborsAfterFtoC, int direction, int level) override;
uint *iCellFCCBorder, uint sizeOfICellFCCBorder, GRIDGENERATOR_EXPORT void reorderRecvIndexForCommAfterFtoC(int *recvIndices, int &numberOfRecvNeighborsAfterFtoC,
int direction, int level) override; uint *iCellFCCBorder, uint sizeOfICellFCCBorder,
int direction, int level) override;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment