Commit 439e411b authored by BRAMAS Berenger's avatar BRAMAS Berenger

update mpi classes

parent 70fc4abe
......@@ -108,9 +108,8 @@ public:
/** Write back, position + sizeof(object) has to be < size */
template <class ClassType>
void writeAt(const FSize position, const ClassType& object){
FAssertLF(position <= currentIndex);
currentIndex = position;
write(object);
FAssertLF(position+FSize(sizeof(ClassType)) <= currentIndex);
memcpy(&array[position], &object, sizeof(ClassType));
}
/** Write an array
......
......@@ -492,7 +492,7 @@ protected:
MPI_Isend(&bufferSize, 1, FMpi::GetType(bufferSize), currentProcIdToSendTo,
FMpi::TagFmmM2MSize + idxLevel, comm.getComm(), &requestsSize[iterMpiRequestsSize++]);
FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max());
MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_PACKED, currentProcIdToSendTo,
MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_BYTE, currentProcIdToSendTo,
FMpi::TagFmmM2M + idxLevel, comm.getComm(), &requests[iterMpiRequests++]);
}
}
......@@ -533,7 +533,7 @@ protected:
if(procHasWorkAtLevel(idxLevel+1, idProcSource) && procCoversMyRightBorderCell(idxLevel, idProcSource)){
recvBuffer[nbProcThatSendToMe].cleanAndResize(recvBufferSize[nbProcThatSendToMe]);
FAssertLF(recvBufferSize[nbProcThatSendToMe] < std::numeric_limits<int>::max());
MPI_Irecv(recvBuffer[nbProcThatSendToMe].data(), int(recvBufferSize[nbProcThatSendToMe]), MPI_PACKED,
MPI_Irecv(recvBuffer[nbProcThatSendToMe].data(), int(recvBufferSize[nbProcThatSendToMe]), MPI_BYTE,
idProcSource, FMpi::TagFmmM2M + idxLevel, comm.getComm(), &requests[iterMpiRequests++]);
nbProcThatSendToMe += 1;
FAssertLF(nbProcThatSendToMe <= 7);
......@@ -557,7 +557,7 @@ protected:
// Retreive data and merge my child and the child from others
for(int idxProc = 0 ; idxProc < nbProcThatSendToMe ; ++idxProc){
int packageFlags = int(recvBuffer[idxProc].getValue<char>());
unsigned packageFlags = unsigned(recvBuffer[idxProc].getValue<unsigned char>());
int position = 0;
int positionToInsert = 0;
......@@ -1113,7 +1113,7 @@ protected:
FMpi::MpiAssert( MPI_Isend(&sendBufferSize, 1, FMpi::GetType(sendBufferSize), idxProcSend,
FMpi::TagFmmL2LSize + idxLevel, comm.getComm(), &requestsSize[iterRequestsSize++]), __LINE__);
FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max());
FMpi::MpiAssert( MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_PACKED, idxProcSend,
FMpi::MpiAssert( MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_BYTE, idxProcSend,
FMpi::TagFmmL2L + idxLevel, comm.getComm(), &requests[iterRequests++]), __LINE__);
// Inc and check the counter
nbMessageSent += 1;
......@@ -1136,7 +1136,7 @@ protected:
if(hasToReceive){
recvBuffer.cleanAndResize(recvBufferSize);
FAssertLF(recvBuffer.getCapacity() < std::numeric_limits<int>::max());
FMpi::MpiAssert( MPI_Irecv( recvBuffer.data(), int(recvBuffer.getCapacity()), MPI_PACKED, idxProcToReceive,
FMpi::MpiAssert( MPI_Irecv( recvBuffer.data(), int(recvBuffer.getCapacity()), MPI_BYTE, idxProcToReceive,
FMpi::TagFmmL2L + idxLevel, comm.getComm(), &requests[iterRequests++]), __LINE__ );
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -115,8 +115,8 @@ int main(int argc, char* argv[])
tree.getBoxWidth(),tree.getHeight(),
&finalParticles, &balancer);
{ // -----------------------------------------------------
std::cout << "Creating & Inserting " << finalParticles.getSize() << " particles ..." << std::endl;
std::cout << "For a total of " << loader.getNumberOfParticles() * app.global().processCount() << " particles ..." << std::endl;
std::cout << app.global().processId() << "] Creating & Inserting " << finalParticles.getSize() << " particles ..." << std::endl;
std::cout << app.global().processId() << "] For a total of " << loader.getNumberOfParticles() * app.global().processCount() << " particles ..." << std::endl;
std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl;
time.tic();
......@@ -126,8 +126,17 @@ int main(int argc, char* argv[])
}
time.tac();
std::cout << "Done " << "(@Creating and Inserting Particles = "
std::cout << app.global().processId() << "] Done " << "(@Creating and Inserting Particles = "
<< time.elapsed() << "s)." << std::endl;
FSize minPart = std::numeric_limits<FSize>::max();
FSize maxPart = std::numeric_limits<FSize>::min();
tree.forEachLeaf([&](LeafClass* lf){
minPart = FMath::Min(lf->getSrc()->getNbParticles(), minPart);
maxPart = FMath::Max(lf->getSrc()->getNbParticles(), maxPart);
});
std::cout << app.global().processId() << "] Min nb part " << minPart << " Max nb part " << maxPart << std::endl;
} // -----------------------------------------------------
delete[] particles;
......@@ -139,13 +148,14 @@ int main(int argc, char* argv[])
KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox());
FmmClass algorithm(app.global(),&tree, &kernels);
time.tac();
std::cout << "Done " << "(@Init = " << time.elapsed() << "s)." << std::endl;
std::cout << app.global().processId() << "] Done " << "(@Init = " << time.elapsed() << "s)." << std::endl;
time.tic();
algorithm.execute();
time.tac();
std::cout << "Done " << "(@Algorithm = " << time.elapsed() << "s)." << std::endl;
std::cout << app.global().processId() << "] Done " << "(@Algorithm = " << time.elapsed() << "s)." << std::endl;
} // -----------------------------------------------------
app.global().barrier();
return 0;
}
......
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