Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ScalFMM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
solverstack
ScalFMM
Commits
4988434c
Commit
4988434c
authored
Nov 06, 2013
by
BRAMAS Berenger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add abstract buffer and use it around
parent
cb32d3d9
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
159 additions
and
57 deletions
+159
-57
Src/Components/FAbstractSendable.hpp
Src/Components/FAbstractSendable.hpp
+16
-7
Src/Components/FAbstractSerializable.hpp
Src/Components/FAbstractSerializable.hpp
+8
-4
Src/Components/FBasicCell.hpp
Src/Components/FBasicCell.hpp
+2
-2
Src/Components/FBasicParticleContainer.hpp
Src/Components/FBasicParticleContainer.hpp
+6
-3
Src/Containers/FAbstractBuffer.hpp
Src/Containers/FAbstractBuffer.hpp
+67
-0
Src/Containers/FBufferReader.hpp
Src/Containers/FBufferReader.hpp
+2
-2
Src/Containers/FBufferWriter.hpp
Src/Containers/FBufferWriter.hpp
+2
-1
Src/Containers/FMpiBufferReader.hpp
Src/Containers/FMpiBufferReader.hpp
+2
-1
Src/Containers/FMpiBufferWriter.hpp
Src/Containers/FMpiBufferWriter.hpp
+2
-1
Src/Containers/FTreeCoordinate.hpp
Src/Containers/FTreeCoordinate.hpp
+3
-1
Src/Extensions/FExtendCellType.hpp
Src/Extensions/FExtendCellType.hpp
+4
-5
Src/Kernels/Chebyshev/FChebCell.hpp
Src/Kernels/Chebyshev/FChebCell.hpp
+4
-2
Src/Kernels/Rotation/FRotationCell.hpp
Src/Kernels/Rotation/FRotationCell.hpp
+16
-10
Src/Kernels/Spherical/FSphericalCell.hpp
Src/Kernels/Spherical/FSphericalCell.hpp
+16
-11
Src/Kernels/Taylor/FTaylorCell.hpp
Src/Kernels/Taylor/FTaylorCell.hpp
+4
-2
Src/Utils/FPoint.hpp
Src/Utils/FPoint.hpp
+5
-5
No files found.
Src/Components/FAbstractSendable.hpp
View file @
4988434c
...
...
@@ -16,9 +16,6 @@
#ifndef FABSTRACTSENDABLE_HPP
#define FABSTRACTSENDABLE_HPP
class
FBufferReader
;
class
FBufferWriter
;
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FAbstractSendable
...
...
@@ -36,18 +33,30 @@ protected:
///////////////////////////////////////////////
/** Save your data */
virtual
void
serializeUp
(
FBufferWriter
&
)
const
=
0
;
template
<
class
BufferWriterClass
>
void
serializeUp
(
BufferWriterClass
&
)
const
{
static_assert
(
sizeof
(
BufferWriterClass
)
==
0
,
"Your class should implement serializeUp"
);
}
/** Retrieve your data */
virtual
void
deserializeUp
(
FBufferReader
&
)
=
0
;
template
<
class
BufferReaderClass
>
void
deserializeUp
(
BufferReaderClass
&
){
static_assert
(
sizeof
(
BufferWriterClass
)
==
0
,
"Your class should implement deserializeUp"
);
}
///////////////////////////////////////////////
// For Downward pass
///////////////////////////////////////////////
/** Save your data */
virtual
void
serializeDown
(
FBufferWriter
&
)
const
=
0
;
template
<
class
BufferWriterClass
>
void
serializeDown
(
BufferWriterClass
&
)
const
{
static_assert
(
sizeof
(
BufferWriterClass
)
==
0
,
"Your class should implement serializeDown"
);
}
/** Retrieve your data */
virtual
void
deserializeDown
(
FBufferReader
&
)
=
0
;
template
<
class
BufferReaderClass
>
void
deserializeDown
(
BufferReaderClass
&
){
static_assert
(
sizeof
(
BufferWriterClass
)
==
0
,
"Your class should implement deserializeDown"
);
}
};
...
...
Src/Components/FAbstractSerializable.hpp
View file @
4988434c
...
...
@@ -16,8 +16,6 @@
#ifndef FABSTRACTSERIALIZABLE_HPP
#define FABSTRACTSERIALIZABLE_HPP
class
FBufferReader
;
class
FBufferWriter
;
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
...
...
@@ -29,8 +27,14 @@ class FBufferWriter;
*/
class
FAbstractSerializable
{
protected:
virtual
void
save
(
FBufferWriter
&
)
const
=
0
;
virtual
void
restore
(
FBufferReader
&
)
=
0
;
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
)
const
{
static_assert
(
sizeof
(
BufferWriterClass
)
==
0
,
"Your class should implement save"
);
}
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
){
static_assert
(
sizeof
(
BufferReaderClass
)
==
0
,
"Your class should implement restore"
);
}
};
#endif // FABSTRACTSERIALIZABLE_HPP
Src/Components/FBasicCell.hpp
View file @
4988434c
...
...
@@ -16,7 +16,7 @@
#ifndef FBASICCELL_HPP
#define FBASICCELL_HPP
#include "FAbstractSerializable.hpp"
#include "../Extensions/FExtendMortonIndex.hpp"
#include "../Extensions/FExtendCoordinate.hpp"
...
...
@@ -34,7 +34,7 @@
*
*
*/
class
FBasicCell
:
public
FExtendMortonIndex
,
public
FExtendCoordinate
{
class
FBasicCell
:
public
FExtendMortonIndex
,
public
FExtendCoordinate
,
public
FAbstractSerializable
{
public:
/** Default destructor */
virtual
~
FBasicCell
(){
...
...
Src/Components/FBasicParticleContainer.hpp
View file @
4988434c
...
...
@@ -17,6 +17,7 @@
#define FBASICPARTICLECONTAINER_HPP
#include "FAbstractParticleContainer.hpp"
#include "FAbstractSerializable.hpp"
#include "../Utils/FAlignedMemory.hpp"
#include "../Utils/FMath.hpp"
...
...
@@ -42,7 +43,7 @@
* @code AStruct* strucs = container.getAttributes<0>();
*/
template
<
unsigned
NbAttributesPerParticle
,
class
AttributeClass
=
FReal
>
class
FBasicParticleContainer
:
public
FAbstractParticleContainer
{
class
FBasicParticleContainer
:
public
FAbstractParticleContainer
,
public
FAbstractSerializable
{
protected:
/** The number of particles in the container */
int
nbParticles
;
...
...
@@ -252,7 +253,8 @@ public:
}
/** Save the current cell in a buffer */
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
buffer
<<
nbParticles
;
for
(
int
idx
=
0
;
idx
<
3
;
++
idx
){
buffer
.
write
(
positions
[
idx
],
nbParticles
);
...
...
@@ -262,7 +264,8 @@ public:
}
}
/** Restore the current cell from a buffer */
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
buffer
>>
nbParticles
;
if
(
nbParticles
>=
allocatedParticles
){
// allocate memory
...
...
Src/Containers/FAbstractBuffer.hpp
0 → 100644
View file @
4988434c
#ifndef FABSTRACTBUFFER_HPP
#define FABSTRACTBUFFER_HPP
class
FAbstractBufferReader
{
public:
virtual
~
FAbstractBufferReader
(){
}
virtual
char
*
data
()
=
0
;
virtual
const
char
*
data
()
const
=
0
;
virtual
int
getSize
()
const
=
0
;
virtual
void
seek
(
const
int
inIndex
)
=
0
;
virtual
int
tell
()
const
=
0
;
virtual
void
reserve
(
const
int
nbBytes
)
=
0
;
virtual
void
reset
()
=
0
;
template
<
class
ClassType
>
ClassType
getValue
(){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement getValue."
);
return
ClassType
();
}
template
<
class
ClassType
>
void
fillValue
(
ClassType
*
const
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement fillValue."
);
}
template
<
class
ClassType
>
void
fillArray
(
ClassType
*
const
,
const
int
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement fillArray."
);
}
template
<
class
ClassType
>
FAbstractBufferReader
&
operator
>>
(
ClassType
&
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement operator>>."
);
return
*
this
;
}
};
class
FAbstractBufferWriter
{
public:
virtual
~
FAbstractBufferWriter
(){
}
virtual
char
*
data
()
=
0
;
virtual
const
char
*
data
()
const
=
0
;
virtual
int
getSize
()
const
=
0
;
virtual
void
reset
()
=
0
;
template
<
class
ClassType
>
void
write
(
const
ClassType
&
object
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement write."
);
}
template
<
class
ClassType
>
void
writeAt
(
const
int
position
,
const
ClassType
&
object
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement writeAt."
);
}
template
<
class
ClassType
>
void
write
(
const
ClassType
*
const
objects
,
const
int
inSize
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement write."
);
}
template
<
class
ClassType
>
FAbstractBufferWriter
&
operator
<<
(
const
ClassType
&
){
static_assert
(
sizeof
(
ClassType
)
==
0
,
"Your Buffer should implement operator<<."
);
return
*
this
;
}
};
#endif // FABSTRACTBUFFER_HPP
Src/Containers/FBufferReader.hpp
View file @
4988434c
...
...
@@ -17,7 +17,7 @@
#define FBUFFERREADER_HPP
#include "FVector.hpp"
#include "FAbstractBuffer.hpp"
/** @author Berenger Bramas
* This class provide a fast way to manage a memory and convert
...
...
@@ -26,7 +26,7 @@
* Specifie the needed space with reserve, then fill it with data
* finaly read and convert.
*/
class
FBufferReader
{
class
FBufferReader
:
public
FAbstractBufferReader
{
FVector
<
char
>
buffer
;
//< The memory buffer
int
index
;
//< The current index reading position
...
...
Src/Containers/FBufferWriter.hpp
View file @
4988434c
...
...
@@ -17,6 +17,7 @@
#define FBUFFERWRITER_HPP
#include "FVector.hpp"
#include "FAbstractBuffer.hpp"
/** @author Berenger Bramas
* This class provide a fast way to manage a memory and fill it
...
...
@@ -25,7 +26,7 @@
* then insert back if needed
* finaly use data pointer as you like
*/
class
FBufferWriter
{
class
FBufferWriter
:
public
FAbstractBufferWriter
{
private:
FVector
<
char
>
buffer
;
//< The buffer
...
...
Src/Containers/FMpiBufferReader.hpp
View file @
4988434c
...
...
@@ -18,6 +18,7 @@
#include <memory>
#include "../Utils/FMpi.hpp"
#include "FAbstractBuffer.hpp"
/** @author Cyrille Piacibello
...
...
@@ -27,7 +28,7 @@
* then insert back if needed
* finally use data pointer as you like
*/
class
FMpiBufferReader
{
class
FMpiBufferReader
:
public
FAbstractBufferReader
{
const
MPI_Comm
comm
;
//< Communicator needed by MPI_Pack functions
const
int
arrayCapacity
;
//< Allocated space
std
::
unique_ptr
<
char
[]
>
array
;
//< Allocated Array
...
...
Src/Containers/FMpiBufferWriter.hpp
View file @
4988434c
...
...
@@ -18,6 +18,7 @@
#include <memory>
#include "../Utils/FMpi.hpp"
#include "FAbstractBuffer.hpp"
/** @author Cyrille Piacibello
* This class provide the same features as FBufferWriter using MPI_Pack system
...
...
@@ -26,7 +27,7 @@
* then insert back if needed
* finally use data pointer as you like
*/
class
FMpiBufferWriter
{
class
FMpiBufferWriter
:
public
FAbstractBufferWriter
{
const
MPI_Comm
mpiComm
;
//< Communicator needed by MPI_Pack functions
const
int
arrayCapacity
;
//< Allocated Space
std
::
unique_ptr
<
char
[]
>
array
;
//< Allocated Array
...
...
Src/Containers/FTreeCoordinate.hpp
View file @
4988434c
...
...
@@ -21,6 +21,8 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FMath.hpp"
#include "../Components/FAbstractSerializable.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FTreeCoordinate
...
...
@@ -31,7 +33,7 @@
* It is directly related to morton index, as interleaves
* bits from this coordinate make the morton index
*/
class
FTreeCoordinate
{
class
FTreeCoordinate
:
public
FAbstractSerializable
{
private:
int
data
[
3
];
//< all box-th position
...
...
Src/Extensions/FExtendCellType.hpp
View file @
4988434c
...
...
@@ -16,9 +16,6 @@
#ifndef FEXTENDCELLTYPE_HPP
#define FEXTENDCELLTYPE_HPP
#include "../Containers/FBufferReader.hpp"
#include "../Containers/FBufferWriter.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class FExtendCellType
...
...
@@ -73,12 +70,14 @@ public:
public:
/** Save current object */
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
buffer
<<
containsTargets
;
buffer
<<
containsSources
;
}
/** Retrieve current object */
void
restore
(
FBufferReader
&
buffer
)
{
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
)
{
buffer
>>
containsTargets
;
buffer
>>
containsSources
;
}
...
...
Src/Kernels/Chebyshev/FChebCell.hpp
View file @
4988434c
...
...
@@ -80,11 +80,13 @@ public:
template
<
int
ORDER
,
int
NVALS
=
1
>
class
FTypedChebCell
:
public
FChebCell
<
ORDER
,
NVALS
>
,
public
FExtendCellType
{
public:
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
FChebCell
<
ORDER
,
NVALS
>::
save
(
buffer
);
FExtendCellType
::
save
(
buffer
);
}
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
FChebCell
<
ORDER
,
NVALS
>::
restore
(
buffer
);
FExtendCellType
::
restore
(
buffer
);
}
...
...
Src/Kernels/Rotation/FRotationCell.hpp
View file @
4988434c
...
...
@@ -23,8 +23,6 @@
#include "../../Components/FBasicCell.hpp"
#include "../../Containers/FBufferWriter.hpp"
#include "../../Containers/FBufferReader.hpp"
/** This class is a cell used for the rotation based kernel
* The size of the multipole and local vector are based on a template
...
...
@@ -107,29 +105,35 @@ public:
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
void
serializeUp
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
serializeUp
(
BufferWriterClass
&
buffer
)
const
{
buffer
.
write
(
multipole_exp
,
MultipoleSize
);
}
void
deserializeUp
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
deserializeUp
(
BufferReaderClass
&
buffer
){
buffer
.
fillArray
(
multipole_exp
,
MultipoleSize
);
}
void
serializeDown
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
serializeDown
(
BufferWriterClass
&
buffer
)
const
{
buffer
.
write
(
local_exp
,
LocalSize
);
}
void
deserializeDown
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
deserializeDown
(
BufferReaderClass
&
buffer
){
buffer
.
fillArray
(
local_exp
,
LocalSize
);
}
///////////////////////////////////////////////////////
// to extend Serializable
///////////////////////////////////////////////////////
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
FBasicCell
::
save
(
buffer
);
buffer
.
write
(
multipole_exp
,
MultipoleSize
);
buffer
.
write
(
local_exp
,
LocalSize
);
}
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
FBasicCell
::
restore
(
buffer
);
buffer
.
fillArray
(
multipole_exp
,
MultipoleSize
);
buffer
.
fillArray
(
local_exp
,
LocalSize
);
...
...
@@ -139,11 +143,13 @@ public:
template
<
int
P
>
class
FTypedRotationCell
:
public
FRotationCell
<
P
>
,
public
FExtendCellType
{
public:
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
FRotationCell
<
P
>::
save
(
buffer
);
FExtendCellType
::
save
(
buffer
);
}
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
FRotationCell
<
P
>::
restore
(
buffer
);
FExtendCellType
::
restore
(
buffer
);
}
...
...
Src/Kernels/Spherical/FSphericalCell.hpp
View file @
4988434c
...
...
@@ -23,9 +23,6 @@
#include "../../Components/FBasicCell.hpp"
#include "../../Containers/FBufferWriter.hpp"
#include "../../Containers/FBufferReader.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
*/
...
...
@@ -121,29 +118,35 @@ public:
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
void
serializeUp
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
serializeUp
(
BufferWriterClass
&
buffer
)
const
{
buffer
.
write
(
multipole_exp
,
PoleSize
);
}
void
deserializeUp
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
deserializeUp
(
BufferReaderClass
&
buffer
){
buffer
.
fillArray
(
multipole_exp
,
PoleSize
);
}
void
serializeDown
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
serializeDown
(
BufferWriterClass
&
buffer
)
const
{
buffer
.
write
(
local_exp
,
LocalSize
);
}
void
deserializeDown
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
deserializeDown
(
BufferReaderClass
&
buffer
){
buffer
.
fillArray
(
local_exp
,
LocalSize
);
}
///////////////////////////////////////////////////////
// to extend Serializable
///////////////////////////////////////////////////////
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
FBasicCell
::
save
(
buffer
);
buffer
.
write
(
multipole_exp
,
PoleSize
);
buffer
.
write
(
local_exp
,
LocalSize
);
}
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
FBasicCell
::
restore
(
buffer
);
buffer
.
fillArray
(
multipole_exp
,
PoleSize
);
buffer
.
fillArray
(
local_exp
,
LocalSize
);
...
...
@@ -160,11 +163,13 @@ int FSphericalCell::PoleSize(-1);
*/
class
FTypedSphericalCell
:
public
FSphericalCell
,
public
FExtendCellType
{
public:
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
FSphericalCell
::
save
(
buffer
);
FExtendCellType
::
save
(
buffer
);
}
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
FSphericalCell
::
restore
(
buffer
);
FExtendCellType
::
restore
(
buffer
);
}
...
...
Src/Kernels/Taylor/FTaylorCell.hpp
View file @
4988434c
...
...
@@ -86,11 +86,13 @@ public:
template
<
int
P
,
int
order
>
class
FTypedTaylorCell
:
public
FTaylorCell
<
P
,
order
>
,
public
FExtendCellType
{
public:
void
save
(
FBufferWriter
&
buffer
)
const
{
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
FTaylorCell
<
P
,
order
>::
save
(
buffer
);
FExtendCellType
::
save
(
buffer
);
}
void
restore
(
FBufferReader
&
buffer
){
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
){
FTaylorCell
<
P
,
order
>::
restore
(
buffer
);
FExtendCellType
::
restore
(
buffer
);
}
...
...
Src/Utils/FPoint.hpp
View file @
4988434c
...
...
@@ -18,8 +18,6 @@
#include "FMath.hpp"
#include "FGlobal.hpp"
#include "../Containers/FBufferReader.hpp"
#include "../Containers/FBufferWriter.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
...
...
@@ -300,12 +298,14 @@ public:
return
output
;
// for multiple << operators.
}
/** Save current object */
void
save
(
FBufferWriter
&
buffer
)
const
{
/** Save current object */
template
<
class
BufferWriterClass
>
void
save
(
BufferWriterClass
&
buffer
)
const
{
buffer
<<
data
[
0
]
<<
data
[
1
]
<<
data
[
2
];
}
/** Retrieve current object */
void
restore
(
FBufferReader
&
buffer
)
{
template
<
class
BufferReaderClass
>
void
restore
(
BufferReaderClass
&
buffer
)
{
buffer
>>
data
[
0
]
>>
data
[
1
]
>>
data
[
2
];
}
};
...
...
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