Commit 1c06aca1 authored by COULAUD Olivier's avatar COULAUD Olivier
parents 1366284e a635b026
......@@ -40,7 +40,7 @@
* Of course this class does not deallocate pointer given in arguements.
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmSectionTask : public FAbstractAlgorithm{
class FFmmAlgorithmSectionTask : public FAbstractAlgorithm, public FAlgorithmTimers {
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -99,24 +99,38 @@ protected:
{
#pragma omp section
{
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();
}
#pragma omp section
{
if(operationsToProceed & FFmmP2P) directPass();
Timers[P2PTimer].tic();
if( operationsToProceed & FFmmP2P ) directPass();
Timers[P2PTimer].tac();
}
}
#pragma omp single
{
Timers[L2PTimer].tic();
if(operationsToProceed & FFmmL2P) L2PPass();
Timers[L2PTimer].tac();
}
}
Timers[NearTimer] = Timers[L2PTimer] + Timers[P2PTimer];
}
/////////////////////////////////////////////////////////////////////////////
......@@ -321,7 +335,7 @@ protected:
FLOG( computationCounter.tic() );
for( int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
const int nbLeaf = shapes[idxShape].getSize();
const FSize nbLeaf = shapes[idxShape].getSize();
for(int iterLeaf = 0 ; iterLeaf < nbLeaf ; ++iterLeaf ){
typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf];
#pragma omp task firstprivate(neighbors, toWork)
......
......@@ -60,6 +60,26 @@ public:
tic();
}
FTic(const FTic& other) : start(other.start), end(other.end), cumulate(other.cumulate) {}
FTic(FTic&& other) : start(other.start), end(other.end), cumulate(other.cumulate) {}
FTic& operator=(const FTic& other) {
start = other.start;
end = other.end;
cumulate = other.cumulate;
return *this;
}
const FTic operator+(const FTic& other) {
start = start < other.start ? start : other.start;
end = end > other.end ? end : other.end;
cumulate += other.cumulate;
return FTic(*this);
}
/** Tic : start <= current time */
void tic(){
this->start = FTic::GetTime();
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _ALGOLOADERCOSTZONES_HPP_
#define _ALGOLOADERCOSTZONES_HPP_
#include <memory>
#include <sstream>
#include "PerfTestUtils.hpp"
#include "Core/FFmmAlgorithm.hpp"
......@@ -37,15 +44,20 @@ public:
using CostFmmClass = FFmmAlgorithm
<OctreeClass, CellClass, ContainerClass, CostKernelClass, LeafClass>;
std::stringstream _infostring;
TreeLoader& _treeLoader;
KernelLoader& _kernelLoader;
std::unique_ptr<FMMClass> _algo;
/// Builds the loader
AlgoLoaderCostZones(FPerfTestParams& /*params*/,
TreeLoader& treeLoader,
KernelLoader& kernelLoader) :
_treeLoader(treeLoader),
_kernelLoader(kernelLoader) {
_kernelLoader(kernelLoader),
_algo(nullptr) {
}
......@@ -61,6 +73,7 @@ public:
costAlgo.execute();
this->time.tac();
std::cout << "Generating tree cost: " << this->time.elapsed() << "s.\n";
_infostring << "costgen:" << this->time.elapsed() << " ";
FCostZones<OctreeClass, CellClass> costzones(p_tree, omp_get_max_threads());
......@@ -68,13 +81,19 @@ public:
costzones.run();
this->time.tac();
std::cout << "Generating cost zones: " << this->time.elapsed() << "s.\n";
_infostring << "zonegen:" << this->time.elapsed() << " ";
this->time.tic();
FMMClass algo(p_tree, &(_kernelLoader._kernel), costzones.getZoneBounds(), costzones.getLeafZoneBounds());
algo.execute();
_algo = std::unique_ptr<FMMClass>(
new FMMClass(p_tree, &(_kernelLoader._kernel),
costzones.getZoneBounds(), costzones.getLeafZoneBounds()));
_algo->execute();
this->time.tac();
}
std::string getRunInfoString() const {
return _infostring.str();
}
};
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _ALGOLOADERSECTIONTASK_HPP_
#define _ALGOLOADERSECTIONTASK_HPP_
#include <memory>
#include "PerfTestUtils.hpp"
#include "Core/FFmmAlgorithmSectionTask.hpp"
template <class _TreeLoader, template<typename> class _KernelLoader>
class AlgoLoaderSectionTask : public FAlgoLoader<_TreeLoader, _KernelLoader> {
public:
using TreeLoader = _TreeLoader;
using KernelLoader = _KernelLoader<TreeLoader>;
using FReal = typename TreeLoader::FReal;
using CellClass = typename TreeLoader::CellClass;
using ContainerClass = typename TreeLoader::ContainerClass;
using LeafClass = typename TreeLoader::LeafClass;
using OctreeClass = typename TreeLoader::OctreeClass;
using KernelClass = typename KernelLoader::KernelClass;
using FMMClass = FFmmAlgorithmSectionTask<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>;
TreeLoader& _treeLoader;
KernelLoader& _kernelLoader;
std::unique_ptr<FMMClass> _algo;
AlgoLoaderSectionTask(FPerfTestParams& /*params*/,
TreeLoader& treeLoader,
KernelLoader& kernelLoader) :
_treeLoader(treeLoader),
_kernelLoader(kernelLoader),
_algo(nullptr) {
}
void run() {
_algo = std::unique_ptr<FMMClass>(
new FMMClass(&(_treeLoader._tree), &(_kernelLoader._kernel)));
_algo->execute();
}
};
#endif
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _ALGOLOADERTASK_HPP_
#define _ALGOLOADERTASK_HPP_
#include <memory>
#include "PerfTestUtils.hpp"
#include "Core/FFmmAlgorithmTask.hpp"
......@@ -25,18 +31,22 @@ public:
TreeLoader& _treeLoader;
KernelLoader& _kernelLoader;
std::unique_ptr<FMMClass> _algo;
AlgoLoaderTask(FPerfTestParams& /*params*/,
TreeLoader& treeLoader,
KernelLoader& kernelLoader) :
_treeLoader(treeLoader),
_kernelLoader(kernelLoader) {
_kernelLoader(kernelLoader),
_algo(nullptr) {
}
void run() {
FMMClass algo(&(_treeLoader._tree), &(_kernelLoader._kernel));
algo.execute();
_algo = std::unique_ptr<FMMClass>(
new FMMClass(&(_treeLoader._tree), &(_kernelLoader._kernel)));
_algo->execute();
}
};
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _ALGOLOADERTHREAD_HPP_
#define _ALGOLOADERTHREAD_HPP_
#include <memory>
#include "PerfTestUtils.hpp"
#include "Core/FFmmAlgorithmThread.hpp"
......@@ -26,20 +32,24 @@ public:
bool _omp_static_schedule;
std::unique_ptr<FMMClass> _algo;
AlgoLoaderThread(FPerfTestParams& params,
TreeLoader& treeLoader,
KernelLoader& kernelLoader) :
_treeLoader(treeLoader),
_kernelLoader(kernelLoader),
_omp_static_schedule(params.omp_static_schedule) {
_omp_static_schedule(params.omp_static_schedule),
_algo(nullptr) {
}
void run() {
FMMClass algo(&(_treeLoader._tree), &(_kernelLoader._kernel),
_omp_static_schedule);
algo.execute();
_algo = std::unique_ptr<FMMClass>(
new FMMClass(&(_treeLoader._tree), &(_kernelLoader._kernel),
_omp_static_schedule));
_algo->execute();
}
};
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _KERNELLOADERFCHEBSYM_HPP_
#define _KERNELLOADERFCHEBSYM_HPP_
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
/**
* \file
......@@ -25,6 +29,7 @@
#include "AlgoLoaderThread.hpp"
#include "AlgoLoaderTask.hpp"
#include "AlgoLoaderSectionTask.hpp"
#include "AlgoLoaderCostZones.hpp"
/**
......@@ -48,6 +53,23 @@ void runperf(FPerfTestParams& params)
KernelLoader<TreeLoader> kernelLoader(params, treeLoader);
AlgoLoader<TreeLoader, KernelLoader> algoLoader(params, treeLoader, kernelLoader);
algoLoader.run();
auto& algo = *(algoLoader._algo);
std::cout << "@@ "
<< "algo:" << params.algo << " "
<< "file:" << params.filename.substr(params.filename.find_last_of('/')+1) << " "
<< "particles:" << treeLoader._loader.getNumberOfParticles() << " "
<< "threads:" << params.nbThreads << " "
<< "height:" << params.treeHeight << " "
<< "subheight:" << params.subTreeHeight << " "
<< algoLoader.getRunInfoString()
<< "P2M:" << algo.getTime(FAlgorithmTimers::P2MTimer) << " "
<< "M2M:" << algo.getTime(FAlgorithmTimers::M2MTimer) << " "
<< "M2L:" << algo.getTime(FAlgorithmTimers::M2LTimer) << " "
<< "L2L:" << algo.getTime(FAlgorithmTimers::L2LTimer) << " "
<< "P2PL2P:" << algo.getTime(FAlgorithmTimers::NearTimer) << " "
<< std::endl;
}
int main (int argc, char** argv)
......@@ -82,6 +104,8 @@ int main (int argc, char** argv)
runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderTask>(params);
} else if ( "costzones" == params.algo ) {
runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderCostZones>(params);
} else if ( "sectiontask" == params.algo ) {
runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderSectionTask>(params);
} else {
std::cout << "Unknown algorithm: " << params.algo << std::endl;
}
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _PERFTESTUTILS_HPP_
#define _PERFTESTUTILS_HPP_
......@@ -167,6 +171,9 @@ public:
FTic time;
/// Method that runs the algorithm.
virtual void run() = 0;
virtual std::string getRunInfoString() const {
return "";
}
};
......
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE
#ifndef _TREELOADERFCHEB_HPP_
#define _TREELOADERFCHEB_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