Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
0bb85290
Commit
0bb85290
authored
Dec 08, 2014
by
PIACIBELLO Cyrille
Browse files
Update in API in order to remove memory leaks (changes added to FChebInterpolator too.)
parent
0b6ed9f6
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Addons/CKernelApi/Src/CScalfmmApi.h
View file @
0bb85290
...
...
@@ -465,7 +465,7 @@ void scalfmm_execute_fmm(scalfmm_handle Handle);
* The last param cellDestroyer is meaningless in case the user uses
* one of the provided kernel. (i.e. Chebyshev, Lagrange)
*/
void
S
calfmm_dealloc_handle
(
scalfmm_handle
handle
,
Callback_free_cell
cellDestroyer
);
void
s
calfmm_dealloc_handle
(
scalfmm_handle
handle
,
Callback_free_cell
cellDestroyer
);
#endif
Addons/CKernelApi/Src/FInterEngine.hpp
View file @
0bb85290
...
...
@@ -24,9 +24,10 @@
#include "FScalFMMEngine.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
#include "Kernels/P2P/FP2PLeafInterface.hpp"
//
#include "Kernels/P2P/FP2PLeafInterface.hpp"
#include "Arranger/FOctreeArranger.hpp"
#include "Arranger/FArrangerPeriodic.hpp"
#include "Arranger/FBasicParticleContainerIndexedMover.hpp"
#include "Core/FFmmAlgorithmThread.hpp"
#include "Core/FFmmAlgorithm.hpp"
...
...
@@ -45,12 +46,14 @@ class FInterEngine : public FScalFMMEngine{
private:
//Typedef on the octree class, in order to clarify following code
typedef
FOctree
<
InterCell
,
ContainerClass
,
LeafClass
>
OctreeClass
;
typedef
FP2PLeafInterface
<
OctreeClass
>
LeafInterface
;
//
typedef FP2PLeafInterface<OctreeClass> LeafInterface;
//Typedef on Octree Arranger, in order to clarify following code
typedef
FOctreeArranger
<
OctreeClass
,
ContainerClass
,
LeafInterface
>
ArrangerClass
;
typedef
FArrangerPeriodic
<
OctreeClass
,
ContainerClass
,
LeafInterface
>
ArrangerClassPeriodic
;
typedef
FBasicParticleContainerIndexedMover
<
OctreeClass
,
ContainerClass
>
MoverClass
;
typedef
FOctreeArranger
<
OctreeClass
,
ContainerClass
,
MoverClass
>
ArrangerClass
;
typedef
FArrangerPeriodic
<
OctreeClass
,
ContainerClass
,
MoverClass
>
ArrangerClassPeriodic
;
//Pointer to the kernel to be executed
InterKernel
*
kernel
;
MatrixKernelClass
*
matrix
;
...
...
@@ -78,8 +81,12 @@ public:
//TODO free kernel too
~
FInterEngine
(){
free
(
octree
);
free
(
kernel
);
delete
matrix
;
delete
octree
;
delete
kernel
;
if
(
arranger
){
delete
arranger
;
}
}
//Inserting array of position
...
...
@@ -528,7 +535,6 @@ public:
void
execute_fmm
(){
//typedef FOctree<InterCell,ContainerClass,LeafClass> OctreeClass;
switch
(
Algorithm
){
case
0
:
{
...
...
@@ -557,7 +563,9 @@ public:
}
}
void
intern_dealloc_handle
(
Callback_free_cell
unUsed
){
//this->~FInterEngine();
}
};
...
...
Addons/CKernelApi/Src/FScalFMMEngine.hpp
View file @
0bb85290
...
...
@@ -51,11 +51,16 @@ protected:
scalfmm_kernel_type
kernelType
;
scalfmm_algorithm
Algorithm
;
FVector
<
bool
>
progress
;
FVector
<
bool
>
*
progress
;
int
nbPart
;
public:
FScalFMMEngine
()
:
Algorithm
(
multi_thread
),
progress
(),
nbPart
(
0
){
FScalFMMEngine
()
:
Algorithm
(
multi_thread
),
progress
(
nullptr
),
nbPart
(
0
){
progress
=
new
FVector
<
bool
>
();
}
virtual
~
FScalFMMEngine
()
{
delete
progress
;
}
//First function displayed there are common function for every
...
...
@@ -208,6 +213,10 @@ public:
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
"
);
}
};
...
...
@@ -378,6 +387,10 @@ extern "C" void scalfmm_execute_fmm(scalfmm_handle Handle){
((
ScalFmmCoreHandle
*
)
Handle
)
->
engine
->
execute_fmm
();
}
extern
"C"
void
scalfmm_user_kernel_config
(
scalfmm_handle
Handle
,
Scalfmm_Kernel_Descriptor
userKernel
,
void
*
userDatas
){
((
ScalFmmCoreHandle
*
)
Handle
)
->
engine
->
user_kernel_config
(
userKernel
,
userDatas
);
}
extern
"C"
void
scalfmm_init_cell
(
scalfmm_handle
Handle
,
Callback_init_cell
user_cell_initializer
){
((
ScalFmmCoreHandle
*
)
Handle
)
->
engine
->
init_cell
(
user_cell_initializer
);
}
...
...
@@ -386,5 +399,8 @@ extern "C" void scalfmm_free_cell(scalfmm_handle Handle, Callback_free_cell user
((
ScalFmmCoreHandle
*
)
Handle
)
->
engine
->
free_cell
(
user_cell_deallocator
);
}
// extern "C" void scalfmm_intern_dealloc_handle(scalfmm_handle Handle,Callback_free_cell userDeallocator){
// ((ScalFmmCoreHandle * ) Handle)->engine->intern_dealloc_handle(userDeallocator);
// }
#endif
Addons/CKernelApi/Src/FScalfmmApiInit.cpp
View file @
0bb85290
#ifndef CALL_HPP
#define CALL_HPP
/** It should be compiled with C export */
extern
"C"
{
#include "CScalfmmApi.h"
...
...
@@ -15,7 +11,7 @@ extern "C" scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* Bo
switch
(
KernelType
){
case
0
:
//
handle->engine = new FUserKernelEngine(
...
);
handle
->
engine
=
new
FUserKernelEngine
(
TreeHeight
,
BoxWidth
,
BoxCenter
,
KernelType
);
std
::
cout
<<
"User Kernel type unsupported yet"
<<
std
::
endl
;
break
;
...
...
@@ -48,5 +44,8 @@ extern "C" scalfmm_handle scalfmm_init(int TreeHeight,double BoxWidth,double* Bo
return
handle
;
}
#endif
extern
"C"
void
scalfmm_dealloc_handle
(
scalfmm_handle
handle
,
Callback_free_cell
userDeallocator
){
((
ScalFmmCoreHandle
*
)
handle
)
->
engine
->
intern_dealloc_handle
(
userDeallocator
);
delete
((
ScalFmmCoreHandle
*
)
handle
)
->
engine
;
delete
(
ScalFmmCoreHandle
*
)
handle
;
}
Addons/CKernelApi/Src/FUserKernelEngine.hpp
View file @
0bb85290
...
...
@@ -153,10 +153,11 @@ private:
typedef
FSimpleLeaf
<
ContainerClass
>
LeafClass
;
typedef
FOctree
<
CoreCell
,
ContainerClass
,
LeafClass
>
OctreeClass
;
typedef
CoreKernel
<
CoreCell
,
ContainerClass
>
CoreKernelClass
;
typedef
FP2PLeafInterface
<
OctreeClass
>
LeafInterface
;
//For arranger classes
typedef
FOctreeArranger
<
OctreeClass
,
ContainerClass
,
LeafInterface
>
ArrangerClass
;
typedef
FArrangerPeriodic
<
OctreeClass
,
ContainerClass
,
LeafInterface
>
ArrangerClassPeriodic
;
typedef
FBasicParticleContainerIndexedMover
<
OctreeClass
,
ContainerClass
>
MoverClass
;
typedef
FOctreeArranger
<
OctreeClass
,
ContainerClass
,
MoverClass
>
ArrangerClass
;
typedef
FArrangerPeriodic
<
OctreeClass
,
ContainerClass
,
MoverClass
>
ArrangerClassPeriodic
;
//Attributes
...
...
@@ -171,12 +172,23 @@ public:
kernelType
=
KernelType
;
//Kernel is not set now because the user must provide a
//Scalfmm_Kernel_descriptor
//kernel = new CoreKernelClass();
}
~
FUserKernelEngine
(){
delete
octree
;
if
(
arranger
){
delete
arranger
;
}
if
(
kernel
){
delete
kernel
;
}
}
void
user_kernel_config
(
Scalfmm_Kernel_Descriptor
userKernel
,
void
*
userDatas
){
kernel
=
new
CoreKernelClass
(
userKernel
,
userDatas
);
if
(
!
kernel
){
kernel
=
new
CoreKernelClass
(
userKernel
,
userDatas
);
}
}
...
...
@@ -226,11 +238,11 @@ public:
}
void
execute_fmm
(){
//
FAssertLF(kernel,"No kernel set, please use scalfmm_user_kernel_config before calling the execute routine ... Exiting \n");
FAssertLF
(
kernel
,
"No kernel set, please use scalfmm_user_kernel_config before calling the execute routine ... Exiting
\n
"
);
switch
(
Algorithm
){
case
0
:
{
typedef
FFmmAlgorithm
<
OctreeClass
,
CoreCell
,
ContainerClass
,
CoreKernelClass
,
Leaf
Interface
>
AlgoClassSeq
;
typedef
FFmmAlgorithm
<
OctreeClass
,
CoreCell
,
ContainerClass
,
CoreKernelClass
,
Leaf
Class
>
AlgoClassSeq
;
AlgoClassSeq
algoSeq
(
octree
,
kernel
);
algoSeq
.
execute
();
break
;
...
...
@@ -255,7 +267,10 @@ public:
}
}
void
intern_dealloc_handle
(
Callback_free_cell
userDeallocator
){
free_cell
(
userDeallocator
);
this
->~
FUserKernelEngine
();
}
};
...
...
Addons/CKernelApi/Tests/testUseNewApi.c
View file @
0bb85290
...
...
@@ -23,7 +23,7 @@ int main(int argc, char ** av){
scalfmm_kernel_type
myChoice
=
chebyshev
;
//Octree configuration
int
TreeHeight
=
5
;
int
TreeHeight
=
7
;
double
boxWidth
=
2
.
0
;
double
boxCenter
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
...
...
@@ -56,7 +56,7 @@ int main(int argc, char ** av){
//Computation Part
int
nb_iteration
=
10
0
;
int
nb_iteration
=
10
;
//atoi(av[1])
;
int
curr_iteration
=
0
;
//Array to store the output
...
...
@@ -112,13 +112,16 @@ int main(int argc, char ** av){
curr_iteration
++
;
}
//End of Computation, useer get the position after a hundreds of iterations
//Free memory
free
(
positionsXYZ
);
free
(
array_of_charge
);
free
(
array_of_forces
);
free
(
array_of_pot
);
free
(
array_of_displacement
);
//End of Computation, useer get the position after some iterations
scalfmm_dealloc_handle
(
handle
,
NULL
);
return
0
;
}
Addons/CKernelApi/Tests/testUserDefinedKernelApi.c
View file @
0bb85290
...
...
@@ -236,10 +236,10 @@ int main(int argc, char ** argv){
scalfmm_handle
handle
=
scalfmm_init
(
treeHeight
,
boxWidth
,
boxCenter
,
user_defined_kernel
);
// Insert particles
printf
(
"Inserting particles...
\n
"
);
S
calfmm_insert_
array_of_
particles
(
handle
,
nbParticles
,
particleIndexes
,
particleXYZ
);
s
calfmm_
tree_
insert_particles
_xyz
(
handle
,
nbParticles
,
particleXYZ
);
// Init cell
printf
(
"Initizalizing the cells:
\n
"
);
S
calfmm_init_cell
(
handle
,
my_Callback_init_cell
);
s
calfmm_init_cell
(
handle
,
my_Callback_init_cell
);
// Init our callback struct
struct
User_Scalfmm_Kernel_Descriptor
kernel
;
...
...
@@ -255,9 +255,11 @@ int main(int argc, char ** argv){
struct
MyData
my_data
;
memset
(
&
my_data
,
0
,
sizeof
(
struct
MyData
));
my_data
.
insertedPositions
=
particleXYZ
;
//Set my datas before calling fmm (this will set as well the kernel)
scalfmm_user_kernel_config
(
handle
,
kernel
,
&
my_data
);
// Execute the FMM
S
calfmm_execute_
kernel
(
handle
,
kernel
,
&
my_data
);
s
calfmm_execute_
fmm
(
handle
/*
, kernel, &my_data
*/
);
// Print the results store in our callback
printf
(
"There was %d P2M
\n
"
,
my_data
.
countP2M
);
...
...
@@ -268,8 +270,10 @@ int main(int argc, char ** argv){
printf
(
"There was %d P2PInner
\n
"
,
my_data
.
countP2PInner
);
printf
(
"There was %d P2P
\n
"
,
my_data
.
countP2P
);
//Dealloc the cells
scalfmm_free_cell
(
handle
,
my_Callback_free_cell
);
// Dealloc the handle
S
calfmm_dealloc_handle
(
handle
,
my_Callback_free_cell
);
s
calfmm_dealloc_handle
(
handle
,
my_Callback_free_cell
);
return
0
;
}
Src/Kernels/Chebyshev/FChebInterpolator.hpp
View file @
0bb85290
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment