Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4153e622 authored by Quentin Khan's avatar Quentin Khan
Browse files

Various fixes for CostZones FChebBalanceSymKernel and FFmmAlgorithmThreadBalanced

parent dd7d91e7
No related branches found
No related tags found
No related merge requests found
#ifndef _COSTZONES_HPP_
#define _COSTZONES_HPP_
#include "FChebBalanceSymKernel.hpp"
/**
* \brief The costzones algorithm implementation.
* \author Quentin Khan <quentin.khan@inria.fr>
......
......@@ -30,20 +30,38 @@
class FTreeCoordinate;
/**
* \author Quentin Khan
* \brief Cell with a cost memory for balance computations.
*
* This class extends FBasicCell to add simple computation cost memory.
*/
class FCostCell : public FBasicCell {
/// The cost of the cell. It is declared mutable because the existing
/// algorithms use const cells.
mutable long int _cost = 0;
public:
/// Debug member, used to check whether the cell was already visited.
bool _visited = false;
/**
* \brief Gets the cost of the cell.
* \return The cost of the cell
*/
long int getCost() const {
return _cost;
}
/**
* Sets the cost of the cell.
* \return The cost of the cell
*/
long int setCost(int newCost) {
_cost = newCost;
return _cost;
}
/**
* Add a cost to the cell.
* \warning Can be used on const cells !
*/
long int addCost(int addCost) const {
_cost += addCost;
return _cost;
......@@ -51,7 +69,7 @@ public:
};
/**
* \author Quentin Khan, Matthias Messner (original file)
* \author Quentin Khan, Matthias Messner (original file: FChebFlopsSymKernel)
* \brief Cost computation of Chebyshev interpolation based FMM.
*
* Please read the license
......@@ -80,10 +98,11 @@ public:
const FSmartPointer<MatrixKernelClass,FSmartPointerMemory> MatrixKernel;
const FSmartPointer<SymmetryHandler, FSmartPointerMemory> SymHandler;
///
/// The tree the kernel is working on. Needed to attain cells in the P2P
/// operator (we only get the particles containers otherwise)
OctreeClass* _tree;
/// tree height
/// The tree height
const unsigned int _treeHeight;
/// count permuted local and multipole expansions
......@@ -358,13 +377,6 @@ public:
/**
* Handler to deal with all symmetries: Stores permutation indices and vectors
* to reduce 343 different interactions to 16 only.
......
......@@ -47,8 +47,8 @@
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThreadBalanced : public FAbstractAlgorithm, public FAlgorithmTimers{
OctreeClass* const tree; ///< The octree to work on.
KernelClass** kernels; ///< The kernels.
OctreeClass* const tree; ///< The octree to work on.
KernelClass** kernels; ///< The kernels.
typename OctreeClass::Iterator* iterArray;
int leafsNumber;
......@@ -56,10 +56,12 @@ class FFmmAlgorithmThreadBalanced : public FAbstractAlgorithm, public FAlgorithm
static const int SizeShape = 3*3*3;
int shapeLeaf[SizeShape];
const int MaxThreads; ///< The maximum number of threads.
const int OctreeHeight; ///< The height of the given tree.
const int MaxThreads; ///< The maximum number of threads.
const int OctreeHeight; ///< The height of the given tree.
/// The vector containing the costzones
const std::vector<std::vector<int,int>> costzones;
public:
/** Class constructor
*
......@@ -69,21 +71,22 @@ public:
*
* \except An exception is thrown if one of the arguments is NULL.
*/
FFmmAlgorithmThreadBalanced(OctreeClass* const inTree, KernelClass* const inKernels)
: tree(inTree) ,
kernels(nullptr),
iterArray(nullptr),
leafsNumber(0),
MaxThreads(omp_get_max_threads()),
OctreeHeight(tree->getHeight()) {
FFmmAlgorithmThreadBalanced(OctreeClass* const inTree, KernelClass* const inKernels,
const std::vector<std::vector<int,int>>) :
tree(inTree) ,
kernels(nullptr),
iterArray(nullptr),
leafsNumber(0),
MaxThreads(omp_get_max_threads()),
OctreeHeight(tree->getHeight()) {
FAssertLF(tree, "tree cannot be null");
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread) {
#pragma omp critical (InitFFmmAlgorithmThreadBalanced)
#pragma omp critical (InitFFmmAlgorithmThreadBalanced)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment