Commit 7d114481 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

FAlgorithmTimers added, set in AlgorithmThread, Algorithm, and...

FAlgorithmTimers added, set in AlgorithmThread, Algorithm, and AlgorithmThreadProc, use as shown in testFmmAlgorithm.cpp
parent cf0129d6
......@@ -4,13 +4,13 @@
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef FFMMALGORITHM_HPP
......@@ -25,6 +25,7 @@
#include "../Containers/FOctree.hpp"
#include "../Containers/FVector.hpp"
#include "../Utils/FAlgorithmTimers.hpp"
#include "FCoreCommon.hpp"
......@@ -40,14 +41,14 @@
* Of course this class does not deallocate pointer given in arguements.
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithm : public FAbstractAlgorithm {
class FFmmAlgorithm : public FAbstractAlgorithm, public FAlgorithmTimers {
OctreeClass* const tree; //< The octree to work on
KernelClass* const kernels; //< The kernels
const int OctreeHeight;
public:
public:
/** The constructor need the octree and the kernels used for computation
* @param inTree the octree to work on
* @param inKernels the kernels to call
......@@ -71,15 +72,26 @@ public:
* Call this function to run the complete algorithm
*/
void execute(const unsigned operationsToProceed = FFmmNearAndFarFields){
Timers[P2MTimer].tic();
if(operationsToProceed & FFmmP2M) bottomPass();
Timers[P2MTimer].tac();
Timers[M2MTimer].tic();
if(operationsToProceed & FFmmM2M) upwardPass();
Timers[M2MTimer].tac();
Timers[M2LTimer].tic();
if(operationsToProceed & FFmmM2L) transferPass();
Timers[M2LTimer].tac();
Timers[L2LTimer].tic();
if(operationsToProceed & FFmmL2L) downardPass();
Timers[L2LTimer].tac();
Timers[NearTimer].tic();
if( (operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P) ) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
Timers[NearTimer].tac();
}
private:
......@@ -276,5 +288,3 @@ private:
#endif //FFMMALGORITHM_HPP
......@@ -4,13 +4,13 @@
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef FFMMALGORITHMTHREAD_HPP
......@@ -22,6 +22,7 @@
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "Utils/FAlgorithmTimers.hpp"
#include "../Containers/FOctree.hpp"
......@@ -45,7 +46,7 @@
* When using this algorithm the P2P is thread safe.
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThread : public FAbstractAlgorithm{
class FFmmAlgorithmThread : public FAbstractAlgorithm, public FAlgorithmTimers{
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -53,7 +54,7 @@ class FFmmAlgorithmThread : public FAbstractAlgorithm{
int leafsNumber;
static const int SizeShape = 3*3*3;
int shapeLeaf[SizeShape];
int shapeLeaf[SizeShape];
const int MaxThreads;
......@@ -114,15 +115,25 @@ public:
iterArray = new typename OctreeClass::Iterator[leafsNumber];
FAssertLF(iterArray, "iterArray bad alloc");
Timers[P2MTimer].tic();
if(operationsToProceed & FFmmP2M) bottomPass();
Timers[P2MTimer].tac();
Timers[M2MTimer].tic();
if(operationsToProceed & FFmmM2M) upwardPass();
Timers[M2MTimer].tac();
Timers[M2LTimer].tic();
if(operationsToProceed & FFmmM2L) transferPass();
Timers[M2LTimer].tac();
Timers[L2LTimer].tic();
if(operationsToProceed & FFmmL2L) downardPass();
Timers[L2LTimer].tac();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
Timers[NearTimer].tic();
if( (operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P) ) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
Timers[NearTimer].tac();
delete [] iterArray;
iterArray = nullptr;
......@@ -434,5 +445,3 @@ private:
#endif //FFMMALGORITHMTHREAD_HPP
......@@ -23,6 +23,7 @@
#include "../Utils/FLog.hpp"
#include "../Utils/FTic.hpp"
#include "Utils/FAlgorithmTimers.hpp"
#include "../Utils/FGlobal.hpp"
......@@ -61,7 +62,7 @@
* ./Tests/testFmmAlgorithmProc ../Data/testLoaderSmall.fma.tmp
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThreadProc : public FAbstractAlgorithm {
class FFmmAlgorithmThreadProc : public FAbstractAlgorithm, public FAlgorithmTimers {
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -242,16 +243,34 @@ public:
}
// run;
// if(operationsToProceed & FFmmP2M) bottomPass();
// if(operationsToProceed & FFmmM2M) upwardPass();
// if(operationsToProceed & FFmmM2L) transferPass();
// if(operationsToProceed & FFmmL2L) downardPass();
// if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
Timers[P2MTimer].tic();
if(operationsToProceed & FFmmP2M) bottomPass();
Timers[P2MTimer].tac();
Timers[M2MTimer].tic();
if(operationsToProceed & FFmmM2M) upwardPass();
Timers[M2MTimer].tac();
Timers[M2LTimer].tic();
if(operationsToProceed & FFmmM2L) transferPass();
Timers[M2LTimer].tac();
Timers[L2LTimer].tic();
if(operationsToProceed & FFmmL2L) downardPass();
Timers[L2LTimer].tac();
if((operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P)) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
Timers[NearTimer].tic();
if( (operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P) ) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
Timers[NearTimer].tac();
// delete array
delete [] iterArray;
......@@ -474,7 +493,7 @@ private:
if(iterMpiRequests){
FAssertLF(iterMpiRequests <= 8);
MPI_Waitall( iterMpiRequests, requests, status);
}
}
// We had received something so we need to proceed the last M2M
if( hasToReceive ){
......
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef FALGORITHMTIMERS_HPP
#define FALGORITHMTIMERS_HPP
/**
* @brief This class provide a way for the different algorithms to
* store the time spent in each operator.
*
*/
class FAlgorithmTimers{
protected:
FTic * Timers;
public:
enum FTimers{
P2MTimer=0,
M2MTimer=1,
M2LTimer=2,
L2LTimer=3,
L2PTimer=4,
P2PTimer=5,
NearTimer=6,
};
const int nbTimers = 7;
FAlgorithmTimers() : Timers(nullptr)
{
Timers = new FTic[nbTimers];
}
~FAlgorithmTimers(){
delete Timers;
}
const FTic * getAllTimers() const {
return Timers;
}
int getNbOfTimerRecorded() const {
return nbTimers;
}
double getTime(FTimers OpeTimer) const{
//assert to verify size
return Timers[OpeTimer].elapsed();
}
double getCumulatedTime(FTimers OpeTimer) const{
//assert to verify size
return Timers[OpeTimer].cumulated();
}
};
#endif // FALGORITHMTIMERS_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