Commit 7863df56 authored by Luka Stanisic's avatar Luka Stanisic

Merge remote-tracking branch 'origin/master' into simgrid

# Conflicts:
#	CMakeLists.txt
#	Src/GroupTree/Core/FGroupTaskStarpuAlgorithm.hpp
#	Src/GroupTree/StarPUUtils/FStarPUTaskNameParams.hpp
#	Tests/GroupTree/testBlockedUniform.cpp
parents 06742e8c 14ea2817
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 1400
PenaltyBreakComment: 1400
PenaltyBreakFirstLessLess: 140000
PenaltyBreakString: 1400
PenaltyExcessCharacter: 1
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: true
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
DisableFormat: false
......@@ -22,7 +22,7 @@ if(SCALFMM_ADDON_CKERNELAPI)
file( GLOB_RECURSE source_lib_files Src/*.cpp )
# Adding cpp files to project
add_library( scalfmmckernelapi STATIC ${source_lib_files} )
add_library( scalfmmckernelapi ${source_lib_files} )
# Add blas library (even if it is set to off)
target_link_libraries( scalfmmckernelapi scalfmm)
......@@ -35,7 +35,7 @@ if(SCALFMM_ADDON_CKERNELAPI)
)
# Install lib
install( TARGETS scalfmmckernelapi ARCHIVE DESTINATION lib )
install( TARGETS scalfmmckernelapi ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
# Install header
SET(my_include_dirs "Src")
......
......@@ -145,10 +145,10 @@ typedef void (*Callback_free_cell)(void*);
/**
* @brief Callback used to know the size of userData.
* @param level current level of current cell
* @param userData Datas that will be serialize
* @param morton_index of the current cell
* @param userData : ptr to user's kernel
*/
typedef FSize (*Callback_get_cell_size)(int level, void * userDatas, long long morton_index);
typedef FSize (*Callback_get_cell_size)(int level, long long morton_index, void * userData);
/**
* @brief Callback used to serialize userdata inside an array of size
......@@ -159,6 +159,39 @@ typedef FSize (*Callback_get_cell_size)(int level, void * userDatas, long long m
*/
typedef void (*Callback_copy_cell)(void * userDatas, FSize size, void * memoryAllocated);
/**
* @brief Callback used by scalfmm to know the size needed by the user
* to store its local datas linked to a leaf.
*
* @param nbParts : number of point inside current Leaf
* @return Size (in bytes) needed to serialize the user datas
*/
typedef FSize (*Callback_get_leaf_size)(FSize nbParts);
/**
* @brief Callback used by scalfmm to serialize the leaf user data.
*
* @param Morton MortonIndex of current Leaf
* @param nbParts : number of point inside current Leaf
* @param userdata : leaf User data
* @param memAllocated : Ptr to an array of size =
* Callback_get_leaf_size(...), to be filled by the user.
*/
typedef void (*Callback_copy_leaf)(FSize nbParts, void * userDatas, void * memAllocated);
/**
* @brief Callback used by scalfmm to retreive leaf data from an array
* (previously filled by the user through Callback_copy_leaf)
*
* @param Morton MortonIndex of current Leaf
* @param nbParts : number of point inside current Leaf
* @param memAllocated : Ptr to an array of size =
* Callback_get_leaf_size(...), to be read by the user in order to
* re-build its leaf.
* @return new userdata local to the leaf
*/
typedef void * (*Callback_restore_leaf)(FSize nbParts, void * memAllocated);
/**
* @brief Callback called if scalfmm_finalize_cell is called.
......@@ -214,10 +247,18 @@ typedef struct User_Scalfmm_Cell_Descriptor{
Callback_get_cell_size user_get_size;
Callback_copy_cell user_copy_cell;
Callback_restore_cell user_restore_cell;
Callback_init_leaf user_init_leaf;
Callback_free_leaf user_free_leaf;
}Scalfmm_Cell_Descriptor;
/**
* @brief This struct contains all the callback affecting leaves
*/
typedef struct User_Scalfmm_Leaf_Descriptor{
Callback_init_leaf user_init_leaf;
Callback_free_leaf user_free_leaf;
Callback_get_leaf_size user_get_size;
Callback_copy_leaf user_copy_leaf;
Callback_restore_leaf user_restore_leaf;
}Scalfmm_Leaf_Descriptor;
/**
* @brief This function build the tree. If scalfmm_init has been
......@@ -228,7 +269,10 @@ typedef struct User_Scalfmm_Cell_Descriptor{
* @param BoxWidth Width of the entire simulation box.
* @param BoxCenter Coordinate of the center of the box (ie array)
*/
void scalfmm_build_tree(scalfmm_handle handle,int TreeHeight,double BoxWidth,double* BoxCenter,Scalfmm_Cell_Descriptor user_cell_descriptor);
void scalfmm_build_tree(scalfmm_handle handle,int TreeHeight,double BoxWidth,
double* BoxCenter,
Scalfmm_Cell_Descriptor user_cell_descriptor,
Scalfmm_Leaf_Descriptor user_leaf_descriptor);
/**
......@@ -488,6 +532,15 @@ typedef void (*Callback_P2M)(void* cellData, void * leafData, FSize nbParticles,
*/
typedef void (*Callback_M2M)(int level, void* parentCell, int childPosition, void* childCell, void* userData);
/**
* @brief Function to be filled by user's M2M
* @param level current level in the tree
* @prama parentCell cell to be filled
* @param userData datas specific to the user's kernel
* @param childCell array of cells to be read
*/
typedef void (*Callback_M2M_Full)(int level, void* parentCell, void* childCell[8], void* userData);
/**
* @brief Function to be filled by user's M2L
* @param level current level in the tree
......@@ -529,6 +582,15 @@ typedef void (*Callback_M2LFull)(int level, void* targetCell, const int * neighb
*/
typedef void (*Callback_L2L)(int level, void* parentCell, int childPosition, void* childCell, void* userData);
/**
* @brief Function to be filled by user's L2L
* @param level current level in the tree
* @prama parentCell cell to be filled
* @param userData datas specific to the user's kernel
* @param childCell array of cells to be read
*/
typedef void (*Callback_L2L_Full)(int level, void* parentCell, void* childCell[8], void* userData);
/**
* @brief Function to be filled by user's L2P
* @param cellData cell to be read
......@@ -599,6 +661,29 @@ typedef void (*Callback_P2PInner)(void * targetLeaf,FSize nbParticles, const FSi
typedef void (*Callback_P2PSym)(void * targetLeaf, FSize nbParticles, const FSize* particleIndexes,
void * sourceLeaf, FSize nbSourceParticles, const FSize* sourceParticleIndexes, void* userData);
/**
* @brief Function to be filled by user's P2P Remote, the sources will
* be erased after the call, so no need to modify them
* @param targetLeaf ptr to user target leaf
* @param nbParticles number of particle in current leaf
* @param particleIndexes indexes of particles currently computed
* @praram sourceLeaves array of user source target
* @param sourceParticleIndexes array of indexes for each source
* @param sourceNbPart : array containing the number of part for each source
* @param size Number of direct neighbors
* @param userData datas specific to the user's kernel
* @attention This function will be called in distributed scalfmm
* only, between leaves belonging to diffenrent MPI processus. On ly
* the target leaf should be modified, since we don't send back the
* sources.
*/
typedef void (*Callback_P2PRemote)(void * targetLeaf,FSize nbParticles, const FSize* particleIndexes,
void ** sourceLeaves,
const FSize ** sourceParticleIndexes,FSize * sourceNbPart,
const int * sourcePosition, const int size, void* userData);
/**
* @brief Function to be filled by user's method to reset a user's cell
* @param level level of the cell.
......@@ -618,15 +703,18 @@ typedef void (*Callback_apply_on_cell)(int level, long long morton_index, int* t
typedef struct User_Scalfmm_Kernel_Descriptor {
Callback_P2M p2m;
Callback_M2M m2m;
Callback_M2M_Full m2m_full;
Callback_M2L m2l;
Callback_M2L_Ext m2l_ext;
Callback_M2LFull m2l_full;
Callback_L2L l2l;
Callback_L2L_Full l2l_full;
Callback_L2P l2p;
Callback_P2P p2p;
Callback_P2PFull p2p_full;
Callback_P2PInner p2pinner;
Callback_P2PSym p2p_sym;
Callback_P2PRemote p2p_remote;
}Scalfmm_Kernel_Descriptor;
......@@ -662,6 +750,14 @@ void scalfmm_user_kernel_config(scalfmm_handle Handle, Scalfmm_Kernel_Descriptor
*/
void scalfmm_execute_fmm(scalfmm_handle Handle);
/**
* @brief This function launch the fmm on the parameters given, but
* only the far field will be evaluated
* @param Handle scalfmm_handle provided by scalfmm_init
*/
void scalfmm_execute_fmm_far_field(scalfmm_handle Handle);
/**
* @brief This function apply the call back on each leaf. Should be
* called after insert_parts.
......@@ -758,8 +854,7 @@ scalfmm_handle scalfmm_init_distributed( scalfmm_kernel_type KernelType,scalfmm_
* once the partitionning done. Can be inserted with no changes.
* @param indexesFilled Array that store the global index of each part
* in the localArrayFilled.
* @param stride stride between two attributes inside attr.
* @param attr array of attribute to be distributed alongside the positions.
* @param outputNbPoint number of points dedicated to this proc
*/
void scalfmm_create_local_partition(scalfmm_handle handle, int nbPoints, double * particleXYZ, double ** localArrayFilled,
FSize ** indexesFilled, FSize * outputNbPoint);
......
......@@ -83,7 +83,8 @@ public:
FScalFMMEngine<FReal>::Algorithm = algo;
}
void build_tree(int TreeHeight, FReal BoxWidth , FReal * BoxCenter,User_Scalfmm_Cell_Descriptor notUsedHere){
virtual void build_tree(int TreeHeight, FReal BoxWidth , FReal * BoxCenter,
User_Scalfmm_Cell_Descriptor notUsedHere, Scalfmm_Leaf_Descriptor notUsedHereToo){
octree = new OctreeClass(TreeHeight,FMath::Min(3,TreeHeight-1),BoxWidth,FPoint<FReal>(BoxCenter));
this->matrix = new MatrixKernelClass();
this->kernel = new InterKernel(TreeHeight,BoxWidth,FPoint<FReal>(BoxCenter),matrix);
......@@ -115,12 +116,12 @@ public:
}else{
if(type==SOURCE){
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleTypeSource,idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleType::FParticleTypeSource,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}else{
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleTypeTarget,idPart);
octree->insert(FPoint<FReal>(&XYZ[3*idPart]),FParticleType::FParticleTypeTarget,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}
......@@ -138,12 +139,12 @@ public:
}else{
if(type==SOURCE){
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleTypeSource,idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleType::FParticleTypeSource,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}else{
for(FSize idPart = 0; idPart<NbPositions ; ++idPart){
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleTypeTarget,idPart);
octree->insert(FPoint<FReal>(X[idPart],Y[idPart],Z[idPart]),FParticleType::FParticleTypeTarget,idPart);
}
FScalFMMEngine<FReal>::nbPart += NbPositions;
}
......@@ -738,6 +739,47 @@ public:
// }
// }
void execute_fmm_far_field(){
switch(FScalFMMEngine<FReal>::Algorithm){
case 0:
{
typedef FFmmAlgorithm<OctreeClass,InterCell,ContainerClass,InterKernel,LeafClass> AlgoClassSeq;
AlgoClassSeq* algoSeq = new AlgoClassSeq(octree,kernel);
algoSeq->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
FScalFMMEngine<FReal>::algoTimer = algoSeq;
FScalFMMEngine<FReal>::abstrct = algoSeq;
break;
}
case 1:
{
typedef FFmmAlgorithmThread<OctreeClass,InterCell,ContainerClass,InterKernel,LeafClass> AlgoClassThread;
AlgoClassThread* algoThread = new AlgoClassThread(octree,kernel);
algoThread->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
FScalFMMEngine<FReal>::algoTimer = algoThread;
FScalFMMEngine<FReal>::abstrct = algoThread;
break;
}
case 2:
{
typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,InterCell,ContainerClass,InterKernel,LeafClass> AlgoClassPeriodic;
AlgoClassPeriodic algoPeriod(octree,2);
algoPeriod.setKernel(kernel);
algoPeriod.execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
break;
}
case 3:
{
typedef FFmmAlgorithmThreadTsm<OctreeClass,InterCell,ContainerClass,InterKernel,LeafClass> AlgoClassTargetSource;
AlgoClassTargetSource* algoTS = new AlgoClassTargetSource(octree,kernel);
algoTS->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
FScalFMMEngine<FReal>::algoTimer = algoTS;
FScalFMMEngine<FReal>::abstrct = algoTS;
break;
}
default :
std::cout<< "No algorithm found (probably for strange reasons) : "<< FScalFMMEngine<FReal>::Algorithm <<" exiting" << std::endl;
}
}
void execute_fmm(){
switch(FScalFMMEngine<FReal>::Algorithm){
......
......@@ -95,7 +95,9 @@ public:
//by specific Engine
//Function about the tree
virtual void build_tree(int TreeHeight,FReal BoxWidth,FReal* BoxCenter,Scalfmm_Cell_Descriptor user_cell_descriptor){
virtual void build_tree(int TreeHeight,FReal BoxWidth,FReal* BoxCenter,
Scalfmm_Cell_Descriptor user_cell_descriptor,
Scalfmm_Leaf_Descriptor user_leaf_descriptor){
FAssertLF(0,"Nothing has been done yet, exiting");
}
......@@ -178,37 +180,6 @@ public:
}
/** Test ... */
struct RunContainer{
template< int nbAttributeToInsert,class ContainerClass,class LeafClass, class CellClass>
static void Run(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPartToInsert,int * strideForEachAtt,
FReal* rawDatas){
generic_tree_abstract_insert<ContainerClass,LeafClass,CellClass,nbAttributeToInsert>(octree,
NbPartToInsert,strideForEachAtt,rawDatas);
}
};
template<class ContainerClass,class LeafClass, class CellClass, int nbAttributeToInsert>
void generic_tree_abstract_insert(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPartToInsert,int * strideForEachAtt,
FReal* rawDatas){
for(FSize idxPart = 0; idxPart<NbPartToInsert ; ++idxPart){
FPoint<FReal> pos = FPoint<FReal>(rawDatas[0],rawDatas[1],rawDatas[2]);
MortonIndex index = octree->getMortonFromPosition(pos);
//Insert with how many attributes ???
octree->insert(pos,idxPart);
//Get again the container
ContainerClass * containerToFill = octree->getLeafSrc(index);//cannot be nullptr
std::array<FReal,nbAttributeToInsert> arrayOfAttribute;
for(int idxAtt = 0; idxAtt<nbAttributeToInsert ; ++idxAtt){
arrayOfAttribute[idxAtt] = rawDatas[3+ strideForEachAtt[idxAtt]];
}
int idxToRemove = containerToFill->getNbParticles();
containerToFill->remove(&idxToRemove,1);
containerToFill->push(pos,idxPart,arrayOfAttribute);
}
}
template<class ContainerClass,class LeafClass,class CellClass>
void generic_get_forces_xyz(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
......@@ -806,6 +777,9 @@ public:
virtual void execute_fmm(){
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
virtual void execute_fmm_far_field(){
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
virtual void intern_dealloc_handle(Callback_free_cell userDeallocator){
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
......@@ -820,15 +794,17 @@ public:
* get the time spent in each operator.
*/
virtual void get_timers(FReal * Timers){
const FTic * timers = algoTimer->getAllTimers();
int nbTimers = algoTimer->getNbOfTimerRecorded();
for(int idTimer = 0; idTimer<nbTimers ; ++idTimer){
Timers[idTimer] = timers[idTimer].elapsed();
}
Timers[0] = algoTimer->Timers["P2M"].elapsed();
Timers[1] = algoTimer->Timers["M2M"].elapsed();
Timers[2] = algoTimer->Timers["M2L"].elapsed();
Timers[3] = algoTimer->Timers["L2L"].elapsed();
Timers[4] = algoTimer->Timers["L2P"].elapsed();
Timers[5] = algoTimer->Timers["P2P"].elapsed();
Timers[6] = algoTimer->Timers["NearField"].elapsed();
}
virtual int get_nb_timers(){
return algoTimer->getNbOfTimerRecorded();
return FAlgorithmTimers::nbTimers;
}