Commit aee66b84 authored by BRAMAS Berenger's avatar BRAMAS Berenger
parents d5aa2784 9f03db26
......@@ -54,6 +54,7 @@ OPTION( ScalFMM_ATTACHE_SOURCE "Set to ON to compile with -g"
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 )
OPTION( ScalFMM_USE_MIC_NATIVE "Set to ON to compile in native mode for MIC" OFF )
# Set scalfmm to default libraries
SET(SCALFMM_LIBRARIES "")
#
......@@ -70,7 +71,14 @@ if(OPENMP_FOUND)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(OPENMP_FOUND)
MESSAGE(STATUS "ScalFMM_BUILD_DEBUG = ${ScalFMM_BUILD_DEBUG}" )
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(FLAGS_64bits "-m64")
else()
SET(FLAGS_64bits "")
endif()
#
# Debug
#
if( ScalFMM_BUILD_DEBUG )
#
# Compile Debug flags
......@@ -80,12 +88,7 @@ if( ScalFMM_BUILD_DEBUG )
IF( APPLE )
SET(SCALFMM_FLAGS_OPTI_DEBUG "-m64 -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
ELSE(APPLE)
# Test if not apple and 64bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(SCALFMM_FLAGS_OPTI_DEBUG "-m64 -march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
else()
SET(SCALFMM_FLAGS_OPTI_DEBUG "-march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
endif()
SET(SCALFMM_FLAGS_OPTI_DEBUG "${FLAGS_64bits} -fp-model strict -march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
ENDIF(APPLE)
# ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_DEBUG})
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_DEBUG}")
......@@ -106,14 +109,14 @@ else()
IF( APPLE )
SET(SCALFMM_FLAGS_OPTI_RELEASE "-m64 -funroll-loops" CACHE STRING "Set your optimization flags for release mode.")
ELSE(APPLE)
# Test if not apple and 64bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(SCALFMM_FLAGS_OPTI_RELEASE "-m64 -ffast-math -flto -march=native -funroll-loops -ftree-vectorize" CACHE STRING "Set your optimization flags for release mode.")
# Not apple system - Check the compilater flags
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
SET(SCALFMM_FLAGS_OPTI_RELEASE "${FLAGS_64bits} -fp-model precise -fp-model source -fimf-precision=low -march=native -funroll-loops -ftree-vectorize" CACHE STRING "Set your optimization flags for release mode.")
else()
SET(SCALFMM_FLAGS_OPTI_RELEASE "-ffast-math -flto -march=native -funroll-loops -ftree-vectorize" CACHE STRING "Set your optimization flags for release mode.")
SET(SCALFMM_FLAGS_OPTI_RELEASE "${FLAGS_64bits} -ffast-math -flto -march=native -funroll-loops -ftree-vectorize" CACHE STRING "Set your optimization flags for release mode.")
endif()
ENDIF(APPLE)
# ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_RELEASE})
#
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_RELEASE}")
endif()
#
......@@ -187,12 +190,15 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
MESSAGE( STATUS "ScalFMM_USE_SSE = ${ScalFMM_USE_SSE}" )
if( ScalFMM_USE_SSE )
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -axAVX")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -vec -axAVX")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3 -mfpmath=sse")
ENDIF()
endif()
if( ScalFMM_USE_MIC_NATIVE )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmic")
ENDIF()
# Use Mem stats
MESSAGE( STATUS "ScalFMM_USE_MEM_STATS = ${ScalFMM_USE_MEM_STATS}" )
......
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// 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 FABSTRACTBALANCEALGORITHM_H
#define FABSTRACTBALANCEALGORITHM_H
/**
* @author Cyrille Piacibello
* @class FAbstractBalanceAlgorithm
*
* @brief This class provide the methods that are used to balance a
* tree FMpiTreeBuilder::EqualizeAndFillTree
*/
class FAbstractBalanceAlgorithm{
public:
virtual ~FAbstractBalanceAlgorithm(){
}
/**
* @brief Give the right leaves (ie the min) of the interval that
* will be handle by idxOfProc
* @param numberOfLeaves Total number of leaves that exist.
* @param numberOfPartPerLeaf Array of lenght numberOfLeaves containing the number of particles in each leaf
* @param numberOfPart Number of particles in the whole field
* @param idxOfLeaves Array of lenght numberOfLeaves containing the Morton Index of each Leaf
* @param numberOfProc Number of MPI processus that will handle the Octree
* @param idxOfProc Idx of the proc calling.
*/
virtual FSize getRight(const FSize numberOfLeaves, const int*numberOfPartPerLeaf, const FSize numberOfPart, const MortonIndex* idxOfLeaves,
const int numberOfProc, const int idxOfProc) = 0;
/**
* @brief Give the Leaft leaves (ie the max) of the interval that
* will be handle by idxOfProc
* @param numberOfLeaves Total number of leaves that exist.
* @param numberOfPartPerLeaf Array of lenght numberOfLeaves containing the number of particles in each leaf
* @param numberOfPart Number of particles in the whole field
* @param idxOfLeaves Array of lenght numberOfLeaves containing the Morton Index of each Leaf
* @param numberOfProc Number of MPI processus that will handle the Octree
* @param idxOfProc Idx of the proc calling.
*/
virtual FSize getLeft(const FSize numberOfLeaves, const int*numberOfPartPerLeaf, const FSize numberOfPart, const MortonIndex* idxOfLeaves,
const int numberOfProc, const int idxOfProc) = 0;
};
#endif //FABSTRACTBALANCEALGORITHM_H
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// 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 FLEAFBALANCE_H
#define FLEAFBALANCE_H
#include "./FAbstractBalanceAlgorithm.hpp"
#include "../Utils/FMath.hpp"
/**
* @author Cyrille Piacibello
* @class FLeafBalance
*
* @brief This class inherits from FAbstractBalanceAlgorithm. It
* provides balancing methods based on leaf numbers only.
*/
class FLeafBalance : public FAbstractBalanceAlgorithm{
public:
/**
* Does not need the number of particles. Just divide the leaves
* over processus
*/
FSize getRight(const FSize numberOfLeaves, const int*numberOfPartPerLeaf, const FSize numberOfPart, const MortonIndex* idxOfLeaves,
const int numberOfProc, const int idxOfProc){
const double step = (double(numberOfLeaves) / double(numberOfProc));
const FSize res = FSize(FMath::Ceil(step * double(idxOfProc+1)));
if(res > numberOfLeaves) return numberOfLeaves;
else return res;
}
/**
* Does not need the number of particles. Just divide the leaves
* over processus
*/
FSize getLeft(const FSize numberOfLeaves, const int*numberOfPartPerLeaf, const FSize numberOfPart, const MortonIndex* idxOfLeaves,
const int numberOfProc, const int idxOfProc){
const double step = (double(numberOfLeaves) / double(numberOfProc));
return FSize(FMath::Ceil(step * double(idxOfProc)));
}
};
#endif // FLEAFBALANCE_H
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// 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 FPARTICLESBALANCE_H
#define FPARTICLESBALANCE_H
#include "./FAbstractBalanceAlgorithm.hpp"
#include "../Utils/FMath.hpp"
/**
* @author Cyrille Piacibello
* @class FLeafBalance
*
* @brief This class inherits from FAbstractBalanceAlgorithm. It
* provides balancing methods based on particles distribution.
*/
class FParticlesBalance : public FAbstractBalanceAlgorithm{
public:
/**
* getRight interval based on particles distribution
*/
FSize getRight(const FSize numberOfLeaves, const int*numberOfPartPerLeaf, const FSize numberOfPart, const MortonIndex* idxOfLeaves,
const int numberOfProc, const int idxOfProc){
int acc = 0;
FSize i = 0;
const double step = (double(numberOfPart) / double(numberOfProc));
FSize aimRight = FSize(FMath::Ceil(step * double(idxOfProc+1)));
if(aimRight > numberOfPart) aimRight = numberOfPart;
while(acc < aimRight){
acc+=numberOfPartPerLeaf[i];
++i;
}
if(FMath::Abs(aimRight-acc) < FMath::Abs(aimRight-(acc-numberOfPartPerLeaf[i]))) return i;
else
return i-1;
}
/**
* get left interval based on particles distribution
*/
FSize getLeft(const FSize numberOfLeaves, const int*numberOfPartPerLeaf, const FSize numberOfPart, const MortonIndex* idxOfLeaves,
const int numberOfProc, const int idxOfProc){
int acc = 0;
FSize i = 0;
const double step = (double(numberOfPart) / double(numberOfProc));
const FSize aimLeft = FSize(FMath::Ceil(step * double(idxOfProc)));
while (acc < aimLeft){
acc+=numberOfPartPerLeaf[i];
++i;
}
if(FMath::Abs(aimLeft-acc) < FMath::Abs(aimLeft-(acc-numberOfPartPerLeaf[i]))) return i;
else
return i-1;
}
};
#endif // FPARTICLESBALANCE_H
This diff is collapsed.
......@@ -255,7 +255,7 @@ struct FMath{
/** Print */
template <class StreamClass>
friend StreamClass& operator<<(StreamClass& output, const FAccurater& inAccurater){
output << "[Error] L2Norm = " << inAccurater.getL2Norm() << " \t Inf = " << inAccurater.getInfNorm();
output << "[Error] Relative L2Norm = " << inAccurater.getRelativeL2Norm() << " \t RMS Norm = " << inAccurater.getRMSError() << " \t Relative Inf = " << inAccurater.getRelativeInfNorm();
return output;
}
......
......@@ -47,6 +47,7 @@
#include "../../Src/Core/FFmmAlgorithmThread.hpp"
#include "../../Src/Core/FFmmAlgorithmThreadProc.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
/**
* This program runs the FMM Algorithm Distributed with the Chebyshev kernel
*/
......@@ -110,10 +111,11 @@ int main(int argc, char* argv[])
loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue);
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FMpiTreeBuilder< TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(),
tree.getBoxCenter(),
tree.getBoxWidth(),
tree.getHeight(), &finalParticles);
tree.getHeight(), &finalParticles,&balancer);
{ // -----------------------------------------------------
std::cout << "Creating & Inserting " << loader.getNumberOfParticles()
......
......@@ -372,7 +372,7 @@ int main(int argc, char* argv[])
#endif
{
const static int P = 7;
const static int P = 8;
typedef FRotationCell<P> CellClass;
typedef FP2PParticleContainerIndexed<> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
......
......@@ -42,6 +42,8 @@
#include "../../Src/Files/FMpiTreeBuilder.hpp"
#include "../../Src/Files/FFmaBinLoader.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
#include <iostream>
#include <cstdio>
......@@ -281,10 +283,11 @@ int main(int argc, char ** argv){
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FMpiTreeBuilder< TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(),
tree.getBoxCenter(),
tree.getBoxWidth(),
tree.getHeight(), &finalParticles);
tree.getHeight(), &finalParticles,&balancer);
for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){
tree.insert(finalParticles[idx].position,finalParticles[idx].physicalValue);
......
......@@ -17,6 +17,7 @@
// ==== CMAKE =====
// @FUSE_BLAS
// @FUSE_MPI
// @FUSE_FFT
// ================
#include <iostream>
......@@ -47,6 +48,7 @@
#include "../../Src/Core/FFmmAlgorithmThread.hpp"
#include "../../Src/Core/FFmmAlgorithmThreadProc.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
/**
* This program runs the FMM Algorithm Distributed with the Uniform kernel
*/
......@@ -110,10 +112,11 @@ int main(int argc, char* argv[])
loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue);
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FMpiTreeBuilder< TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(),
tree.getBoxCenter(),
tree.getBoxWidth(),
tree.getHeight(), &finalParticles);
tree.getHeight(), &finalParticles, &balancer);
{ // -----------------------------------------------------
std::cout << "Creating & Inserting " << loader.getNumberOfParticles()
......
......@@ -26,7 +26,11 @@
* Each data is a FReal : posX,posY,posZ,physicalValue,forceX,forceY,forceZ,potential
*/
// ==== CMAKE =====
// // @FUSE_BLAS
// // ================
//
//
#include <iostream>
#include <cstdio>
......
......@@ -44,6 +44,8 @@
#include "../../Src/Components/FBasicKernels.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
#include <iostream>
#include <cstdio>
#include <cstdlib>
......@@ -357,10 +359,11 @@ int main(int argc, char ** argv){
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FMpiTreeBuilder< TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(),
realTree.getBoxCenter(),
realTree.getBoxWidth(),
realTree.getHeight(), &finalParticles);
realTree.getHeight(), &finalParticles,&balancer);
for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){
realTree.insert(finalParticles[idx].position);
......
......@@ -43,6 +43,7 @@
#include "../../Src/Files/FMpiTreeBuilder.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
/** This program show an example of use of
* the fmm basic algo
......@@ -100,8 +101,9 @@ int main(int argc, char ** argv){
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FMpiTreeBuilder<TestParticle>::ArrayToTree(app.global(), particles, NbParticles, loader.getCenterOfBox(),
loader.getBoxWidth(), tree.getHeight(), &finalParticles);
loader.getBoxWidth(), tree.getHeight(), &finalParticles, &balancer);
for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){
tree.insert(finalParticles[idx].position);
......
......@@ -42,13 +42,15 @@
#include "../../Src/Files/FMpiTreeBuilder.hpp"
#include "../../Src/Files/FFmaBinLoader.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
#include <iostream>
#include <cstdio>
#include <cstdlib>
// Uncoment to validate the FMM
#define VALIDATE_FMM
//#define VALIDATE_FMM
/** This program show an example of use of
* the fmm basic algo it also check that eachh particles is little or longer
......@@ -282,10 +284,11 @@ int main(int argc, char ** argv){
}
FVector<TestParticle> finalParticles;
FleafBalance balancer;
FMpiTreeBuilder< TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(),
tree.getBoxCenter(),
tree.getBoxWidth(),
tree.getHeight(), &finalParticles);
tree.getHeight(), &finalParticles,&balancer);
for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){
tree.insert(finalParticles[idx].position,finalParticles[idx].physicalValue);
......@@ -312,7 +315,7 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Create kernel..." << std::endl;
{
KernelClass kernels( NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
......@@ -320,11 +323,11 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
{
FmmClass algo(app.global(),&tree,&kernels);
counter.tic();
algo.execute();
algo.execute(FFmmM2M);
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
......@@ -408,7 +411,8 @@ int main(int argc, char ** argv){
ValidateFMMAlgoProc<OctreeClass,ContainerClass>(&tree,&treeValide,&app);
}
#endif
}
}
// -----------------------------------------------------
......
......@@ -40,6 +40,7 @@
#include "../../Src/Components/FBasicParticleContainer.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
struct TestParticle{
FPoint position;
......@@ -117,9 +118,10 @@ int main(int argc, char ** argv){
}
FVector<TestParticle> finalParticles;
FLeafBalance balancer;
FMpiTreeBuilder< TestParticle >::ArrayToTree(app.global(), particles, NbPart,
FPoint(BoxCenter,BoxCenter,BoxCenter),
BoxWidth, tree.getHeight(), &finalParticles);
FPoint(BoxCenter,BoxCenter,BoxCenter),
BoxWidth, tree.getHeight(), &finalParticles,&balancer);
for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){
tree.insert(finalParticles[idx].position);
......
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