Commit 1ca97c8c authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Changes for avoiding zero traited as null ptr

parent 42c991d5
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
* so this struct store a particle + its index * so this struct store a particle + its index
*/ */
struct IndexedParticle{ struct IndexedParticle{
public:
MortonIndex index; MortonIndex index;
ParticleClass particle; ParticleClass particle;
...@@ -181,7 +182,7 @@ private: ...@@ -181,7 +182,7 @@ private:
const bool needToRecvBeforeSend = (rank != 0 && (((*workingSize) && otherFirstIndex == workingArray[0].index ) || !(*workingSize))); const bool needToRecvBeforeSend = (rank != 0 && (((*workingSize) && otherFirstIndex == workingArray[0].index ) || !(*workingSize)));
MPI_Request requestSendLeaf; MPI_Request requestSendLeaf;
IndexedParticle* sendBuffer = 0; IndexedParticle* sendBuffer = nullptr;
if(rank != nbProcs - 1 && needToRecvBeforeSend == false){ if(rank != nbProcs - 1 && needToRecvBeforeSend == false){
FSize idxPart = (*workingSize) - 1 ; FSize idxPart = (*workingSize) - 1 ;
while(idxPart >= 0 && workingArray[idxPart].index == otherFirstIndex){ while(idxPart >= 0 && workingArray[idxPart].index == otherFirstIndex){
...@@ -197,7 +198,7 @@ private: ...@@ -197,7 +198,7 @@ private:
rank + 1, FMpi::TagSplittedLeaf, communicator.getComm(), &requestSendLeaf); rank + 1, FMpi::TagSplittedLeaf, communicator.getComm(), &requestSendLeaf);
} }
else{ else{
MPI_Isend( 0, 0, MPI_BYTE, rank + 1, FMpi::TagSplittedLeaf, communicator.getComm(), &requestSendLeaf); MPI_Isend( nullptr, 0, MPI_BYTE, rank + 1, FMpi::TagSplittedLeaf, communicator.getComm(), &requestSendLeaf);
} }
} }
...@@ -223,7 +224,7 @@ private: ...@@ -223,7 +224,7 @@ private:
rank - 1, FMpi::TagSplittedLeaf, communicator.getComm(), MPI_STATUS_IGNORE); rank - 1, FMpi::TagSplittedLeaf, communicator.getComm(), MPI_STATUS_IGNORE);
} }
else{ else{
MPI_Recv( 0, 0, MPI_BYTE, rank - 1, FMpi::TagSplittedLeaf, communicator.getComm(), MPI_STATUS_IGNORE); MPI_Recv( nullptr, 0, MPI_BYTE, rank - 1, FMpi::TagSplittedLeaf, communicator.getComm(), MPI_STATUS_IGNORE);
} }
} }
...@@ -231,21 +232,21 @@ private: ...@@ -231,21 +232,21 @@ private:
MPI_Send( workingArray, int((*workingSize) * sizeof(IndexedParticle)), MPI_BYTE, MPI_Send( workingArray, int((*workingSize) * sizeof(IndexedParticle)), MPI_BYTE,
rank + 1, FMpi::TagSplittedLeaf, communicator.getComm()); rank + 1, FMpi::TagSplittedLeaf, communicator.getComm());
delete[] workingArray; delete[] workingArray;
workingArray = 0; workingArray = nullptr;
(*workingSize) = 0; (*workingSize) = 0;
} }
else if(rank != nbProcs - 1){ else if(rank != nbProcs - 1){
MPI_Wait( &requestSendLeaf, MPI_STATUS_IGNORE); MPI_Wait( &requestSendLeaf, MPI_STATUS_IGNORE);
delete[] sendBuffer; delete[] sendBuffer;
sendBuffer = 0; sendBuffer = nullptr;
} }
} }
} }
{//Filling the Array with leaves and parts //// COULD BE MOVED IN AN OTHER FUCTION {//Filling the Array with leaves and parts //// COULD BE MOVED IN AN OTHER FUCTION
(*leavesSize) = 0; //init ptr (*leavesSize) = 0; //init ptr
(*leavesArray) = 0; //init ptr (*leavesArray) = nullptr; //init ptr
(*leavesIndices) = 0; //init ptr (*leavesIndices) = nullptr; //init ptr
if((*workingSize)){ if((*workingSize)){
...@@ -275,7 +276,7 @@ private: ...@@ -275,7 +276,7 @@ private:
delete [] workingArray; delete [] workingArray;
workingArray = 0; workingArray = nullptr;
} }
} }
...@@ -337,8 +338,8 @@ private: ...@@ -337,8 +338,8 @@ private:
for(int idxProc = 0 ; idxProc < nbProcs ; ++idxProc){ for(int idxProc = 0 ; idxProc < nbProcs ; ++idxProc){
if(idxProc != myRank){ if(idxProc != myRank){
const FSize correctLeftLeafNumber = balancer->getLeft(totalNumberOfLeaves,NULL,0,0,nbProcs,idxProc); const FSize correctLeftLeafNumber = balancer->getLeft(totalNumberOfLeaves,nullptr,0,nullptr,nbProcs,idxProc);
const FSize correctRightLeafNumber = balancer->getRight(totalNumberOfLeaves,NULL,0,0,nbProcs,idxProc); const FSize correctRightLeafNumber = balancer->getRight(totalNumberOfLeaves,nullptr,0,nullptr,nbProcs,idxProc);
//5 cases : Refer to ParalleleDetails.pdf to know more //5 cases : Refer to ParalleleDetails.pdf to know more
...@@ -532,14 +533,14 @@ public: ...@@ -532,14 +533,14 @@ public:
const FPoint& boxCenter, const FReal boxWidth, const int treeHeight, const FPoint& boxCenter, const FReal boxWidth, const int treeHeight,
ContainerClass* particleSaver, FAbstractBalanceAlgorithm* balancer,const SortingType type = QuickSort){ ContainerClass* particleSaver, FAbstractBalanceAlgorithm* balancer,const SortingType type = QuickSort){
IndexedParticle* particlesArray = 0; IndexedParticle* particlesArray = nullptr;
FSize particlesSize = 0; FSize particlesSize = 0;
SortParticlesFromArray(communicator, array, size, type, boxCenter, boxWidth, treeHeight, SortParticlesFromArray(communicator, array, size, type, boxCenter, boxWidth, treeHeight,
&particlesArray, &particlesSize); &particlesArray, &particlesSize);
ParticleClass* leavesArray = 0; ParticleClass* leavesArray = nullptr;
FSize leavesSize = 0; FSize leavesSize = 0;
FSize * leavesIndices = 0; FSize * leavesIndices = nullptr;
MergeLeaves(communicator, particlesArray, &particlesSize, &leavesIndices, &leavesArray, &leavesSize); MergeLeaves(communicator, particlesArray, &particlesSize, &leavesIndices, &leavesArray, &leavesSize);
...@@ -547,7 +548,7 @@ public: ...@@ -547,7 +548,7 @@ public:
/** To produce stats after the Equalize phase /** To produce stats after the Equalize phase
*/ */
int* nbPartsPerProc = {0}; int* nbPartsPerProc;
int myParts = particleSaver->getSize(); int myParts = particleSaver->getSize();
int nbProc = communicator.processCount(); int nbProc = communicator.processCount();
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
// receiving buffer // receiving buffer
IndexType bufferSize = 0; IndexType bufferSize = 0;
SortType* buffer = 0; SortType* buffer = nullptr;
// Create the first com // Create the first com
FMpi::FComm currentComm(originalComm.getComm()); FMpi::FComm currentComm(originalComm.getComm());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment