Commit 0b18cdb9 authored by BRAMAS Berenger's avatar BRAMAS Berenger

move to clean assertion

parent 48c4e4da
......@@ -49,6 +49,7 @@ OPTION( ScalFMM_USE_DOUBLE_PRECISION "Set to ON to compile in double precision"
OPTION( ScalFMM_ATTACHE_SOURCE "Set to ON to compile with -g" OFF )
OPTION( ScalFMM_USE_ADDONS "Set to ON to compile add ons" OFF )
OPTION( ScalFMM_USE_SSE "Set to ON to compile with sse support" ON )
OPTION( ScalFMM_USE_ASSERT "Set to ON to enable safe tests during execution" ON )
# Set scalfmm to default libraries
SET(SCALFMM_LIBRARIES "")
......@@ -160,6 +161,12 @@ endif()
# Use Mem stats
MESSAGE( STATUS "ScalFMM_USE_MEM_STATS = ${ScalFMM_USE_MEM_STATS}" )
# Use Log
MESSAGE( STATUS "ScalFMM_USE_LOG = ${ScalFMM_USE_LOG}" )
# Use Assert
MESSAGE( STATUS "ScalFMM_USE_ASSERT = ${ScalFMM_USE_ASSERT}" )
# Add CBLAS
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CBLAS_LIBRARIES}")
......
......@@ -19,7 +19,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FPoint.hpp"
#include "../Containers/FVector.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FGlobalPeriodic.hpp"
......@@ -37,13 +37,13 @@
* tree.
*/
template <class OctreeClass, class ContainerClass, class ParticleClass, class ConverterClass >
class FOctreeArranger : FAssertable {
class FOctreeArranger {
OctreeClass* const tree; //< The tree to work on
public:
/** Basic constructor */
FOctreeArranger(OctreeClass* const inTree) : tree(inTree) {
fassert(tree, "Tree cannot be null", __LINE__ , __FILE__ );
FAssertLF(tree, "Tree cannot be null" );
}
/** Arrange */
......
......@@ -18,7 +18,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Containers/FVector.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FMpi.hpp"
#include "../Utils/FGlobalPeriodic.hpp"
......@@ -36,7 +36,7 @@
* tree.
*/
template <class OctreeClass, class ContainerClass, class ParticleClass, class ConverterClass >
class FOctreeArrangerProc : FAssertable {
class FOctreeArrangerProc {
/** Interval is the min/max morton index
* for a proc
*/
......@@ -64,7 +64,7 @@ class FOctreeArrangerProc : FAssertable {
public:
/** Basic constructor */
FOctreeArrangerProc(OctreeClass* const inTree) : tree(inTree) {
fassert(tree, "Tree cannot be null", __LINE__ , __FILE__ );
FAssertLF(tree, "Tree cannot be null");
}
/** return false if the tree is empty after processing */
......
......@@ -17,7 +17,7 @@
#define FTYPEDLEAF_HPP
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "FAbstractLeaf.hpp"
#include "FParticleType.hpp"
......@@ -33,7 +33,7 @@
* Particles should be typed to enable targets/sources difference.
*/
template< class ContainerClass>
class FTypedLeaf : public FAbstractLeaf<ContainerClass>, public FAssertable {
class FTypedLeaf : public FAbstractLeaf<ContainerClass> {
ContainerClass sources; //< The sources containers
ContainerClass targets; //< The targets containers
......
......@@ -28,7 +28,7 @@
#include "../Utils/FPoint.hpp"
#include "../Utils/FMath.hpp"
#include "../Utils/FNoCopyable.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
/**
......@@ -53,7 +53,7 @@
* CellAllocator can be FListBlockAllocator<CellClass, 10> or FBasicBlockAllocator<CellClass>
*/
template< class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass = FListBlockAllocator<CellClass, 15> >
class FOctree : protected FAssertable, public FNoCopyable {
class FOctree : public FNoCopyable {
typedef FSubOctreeWithLeafs< CellClass , ContainerClass, LeafClass, CellAllocatorClass> SubOctreeWithLeaves;
typedef FSubOctree< CellClass , ContainerClass, LeafClass, CellAllocatorClass> SubOctree;
......@@ -93,15 +93,9 @@ class FOctree : protected FAssertable, public FNoCopyable {
* @return the box num at the leaf level that contains inRelativePosition
*/
int getTreeCoordinate(const FReal inRelativePosition) const {
if(!(inRelativePosition >= 0 && inRelativePosition < this->boxWidth))
printf("inRelativePosition : %f\n",inRelativePosition);
FLOG( fassert(inRelativePosition >= 0 && inRelativePosition < this->boxWidth, "Particle out of box", __LINE__, __FILE__) );
FAssertLF( (inRelativePosition >= 0 && inRelativePosition < this->boxWidth), "inRelativePosition : ",inRelativePosition );
FAssertLF( inRelativePosition >= 0 && inRelativePosition < this->boxWidth, "Particle out of box" );
const FReal indexFReal = inRelativePosition / this->boxWidthAtLevel[this->leafIndex];
/*const int index = int(FMath::dfloor(indexFReal));
if( index && FMath::LookEqual(inRelativePosition, this->boxWidthAtLevel[this->leafIndex] * FReal(index) ) ){
return index - 1;
}
return index;*/
return static_cast<int>(indexFReal);
}
......@@ -119,7 +113,7 @@ public:
height(inHeight) , subHeight(inSubHeight), leafIndex(this->height-1),
boxCenter(inBoxCenter), boxCorner(inBoxCenter,-(inBoxWidth/2)), boxWidth(inBoxWidth)
{
fassert(subHeight <= height - 1, "Subheight cannot be greater than height", __LINE__, __FILE__ );
FAssertLF(subHeight <= height - 1, "Subheight cannot be greater than height", __LINE__, __FILE__ );
// Does we only need one suboctree?
if(subHeight == height - 1){
root = new FSubOctreeWithLeafs< CellClass , ContainerClass, LeafClass,CellAllocatorClass>(0, 0, this->subHeight, 1);
......@@ -273,7 +267,7 @@ public:
* It uses the left right limit on each suboctree and their morton index.
* Please have a look to the move functions to understand how the system is working.
*/
class Iterator : protected FAssertable {
class Iterator {
SubOctreeTypes current; //< Current suboctree
int currentLocalIndex; //< Current index (array position) in the current_suboctree.cells[ currentLocalLevel ]
......@@ -297,8 +291,8 @@ public:
*/
explicit Iterator(FOctree* const inTarget)
: currentLocalIndex(0) , currentLocalLevel(0) {
fassert(inTarget, "Target for Octree::Iterator cannot be null", __LINE__, __FILE__);
fassert(inTarget->root->getRightLeafIndex() >= 0, "Octree seems to be empty, getRightLeafIndex == 0", __LINE__, __FILE__);
FAssertLF(inTarget, "Target for Octree::Iterator cannot be null", __LINE__, __FILE__);
FAssertLF(inTarget->root->getRightLeafIndex() >= 0, "Octree seems to be empty, getRightLeafIndex == 0", __LINE__, __FILE__);
// Start by the root
this->current.tree = inTarget->root;
......
......@@ -19,7 +19,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FPoint.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FMath.hpp"
#include "FTreeCoordinate.hpp"
......@@ -48,7 +48,7 @@
* @warning Give the particleClass & cellClass
*/
template< class CellClass , class ContainerClass, class LeafClass, class CellAllocatorClass>
class FAbstractSubOctree : protected FAssertable{
class FAbstractSubOctree {
protected:
CellClass*** cells; //< Potential cells, cells are allocated only if needed
......@@ -187,7 +187,7 @@ public:
subOctreeHeight( inSubOctreeHeight ), subOctreePosition( inSubOctreePosition ), isLeafSubtree(inIsLeafSubtree) {
this->cells = new CellClass**[this->subOctreeHeight];
fassert(this->cells, "Allocation failled", __LINE__, __FILE__);
FAssertLF(this->cells, "Allocation failled");
memset(this->cells, 0, sizeof(CellClass**) * subOctreeHeight);
......@@ -195,7 +195,7 @@ public:
int cellsAtlevel = 8;
for( int indexLevel = 0 ; indexLevel < this->subOctreeHeight ; ++indexLevel ){
this->cells[indexLevel] = new CellClass*[cellsAtlevel];
fassert(this->cells[indexLevel], "Allocation failled", __LINE__, __FILE__);
FAssertLF(this->cells[indexLevel], "Allocation failled");
memset(this->cells[indexLevel], 0, sizeof(CellClass*) * cellsAtlevel);
......@@ -278,7 +278,7 @@ public:
* @param level the level to access cells array (must be < subOctreeHeight)
* @return cells[level] */
CellClass** cellsAt(const int level) const{
fassert(level < subOctreeHeight, "Level out of memory", __LINE__, __FILE__);
FAssertLF(level < subOctreeHeight, "Level out of memory");
return cells[level];
}
......@@ -360,7 +360,7 @@ public:
const int cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->leafs = new LeafClass*[cellsAtLeafLevel];
Parent::fassert(this->leafs, "Allocation failled", __LINE__, __FILE__);
FAssertLF(this->leafs, "Allocation failled");
memset(leafs, 0, sizeof(LeafClass*) * cellsAtLeafLevel);
}
......@@ -507,7 +507,7 @@ public:
const int cellsAtLeafLevel = 1 << (3 * inSubOctreeHeight);
this->subleafs = new Parent*[cellsAtLeafLevel];
Parent::fassert(this->subleafs, "Allocation failled", __LINE__, __FILE__);
FAssertLF(this->subleafs, "Allocation failled");
memset(subleafs, 0, sizeof(Parent**) * cellsAtLeafLevel);
}
......
......@@ -18,7 +18,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -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 FFmmAlgorithm : protected FAssertable, public FAbstractAlgorithm {
class FFmmAlgorithm : public FAbstractAlgorithm {
OctreeClass* const tree; //< The octree to work on
KernelClass* const kernels; //< The kernels
......@@ -56,8 +56,8 @@ public:
FFmmAlgorithm(OctreeClass* const inTree, KernelClass* const inKernels)
: tree(inTree) , kernels(inKernels), OctreeHeight(tree->getHeight()) {
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
fassert(kernels, "kernels cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
FAssertLF(kernels, "kernels cannot be null");
FLOG(FLog::Controller << "FFmmAlgorithm\n");
}
......
......@@ -19,7 +19,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FGlobalPeriodic.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -42,7 +42,7 @@
* Of course this class does not deallocate pointer given in arguments.
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmPeriodic : protected FAssertable, public FAbstractAlgorithm{
class FFmmAlgorithmPeriodic : public FAbstractAlgorithm{
OctreeClass* const tree; //< The octree to work on
KernelClass* kernels; //< The kernels
......@@ -66,8 +66,8 @@ public:
nbLevelsAboveRoot(inUpperLevel), offsetRealTree(inUpperLevel + 3),
periodicDirections(inPeriodicDirections) {
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
fassert(-1 <= inUpperLevel, "inUpperLevel cannot be < -1", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
FAssertLF(-1 <= inUpperLevel, "inUpperLevel cannot be < -1");
FLOG(FLog::Controller << "FFmmAlgorithmPeriodic\n");
}
......@@ -85,7 +85,7 @@ public:
* Call this function to run the complete algorithm
*/
void execute(const unsigned operationsToProceed = FFmmNearAndFarFields){
fassert(kernels, "kernels cannot be null", __LINE__, __FILE__);
FAssertLF(kernels, "kernels cannot be null");
FTRACE( FTrace::FFunction functionTrace(__FUNCTION__, "Fmm" , __FILE__ , __LINE__) );
if(operationsToProceed & FFmmP2M) bottomPass();
......
......@@ -18,7 +18,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -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 : protected FAssertable, public FAbstractAlgorithm{
class FFmmAlgorithmSectionTask : public FAbstractAlgorithm{
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -60,8 +60,8 @@ public:
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight())
{
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
fassert(inKernels, "kernels cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
FAssertLF(inKernels, "kernels cannot be null");
this->kernels = new KernelClass*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
......
......@@ -18,7 +18,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -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 FFmmAlgorithmTask : protected FAssertable, public FAbstractAlgorithm{
class FFmmAlgorithmTask : public FAbstractAlgorithm{
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -60,8 +60,8 @@ public:
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight())
{
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
fassert(inKernels, "kernels cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
FAssertLF(inKernels, "kernels cannot be null");
this->kernels = new KernelClass*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
......
......@@ -17,7 +17,7 @@
#define FFMMALGORITHMTHREAD_HPP
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -45,7 +45,7 @@
* When using this algorithm the P2P is thread safe.
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThread : protected FAssertable, public FAbstractAlgorithm{
class FFmmAlgorithmThread : public FAbstractAlgorithm{
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -69,7 +69,7 @@ public:
: tree(inTree) , kernels(0), iterArray(0), leafsNumber(0),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()) {
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
this->kernels = new KernelClass*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
......@@ -109,7 +109,7 @@ public:
} while(octreeIterator.moveRight());
iterArray = new typename OctreeClass::Iterator[leafsNumber];
fassert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
FAssertLF(iterArray, "iterArray bad alloc");
if(operationsToProceed & FFmmP2M) bottomPass();
......
......@@ -19,7 +19,7 @@
#include <omp.h>
//
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -60,7 +60,7 @@
* ./Tests/testFmmAlgorithmProc ../Data/testLoaderSmall.fma.tmp
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThreadProc : protected FAssertable , public FAbstractAlgorithm {
class FFmmAlgorithmThreadProc : public FAbstractAlgorithm {
static const int MaxSizePerCell = 1024;
......@@ -119,7 +119,7 @@ public:
OctreeHeight(tree->getHeight()),intervals(new Interval[inComm.processCount()]),
workingIntervalsPerLevel(new Interval[inComm.processCount() * tree->getHeight()]){
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
this->kernels = new KernelClass*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
......@@ -163,7 +163,7 @@ public:
myLastInterval.max = octreeIterator.getCurrentGlobalIndex();
}
iterArray = new typename OctreeClass::Iterator[numberOfLeafs];
fassert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
FAssertLF(iterArray, "iterArray bad alloc");
// We get the min/max indexes from each procs
FMpi::MpiAssert( MPI_Allgather( &myLastInterval, sizeof(Interval), MPI_BYTE, intervals, sizeof(Interval), MPI_BYTE, comm.getComm()), __LINE__ );
......@@ -414,7 +414,7 @@ private:
++position;
}
fassert(!currentChild[position], "Already has a cell here", __LINE__, __FILE__);
FAssertLF(!currentChild[position], "Already has a cell here");
recvBufferCells[position].deserializeUp(recvBuffer);
currentChild[position] = (CellClass*) &recvBufferCells[position];
......
......@@ -17,7 +17,7 @@
#define FFMMALGORITHMTHREADPROCPPERIODIC_HPP
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -58,7 +58,7 @@
* ./Tests/testFmmAlgorithmProc ../Data/testLoaderSmall.fma.tmp
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThreadProcPeriodic : protected FAssertable, public FAbstractAlgorithm {
class FFmmAlgorithmThreadProcPeriodic : public FAbstractAlgorithm {
static const int MaxSizePerCell = 2048;
......@@ -132,8 +132,8 @@ public:
OctreeHeight(tree->getHeight()),intervals(new Interval[inComm.processCount()]),
workingIntervalsPerLevel(new Interval[inComm.processCount() * tree->getHeight()]) {
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
fassert(-1 <= inUpperLevel, "inUpperLevel cannot be < -1", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
FAssertLF(-1 <= inUpperLevel, "inUpperLevel cannot be < -1");
FLOG(FLog::Controller << "FFmmAlgorithmThreadProcPeriodic\n");
FLOG(FLog::Controller << "Max threads = " << MaxThreads << ", Procs = " << nbProcess << ", I am " << idProcess << ".\n");
......@@ -173,7 +173,7 @@ public:
myLastInterval.max = octreeIterator.getCurrentGlobalIndex();
}
iterArray = new typename OctreeClass::Iterator[numberOfLeafs];
fassert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
FAssertLF(iterArray, "iterArray bad alloc");
// We get the min/max indexes from each procs
FMpi::MpiAssert( MPI_Allgather( &myLastInterval, sizeof(Interval), MPI_BYTE, intervals, sizeof(Interval), MPI_BYTE, comm.getComm()), __LINE__ );
......@@ -418,7 +418,7 @@ private:
++position;
}
fassert(!currentChild[position], "Already has a cell here", __LINE__, __FILE__);
FAssertLF(!currentChild[position], "Already has a cell here");
recvBufferCells[position].deserializeUp(recvBuffer);
currentChild[position] = (CellClass*) &recvBufferCells[position];
......@@ -481,7 +481,7 @@ private:
state >>= 1;
++position;
}
fassert(!currentChild[position], "Already has a cell here", __LINE__, __FILE__);
FAssertLF(!currentChild[position], "Already has a cell here");
recvBufferCells[position].deserializeUp(recvBuffer);
......
......@@ -17,7 +17,7 @@
#define FFMMALGORITHMTHREADTSM_HPP
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -45,7 +45,7 @@
* You should not write on sources in the P2P method!
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmThreadTsm : protected FAssertable, public FAbstractAlgorithm{
class FFmmAlgorithmThreadTsm : public FAbstractAlgorithm{
OctreeClass* const tree; //< The octree to work on
KernelClass** kernels; //< The kernels
......@@ -65,7 +65,7 @@ public:
: tree(inTree) , kernels(0), iterArray(0),
MaxThreads(omp_get_max_threads()) , OctreeHeight(tree->getHeight()) {
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
this->kernels = new KernelClass*[MaxThreads];
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
......@@ -98,7 +98,7 @@ public:
++numberOfLeafs;
} while(octreeIterator.moveRight());
iterArray = new typename OctreeClass::Iterator[numberOfLeafs];
fassert(iterArray, "iterArray bad alloc", __LINE__, __FILE__);
FAssertLF(iterArray, "iterArray bad alloc");
if(operationsToProceed & FFmmP2M) bottomPass();
......
......@@ -17,7 +17,7 @@
#define FFMMALGORITHMTSM_HPP
#include "../Utils/FAssertable.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FTrace.hpp"
#include "../Utils/FTic.hpp"
......@@ -39,7 +39,7 @@
* The differences with FmmAlgorithm is that it used target source model.
*/
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
class FFmmAlgorithmTsm : protected FAssertable, public FAbstractAlgorithm{
class FFmmAlgorithmTsm : public FAbstractAlgorithm{
OctreeClass* const tree; //< The octree to work on
KernelClass* const kernels; //< The kernels
......@@ -58,8 +58,8 @@ public:
FFmmAlgorithmTsm(OctreeClass* const inTree, KernelClass* const inKernels)
: tree(inTree) , kernels(inKernels) , OctreeHeight(tree->getHeight()){
fassert(tree, "tree cannot be null", __LINE__, __FILE__);
fassert(kernels, "kernels cannot be null", __LINE__, __FILE__);
FAssertLF(tree, "tree cannot be null");
FAssertLF(kernels, "kernels cannot be null");
FLOG(FLog::Controller << "FFmmAlgorithmTsm\n");
}
......
......@@ -68,4 +68,10 @@
#cmakedefine ScalFMM_USE_SSE
///////////////////////////////////////////////////////
// Assert tests
///////////////////////////////////////////////////////
#cmakedefine ScalFMM_USE_ASSERT
#endif // CONFIG_H
......@@ -13,57 +13,92 @@
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef FASSERTABLE_HPP
#define FASSERTABLE_HPP
#ifndef FASSERT_HPP
#define FASSERT_HPP
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <cassert>
#include "FGlobal.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FAssertable
* Please read the license
*
* This class is an interface for managing error.
*
* Please refere to testAssert.cpp to see an example
* <code>
* </code>
*/
class FAssertable {
* @brief The SpError class
* It is recommendede to use the macro:
* FAssertLF( aTest , "some data ", "to ", plot);
*/
class SpError {
protected:
/** Empty Destructor */
virtual ~FAssertable(){}
/**
* to write debug data with line & file
* @param inTest if false, application will stop
* @param inMessage a message - from any type - to print
* @param inLinePosition line number
* @param inFilePosition file name
* @param inExitCode an exit code
*
* @code
* fassert(toto == titi, "problem : toto is not equal titi!", __LINE__, __FILE__);
* @endcode
* To prevent use from multiple thread we use a ostringstream before printing
*/
template <class Tmess, class Tline, class Tfile>
void fassert(const bool inTest, const Tmess& inMessage, const Tline& inLinePosition, const Tfile& inFilePosition, const int inExitCode = 1) const {
if(!inTest){
std::ostringstream oss;
oss << "Error in " << inFilePosition << " at line " << inLinePosition <<" :\n";
oss << inMessage << "\n";
std::cerr << oss.str();
exit(inExitCode);
}
}
/**
* @brief ErrPrint private method to end print
*/
static void ErrPrint(){
std::cerr << '\n';
}
/**
* @brief ErrPrint private methdo to print
*/
template<typename T, typename... Args>
static void ErrPrint(const T& toPrint, Args... args){
std::cerr << toPrint;
ErrPrint( args... );
}
public:
//////////////////////////////////////////////////////////////
// Should not be called directly
//////////////////////////////////////////////////////////////
/** Nothing to print */
static void Print(){
}
/** One or more things to print */
template<typename T, typename... Args>
static void Print(const T& toPrint, Args... args){
std::cerr << "[ERROR] ";
ErrPrint( toPrint, args... );
}
};
#endif //FASSERTABLE_HPP
#ifdef SCALFMM_USE_ASSERT
//////////////////////////////////////////////////////////////
// Sp error activated
//////////////////////////////////////////////////////////////
#define SpErrorAssertExit(TEST, args...) \
if( !(TEST) ){ \
SpError::Print( args ); \
throw std::exception(); \
}
#else
//////////////////////////////////////////////////////////////
// Sp error desactivated
//////////////////////////////////////////////////////////////
#define SpErrorAssertExit(TEST, args...) \
if( !(TEST) ){}
#endif
//////////////////////////////////////////////////////////////
// Shortcut macro
//////////////////////////////////////////////////////////////
#define SPARSETD_ERROR_LINE " At line " , __LINE__ , "."
#define SPARSETD_ERROR_FILE " In file " , __FILE__ , "."
#define FAssert SpErrorAssertExit
#define FAssertLF(args...) FAssert(args, SPARSETD_ERROR_LINE, SPARSETD_ERROR_FILE)
#endif //FASSERT_HPP
......@@ -30,7 +30,7 @@
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Utils/FAssertable.hpp"
#include "../../Src/Utils/FAssert.hpp"
#include "../../Src/Utils/FPoint.hpp"
......
......@@ -29,7 +29,7 @@
#include "../../Src/Containers/FOctree.hpp"
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Utils/FAssertable.hpp"
#include "../../Src/Utils/FAssert.hpp"
#include "../../Src/Utils/FPoint.hpp"
#include "../../Src/Kernels/Chebyshev/FChebCell.hpp"
......
......@@ -30,7 +30,7 @@
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Utils/FAssertable.hpp"
#include "../../Src/Utils/FAssert.hpp"
#include "../../Src/Utils/FPoint.hpp"
......
......@@ -31,7 +31,7 @@
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Utils/FAssertable.hpp"
#include "../../Src/Utils/FAssert.hpp"
#include "../../Src/Utils/FPoint.hpp"
#include "../../Src/Kernels/Chebyshev/FChebTensor.hpp"
......