Commit 63f38123 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Adding a scalfmm_execute_only_far_field method to the API, in order for a user...

Adding a scalfmm_execute_only_far_field method to the API, in order for a user to compute a FMM without P2P
parent 449acc24
......@@ -749,6 +749,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.
......
......@@ -739,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){
......
......@@ -777,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");
......@@ -994,6 +997,12 @@ extern "C" void scalfmm_execute_fmm(scalfmm_handle Handle){
((ScalFmmCoreHandle<double> * ) Handle)->engine->execute_fmm();
}
//Executing FMM
extern "C" void scalfmm_execute_fmm_far_field(scalfmm_handle Handle){
((ScalFmmCoreHandle<double> * ) Handle)->engine->execute_fmm_far_field();
}
extern "C" void scalfmm_user_kernel_config(scalfmm_handle Handle, Scalfmm_Kernel_Descriptor userKernel, void * userDatas){
((ScalFmmCoreHandle<double> * ) Handle)->engine->user_kernel_config(userKernel,userDatas);
}
......
......@@ -697,6 +697,25 @@ public:
}
}
void execute_fmm_far_field(){
FAssertLF(octreeDist,
"No Tree set, please use scalfmm_user_kernel_config before calling the execute routine ... Exiting \n");
//Only one config shall work , so let's use it
switch(FScalFMMEngine<FReal>::Algorithm){
case 5:
{
typedef FFmmAlgorithmThreadProc<OctreeClass,CoreCellDist,ContainerClass,CoreKernelClass,LeafClass> AlgoProcClass;
AlgoProcClass * algoProc = new AlgoProcClass(*comm,octreeDist,kernel);
FScalFMMEngine<FReal>::algoTimer = algoProc;
algoProc->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
break;
}
default:
break;
}
}
void free_cell(Callback_free_cell user_cell_deallocator){
octreeDist->forEachCell([&](CoreCellDist * currCell){
if(currCell->getContainer()){
......
......@@ -714,6 +714,69 @@ public:
}
}
virtual void execute_fmm_far_field(){
FAssertLF(kernel,"No kernel set, please use scalfmm_user_kernel_config before calling the execute routine ... Exiting \n");
switch(FScalFMMEngine<FReal>::Algorithm){
case 0:
{
typedef FFmmAlgorithm<OctreeClass,CoreCell,ContainerClass,CoreKernelClass,LeafClass> AlgoClassSeq;
AlgoClassSeq * algoSeq = new AlgoClassSeq(octree,kernel);
FScalFMMEngine<FReal>::algoTimer = algoSeq;
FScalFMMEngine<FReal>::abstrct = algoSeq;
//algoSeq->execute(); will be done later
break;
}
case 1:
{
typedef FFmmAlgorithmThread<OctreeClass,CoreCell,ContainerClass,CoreKernelClass,LeafClass> AlgoClassThread;
AlgoClassThread* algoThread = new AlgoClassThread(octree,kernel);
FScalFMMEngine<FReal>::algoTimer = algoThread;
FScalFMMEngine<FReal>::abstrct = algoThread;
//algoThread->execute(); will be done later
break;
}
case 2:
{
typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CoreCell,ContainerClass,CoreKernelClass,LeafClass> AlgoClassPeriodic;
AlgoClassPeriodic algoPeriod(octree,2);
algoPeriod.setKernel(kernel);
algoPeriod.execute();
break;
}
case 3:
{
typedef FFmmAlgorithmThreadTsm<OctreeClass,CoreCell,ContainerClass,CoreKernelClass,LeafClass> AlgoClassTargetSource;
AlgoClassTargetSource* algoTS = new AlgoClassTargetSource(octree,kernel);
FScalFMMEngine<FReal>::algoTimer = algoTS;
FScalFMMEngine<FReal>::abstrct = algoTS;
//algoTS->execute(); will be done later
break;
}
default :
std::cout<< "No algorithm found (probably for strange reasons) : "<< FScalFMMEngine<FReal>::Algorithm <<" exiting" << std::endl;
}
if (FScalFMMEngine<FReal>::Algorithm != 2){
if(upperLimit != 2){
(FScalFMMEngine<FReal>::abstrct)->execute(FFmmP2M | FFmmM2M | FFmmM2L, upperLimit, treeHeight);
printf("\tUpPass finished\n");
internal_M2L();
printf("\tStrange M2L finished\n");
(FScalFMMEngine<FReal>::abstrct)->execute(FFmmL2L | FFmmL2P, upperLimit, treeHeight);
printf("\tDownPass finished\n");
}
else{
if(octree->getHeight() == 2){
//(FScalFMMEngine<FReal>::abstrct)->execute(FFmmP2P);
std::cout<<"Nothing to be done\n";
}else{
(FScalFMMEngine<FReal>::abstrct)->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
}
}
}
}
virtual void intern_dealloc_handle(Callback_free_cell userDeallocator){
free_cell(userDeallocator, ContainerClass::GetFreeLeaf());
}
......
......@@ -74,6 +74,7 @@ void cheb_p2pFull(void * targetLeaf, FSize nbParticles, const FSize* particleInd
void ** sourceLeaves,
const FSize ** sourceParticleIndexes, FSize* sourceNbPart,const int * sourcePosition,
const int size, void* userData) {
printf("NOPE\n");
ChebKernel_P2P(targetLeaf,nbParticles, particleIndexes, sourceLeaves, sourceParticleIndexes, sourceNbPart,sourcePosition,size,
userData);
}
......@@ -285,7 +286,7 @@ int main(int argc, char ** av){
scalfmm_apply_on_leaf(handle,fill_leaf_container);
tic(&interface_timer);
scalfmm_execute_fmm(handle/*, kernel, &my_data*/);
scalfmm_execute_fmm_far_field(handle/*, kernel, &my_data*/);
tac(&interface_timer);
{ //Temporary
......@@ -320,7 +321,7 @@ int main(int argc, char ** av){
print_elapsed(&interface_timer);
tic(&ref_timer);
scalfmm_execute_fmm(handle_ref/*, kernel, &my_data*/);
scalfmm_execute_fmm_far_field(handle_ref/*, kernel, &my_data*/);
tac(&ref_timer);
/* { //Temporary */
......
......@@ -353,7 +353,7 @@ int main(int argc, char ** argv){
//Execution !!
scalfmm_execute_fmm(Handle);
scalfmm_execute_fmm_far_field(Handle);
scalfmm_apply_on_leaf(Handle,on_leaf);
......
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