Commit 33e7351a authored by BRAMAS Berenger's avatar BRAMAS Berenger

Add rotation POD and update blocked rotation main

parent a5b423db
......@@ -2,5 +2,168 @@
#ifndef FROTATIONCELLPOD_HPP
#define FROTATIONCELLPOD_HPP
#include "../../Utils/FComplex.hpp"
#include "../../Utils/FMemUtils.hpp"
#include "../../Utils/FGlobal.hpp"
#include "../../Containers/FTreeCoordinate.hpp"
#include "../StarPUUtils/FStarPUDefaultAlign.hpp"
struct alignas(FStarPUDefaultAlign::StructAlign) FRotationCellPODCore {
MortonIndex mortonIndex;
int coordinates[3];
};
template <int P>
struct alignas(FStarPUDefaultAlign::StructAlign) FRotationCellPODPole {
//< Size of multipole vector
static const int MultipoleSize = ((P+2)*(P+1))/2; // Artimethique suite (n+1)*n/2
//< Multipole vector (static memory)
FComplex multipole_exp[MultipoleSize]; //< For multipole extenssion
};
template <int P>
struct alignas(FStarPUDefaultAlign::StructAlign) FRotationCellPODLocal {
//< Size of local vector
static const int LocalSize = ((P+2)*(P+1))/2; // Artimethique suite (n+1)*n/2
//< Local vector (static memory)
FComplex local_exp[LocalSize]; //< For local extenssion
};
template <int P>
class FRotationCellPOD
{
FRotationCellPODCore* symb;
FRotationCellPODPole<P>* up;
FRotationCellPODLocal<P>* down;
public:
FRotationCellPOD(FRotationCellPODCore* inSymb, FRotationCellPODPole<P>* inUp,
FRotationCellPODLocal<P>* inDown): symb(inSymb), up(inUp), down(inDown){
}
FRotationCellPOD()
: symb(nullptr), up(nullptr), down(nullptr){
}
/** To get the morton index */
MortonIndex getMortonIndex() const {
return symb->mortonIndex;
}
/** To set the morton index */
void setMortonIndex(const MortonIndex inMortonIndex) {
symb->mortonIndex = inMortonIndex;
}
/** To get the position */
FTreeCoordinate getCoordinate() const {
return FTreeCoordinate(symb->coordinates[0],
symb->coordinates[1], symb->coordinates[2]);
}
/** To set the position */
void setCoordinate(const FTreeCoordinate& inCoordinate) {
symb->coordinates[0] = inCoordinate.getX();
symb->coordinates[1] = inCoordinate.getY();
symb->coordinates[2] = inCoordinate.getZ();
}
/** To set the position from 3 FReals */
void setCoordinate(const int inX, const int inY, const int inZ) {
symb->coordinates[0] = inX;
symb->coordinates[1] = inY;
symb->coordinates[2] = inZ;
}
/** Get Multipole */
const FComplex* getMultipole() const
{ return up->multipole_exp;
}
/** Get Local */
const FComplex* getLocal() const{
return down->local_exp;
}
/** Get Multipole */
FComplex* getMultipole(){
return up->multipole_exp;
}
/** Get Local */
FComplex* getLocal(){
return down->local_exp;
}
/** To get the leading dim of a vec */
int getVectorSize() const{
return down->VectorSize;
}
/** Make it like the begining */
void resetToInitialState(){
for(int idx = 0 ; idx < up->MultipoleSize ; ++idx){
up->multipole_exp[idx].setRealImag(FReal(0.0), FReal(0.0));
}
for(int idx = 0 ; idx < down->LocalSize ; ++idx){
down->local_exp[idx].setRealImag(FReal(0.0), FReal(0.0));
}
}
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
template <class BufferWriterClass>
void serializeUp(BufferWriterClass& buffer) const{
buffer.write(up->multipole_exp, up->MultipoleSize);
}
template <class BufferReaderClass>
void deserializeUp(BufferReaderClass& buffer){
buffer.fillArray(up->multipole_exp, up->MultipoleSize);
}
template <class BufferWriterClass>
void serializeDown(BufferWriterClass& buffer) const{
buffer.write(down->local_exp, down->LocalSize);
}
template <class BufferReaderClass>
void deserializeDown(BufferReaderClass& buffer){
buffer.fillArray(down->local_exp, down->LocalSize);
}
///////////////////////////////////////////////////////
// to extend Serializable
///////////////////////////////////////////////////////
template <class BufferWriterClass>
void save(BufferWriterClass& buffer) const{
buffer << symb->mortonIndex << symb->coordinates[0]
<< symb->coordinates[1] << symb->coordinates[2];
buffer.write(up->multipole_exp, up->MultipoleSize);
buffer.write(down->local_exp, down->LocalSize);
}
template <class BufferReaderClass>
void restore(BufferReaderClass& buffer){
buffer >> symb->mortonIndex >> symb->coordinates[0]
>> symb->coordinates[1] >> symb->coordinates[2];
buffer.fillArray(up->multipole_exp, up->MultipoleSize);
buffer.fillArray(down->local_exp, down->LocalSize);
}
int getSavedSize() const {
return int(sizeof(FComplex)*(up->MultipoleSize + down->LocalSize) + sizeof(symb->mortonIndex) + sizeof(symb->coordinates[0]) +
sizeof(symb->coordinates[1]) + sizeof(symb->coordinates[2]));
}
int getSavedSizeUp() const {
return ((int) sizeof(FComplex)) * (up->MultipoleSize);
}
int getSavedSizeDown() const {
return ((int) sizeof(FComplex)) * (down->LocalSize);
}
};
#endif // FROTATIONCELLPOD_HPP
......@@ -12,7 +12,7 @@
#include "../../Src/Kernels/P2P/FP2PParticleContainer.hpp"
#include "../../Src/Kernels/Rotation/FRotationKernel.hpp"
#include "../../Src/Kernels/Rotation/FRotationCell.hpp"
#include "../../Src/GroupTree/Rotation/FRotationCellPOD.hpp"
#include "../../Src/Utils/FMath.hpp"
#include "../../Src/Utils/FMemUtils.hpp"
......@@ -34,17 +34,10 @@
#include "../../Src/Utils/FParameterNames.hpp"
#include "../../Src/Components/FTestParticleContainer.hpp"
#include "../../Src/Components/FTestCell.hpp"
#include "../../Src/Components/FTestKernels.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
#include <memory>
int main(int argc, char* argv[]){
const FParameterNames LocalOptionBlocSize { {"-bs"}, "The size of the block of the blocked tree"};
const FParameterNames LocalOptionNoValidate { {"-no-validation"}, "To avoid comparing with direct computation"};
......@@ -55,12 +48,17 @@ int main(int argc, char* argv[]){
// Initialize the types
static const int P = 9;
typedef FRotationCell<P> GroupCellClass;
typedef FRotationCellPODCore GroupCellSymbClass;
typedef FRotationCellPODPole<P> GroupCellUpClass;
typedef FRotationCellPODLocal<P> GroupCellDownClass;
typedef FRotationCellPOD<P> GroupCellClass;
typedef FP2PGroupParticleContainer<> GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupContainerClass, 5, FReal> GroupOctreeClass;
typedef FGroupTree< GroupCellClass, GroupCellSymbClass, GroupCellUpClass, GroupCellDownClass, GroupContainerClass, 1, 4, FReal> GroupOctreeClass;
#ifdef ScalFMM_USE_STARPU
typedef FStarPUAllYesCapacities<FRotationKernel< GroupCellClass, GroupContainerClass , P>> GroupKernelClass;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm;
typedef FStarPUCpuWrapper<typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass> GroupCpuWrapper;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupCpuWrapper > GroupAlgorithm;
#elif defined(ScalFMM_USE_OMP4)
typedef FRotationKernel< GroupCellClass, GroupContainerClass , P> GroupKernelClass;
// Set the number of threads
......@@ -115,7 +113,7 @@ int main(int argc, char* argv[]){
FReal*const allPosY = const_cast<FReal*>( allParticles.getPositions()[1]);
FReal*const allPosZ = const_cast<FReal*>( allParticles.getPositions()[2]);
groupedTree.forEachCellLeaf<FP2PGroupParticleContainer<> >([&](GroupCellClass* cellTarget, FP2PGroupParticleContainer<> * leafTarget){
groupedTree.forEachCellLeaf<FP2PGroupParticleContainer<> >([&](GroupCellClass cellTarget, FP2PGroupParticleContainer<> * leafTarget){
const FReal*const physicalValues = leafTarget->getPhysicalValues();
const FReal*const posX = leafTarget->getPositions()[0];
const FReal*const posY = leafTarget->getPositions()[1];
......@@ -153,7 +151,7 @@ int main(int argc, char* argv[]){
FMath::FAccurater potentialDiff;
FMath::FAccurater fx, fy, fz;
offsetParticles = 0;
groupedTree.forEachCellLeaf<FP2PGroupParticleContainer<> >([&](GroupCellClass* cellTarget, FP2PGroupParticleContainer<> * leafTarget){
groupedTree.forEachCellLeaf<FP2PGroupParticleContainer<> >([&](GroupCellClass cellTarget, FP2PGroupParticleContainer<> * leafTarget){
const FReal*const potentials = leafTarget->getPotentials();
const FReal*const forcesX = leafTarget->getForcesX();
const FReal*const forcesY = leafTarget->getForcesY();
......
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