Commit a4aefb42 authored by berenger-bramas's avatar berenger-bramas

Checkpoint before buffering mpi communication.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@68 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 238c7c82
......@@ -4,7 +4,6 @@
// To get memcpy
#include <cstring>
#include "FGlobal.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
......
......@@ -7,8 +7,8 @@
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "../Utils/FBoolArray.hpp"
#include "../Containers/FBoolArray.hpp"
#include "../Containers/FOctree.hpp"
#include "../Utils/FMpi.hpp"
......@@ -41,6 +41,8 @@ int OctreeHeight, int SubtreeHeight>
typedef typename FOctree<ParticleClass, CellClass,LeafClass, OctreeHeight, SubtreeHeight>::Iterator OctreeIterator;
typedef KernelClass<ParticleClass, CellClass, OctreeHeight> Kernel;
FMpi& app; //< The app to communicate
Octree* const tree; //< The octree to work on
Kernel** kernels; //< The kernels
......@@ -76,11 +78,10 @@ public:
* @param inKernels the kernels to call
* An assert is launched if one of the arguments is null
*/
FFmmAlgorithmThreadProc(Octree* const inTree, Kernel* const inKernels, const int inArgc, char ** const inArgv )
: tree(inTree) , kernels(0), iterArray(0),
FFmmAlgorithmThreadProc(FMpi& inApp, Octree* const inTree, Kernel* const inKernels)
: app(inApp), tree(inTree) , kernels(0), iterArray(0),
previousIterArray(0), previousLeft(0),previousRight(0), previousSize(0),
MaxThreads(omp_get_max_threads()), nbProcess(FMpi::processCount()), idPorcess(FMpi::processId()) {
FMpi::init(inArgc,inArgv);
MaxThreads(omp_get_max_threads()), nbProcess(inApp.processCount()), idPorcess(inApp.processId()) {
assert(tree, "tree cannot be null", __LINE__, __FILE__);
......@@ -90,6 +91,7 @@ public:
}
FDEBUG(FDebug::Controller << "FFmmAlgorithmThreadProc\n");
FDEBUG(FDebug::Controller << "Max threads = " << MaxThreads << " .\n");
}
/** Default destructor */
......@@ -98,7 +100,6 @@ public:
delete this->kernels[idxThread];
}
delete [] this->kernels;
FMpi::destroy();
}
/**
......@@ -272,7 +273,7 @@ public:
}
const int idxReceiver = getProc(parentOffset,leafs);
FMpi::sendData(idxReceiver,sizeof(CellClass),previousIterArray[this->previousLeft+leftOffset].getCurrentCell(),previousLeft+leftOffset);
app.sendData(idxReceiver,sizeof(CellClass),previousIterArray[this->previousLeft+leftOffset].getCurrentCell(),previousLeft+leftOffset);
++leftOffset;
}
......@@ -307,7 +308,7 @@ public:
parentIndex = iterArray[parentOffset].getCurrentGlobalIndex();
}
const int idxReceiver = getProc(parentOffset,leafs);
FMpi::sendData(idxReceiver,sizeof(CellClass),previousIterArray[this->previousRight-rightOffset].getCurrentCell(),previousRight-rightOffset);
app.sendData(idxReceiver,sizeof(CellClass),previousIterArray[this->previousRight-rightOffset].getCurrentCell(),previousRight-rightOffset);
++rightOffset;
}
......@@ -327,7 +328,7 @@ public:
int source = 0, tag = 0, filled = 0;
while(needToReceive){
FMpi::receiveData(sizeof(CellClass),&tempCell,&source,&tag,&filled);
app.receiveData(sizeof(CellClass),&tempCell,&source,&tag,&filled);
if(filled){
*previousIterArray[tag].getCurrentCell() = tempCell;
}
......@@ -365,7 +366,7 @@ public:
parentIndex = iterArray[parentOffset].getCurrentGlobalIndex();
}
const int idxReceiver = getProc(parentOffset,leafs);
FMpi::sendData(idxReceiver,sizeof(CellClass),previousIterArray[idxLeafs].getCurrentCell(),idxLeafs);
app.sendData(idxReceiver,sizeof(CellClass),previousIterArray[idxLeafs].getCurrentCell(),idxLeafs);
}
leftOffsets[idxLevel+1] = (previousRight-previousLeft) + 1;
......@@ -376,7 +377,7 @@ public:
this->previousRight = endIdx - 1;
this->previousSize = leafs;
FMpi::processBarrier();
app.processBarrier();
}
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
......@@ -434,7 +435,6 @@ public:
for(int idxProc = 0 ; idxProc < nbProcess; ++idxProc){
alreadySent[idxProc] = new FBoolArray(leafs);
}
#pragma omp parallel
{
CellClass* neighbors[208];
......@@ -484,7 +484,7 @@ public:
#pragma omp critical(CheckToSend)
{
if(!alreadySent[idxReceiver]->get(idxLeafs)){
FMpi::sendData(idxReceiver,sizeof(CellClass),iterArray[idxLeafs].getCurrentCell(),idxLeafs);
app.sendData(idxReceiver,sizeof(CellClass),iterArray[idxLeafs].getCurrentCell(),idxLeafs);
alreadySent[idxReceiver]->set(idxLeafs,true);
needData = true;
}
......@@ -528,7 +528,7 @@ public:
int source = 0, tag = 0, filled = 0;
while(needToReceive){
FMpi::receiveData(sizeof(CellClass),&tempCell,&source,&tag,&filled);
app.receiveData(sizeof(CellClass),&tempCell,&source,&tag,&filled);
if(filled){
*iterArray[tag].getCurrentCell() = tempCell;
}
......@@ -562,7 +562,7 @@ public:
delete alreadySent[idxProc];
}
FMpi::processBarrier();
app.processBarrier();
}
FDEBUG( FDebug::Controller << "\tFinished (" << counterTime.tacAndElapsed() << "s)\n" );
......@@ -613,12 +613,12 @@ public:
const int leftOffset = -leftOffsets[idxLevel];
for(int idxLeafs = 1 ; idxLeafs <= leftOffset ; ++idxLeafs){
const int idxReceiver = getProc((currentLeft-idxLeafs),leafs);
FMpi::sendData(idxReceiver,sizeof(CellClass),iterArray[currentLeft-idxLeafs].getCurrentCell(),currentLeft-idxLeafs);
app.sendData(idxReceiver,sizeof(CellClass),iterArray[currentLeft-idxLeafs].getCurrentCell(),currentLeft-idxLeafs);
}
const int rightOffset = -rightOffsets[idxLevel];
for(int idxLeafs = 1 ; idxLeafs <= rightOffset ; ++idxLeafs){
const int idxReceiver = getProc((currentRight+idxLeafs),leafs);
FMpi::sendData(idxReceiver,sizeof(CellClass),iterArray[currentRight+idxLeafs].getCurrentCell(),currentRight+idxLeafs);
app.sendData(idxReceiver,sizeof(CellClass),iterArray[currentRight+idxLeafs].getCurrentCell(),currentRight+idxLeafs);
}
FDEBUG(sendCounter.tac());
}
......@@ -632,7 +632,7 @@ public:
int source = 0, tag = 0, filled = 0;
while(needToReceive){
FMpi::receiveData(sizeof(CellClass),&tempCell,&source,&tag,&filled);
app.receiveData(sizeof(CellClass),&tempCell,&source,&tag,&filled);
if(filled){
iterArray[tag].getCurrentCell()->addCell(tempCell);
}
......@@ -654,7 +654,7 @@ public:
}
}
FDEBUG(computationCounter.tac());
FMpi::processBarrier();
app.processBarrier();
}
}
......
#ifndef FABSTRACTSENDABLE_HPP
#define FABSTRACTSENDABLE_HPP
// /!\ Please, you must read the license at the bottom of this page
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FAbstractSendable
* Please read the license
*/
class FAbstractSendable {
protected:
/** Empty Destructor */
virtual ~FAbstractSendable(){}
/** To know the number of bytes needed */
virtual int bytesToSend() const = 0;
/** To put the object into the buffer */
virtual int write(void* const buffer, const int limit) const = 0;
/** To retreive data from a buffer */
virtual int read(void* const buffer, const int limit) = 0;
};
#endif //FABSTRACTSENDABLE_HPP
// [--LICENSE--]
......@@ -17,13 +17,6 @@
* </code>
*/
class FAssertable {
private:
/** To quit current application */
void exitApplication(const int inExitCode) const{
}
protected:
/** Empty Destructor */
virtual ~FAssertable(){}
......@@ -42,22 +35,15 @@ protected:
template <class Tmess, class Tline, class Tfile>
void assert(const bool inTest, const Tmess& inMessage, const Tline& inLinePosition, const Tfile& inFilePosition, const int inExitCode = 1) const {
if(!inTest){
calledBeforeExit();
std::ostringstream oss;
std::ostringstream oss;
oss << "Error in " << inFilePosition << " at line " << inLinePosition <<" :\n";
oss << inMessage << "\n";
std::cerr << oss.str();
exitApplication(inExitCode);
exit(inExitCode);
}
}
/**
* May be implemented in the derived class to know when app will quit
*/
virtual void calledBeforeExit() const {}
};
#endif //FASSERTABLE_HPP
......
......@@ -5,6 +5,10 @@
#include "FGlobal.hpp"
#ifdef SCALFMM_USE_MPI
#include <mpi.h>
#endif
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FMpi
......@@ -13,21 +17,19 @@
* This namespace is to compile with or without mpi
*/
class FMpi {
public:
#ifdef SCALFMM_USE_MPI
////////////////////////////////////////////////////////
// Use MPI
////////////////////////////////////////////////////////
#include <mpi.h>
namespace FMpi {
void init(int inArgc, char ** inArgv ) {
FMpi(int inArgc, char ** inArgv ) {
MPI_Init(&inArgc,&inArgv);
}
void destroy(){
~FMpi(){
MPI_Finalize();
}
......@@ -69,17 +71,13 @@ namespace FMpi {
void abort(const int inErrorCode = 1) {
MPI_Abort(MPI_COMM_WORLD, inErrorCode);
}
};
#else
////////////////////////////////////////////////////////
// Without MPI
////////////////////////////////////////////////////////
namespace FMpi {
void init(int inArgc, char ** inArgv ) {}
void destroy(){}
FMpi(int inArgc, char ** inArgv ) {}
void sendData(const int, const int, void* const, const int ){}
......@@ -107,14 +105,11 @@ namespace FMpi {
exit(inErrorCode);
}
};
#endif
////////////////////////////////////////////////////////
// To use in any case
////////////////////////////////////////////////////////
namespace FMpi {
bool isMaster() {
return !processId();
}
......
......@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "../Src/Utils/FMpi.hpp"
#include "../Src/Utils/FTic.hpp"
#include "../Src/Containers/FOctree.hpp"
......@@ -23,7 +24,6 @@
#include "../Src/Core/FFmmAlgorithmThreadProc.hpp"
#include "../Src/Core/FFmmAlgorithmThread.hpp"
#include "../Src/Files/FFmaLoader.hpp"
#include "../Src/Components/FBasicKernels.hpp"
......@@ -37,7 +37,7 @@
/** Fmb class has to extend {FExtendForces,FExtendPotential,FExtendPhysicalValue}
* Because we use fma loader it needs {FFmaParticle}
* Because we use fma loader it needs {FExtendPhysicalValue}
*/
class TestParticle : public FTestParticle, public FExtendPhysicalValue {
public:
......@@ -58,6 +58,8 @@ int main(int argc, char ** argv){
std::cout << ">> This executable has to be used to test the FMM algorithm.\n";
//////////////////////////////////////////////////////////////
FMpi app( argc, argv);
const int NbLevels = 10;//10;
const int SizeSubLevels = 3;//3
const char* const defaultFilename = "testLoaderFMA.fma"; //../../Data/ "testLoaderFMA.fma" "testFMAlgorithm.fma" Sphere.fma
......@@ -124,7 +126,7 @@ int main(int argc, char ** argv){
FTestKernels<TestParticle, FTestCellPar, NbLevels> kernels;
FFmmAlgorithmThreadProc<FTestKernels, TestParticle, FTestCellPar, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels,argc,argv);
FFmmAlgorithmThreadProc<FTestKernels, TestParticle, FTestCellPar, FSimpleLeaf, NbLevels, SizeSubLevels> algo(app,&tree,&kernels);
algo.execute();
FFmmAlgorithmThread<FTestKernels, TestParticle, FTestCellPar, FSimpleLeaf, NbLevels, SizeSubLevels> algoValide(&treeValide,&kernels);
......
#include "FUTester.hpp"
#include "../Src/Utils/FBoolArray.hpp"
#include "../Src/Containers/FBoolArray.hpp"
/**
......
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