MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit e196816b authored by Quentin Khan's avatar Quentin Khan
Browse files

Prepare uniform kernel for the new interface

parent f55f61ac
......@@ -39,66 +39,68 @@ public:
using FBase::M2L;
using FBase::L2L;
using FBase::P2P;
/**
* \brief Adaptive P2M
*
* Computes the leaf box width for every leaf. The uniform one relies on the
* fact that all leaves are at the same level to pre-compute this width.
*/
template<class SymbolicData>
void P2M(typename CellClass::multipole_t* const LeafMultipole,
const SymbolicData* const LeafSymbData,
const ContainerClass* const SourceParticles)
{
FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafSymbData->depth);
const FPoint<FReal> LeafCellCenter(
FBase::getCellCenter(LeafSymbData->getCoordinate(),
static_cast<int>(LeafSymbData->depth)));
FBase::Interpolator->applyP2M(LeafCellCenter, leafBoxWidth,
LeafMultipole->getMultipole(0), SourceParticles);
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 2) apply Discrete Fourier Transform
this->M2LHandler.applyZeroPaddingAndDFT(LeafMultipole->getMultipole(idxRhs),
LeafMultipole->getTransformedMultipole(idxRhs));
}
}
/**
* \brief Adaptive L2P
*
* Computes the leaf box width for every leaf. The uniform one relies on the
* fact that all leaves are at the same level to pre-compute this width.
*/
template<class SymbolicData>
void L2P(const typename CellClass::local_expansion_t* const LeafCell,
const SymbolicData* const LeafSymbData,
ContainerClass* const TargetParticles)
{
FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafSymbData->depth);
const FPoint<FReal> LeafCellCenter(
FBase::getCellCenter(LeafSymbData->getCoordinate(),
static_cast<int>(LeafSymbData->depth)));
FReal localExp[NVALS*FBase::nnodes];
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 1) Apply Inverse Discete Fourier Transform
FBase::M2LHandler.unapplyZeroPaddingAndDFT(LeafCell->getTransformedLocal(idxRhs),
localExp + idxRhs*FBase::nnodes);
FBlas::add(FBase::nnodes,const_cast<FReal*>(LeafCell->getLocal(idxRhs)),localExp + idxRhs*FBase::nnodes);
}
// 2.a) apply Sx
FBase::Interpolator->applyL2P(LeafCellCenter, leafBoxWidth,
localExp, TargetParticles);
// 2.b) apply Px (grad Sx)
FBase::Interpolator->applyL2PGradient(LeafCellCenter, leafBoxWidth,
localExp, TargetParticles);
}
using FBase::P2M;
using FBase::L2P;
// /**
// * \brief Adaptive P2M
// *
// * Computes the leaf box width for every leaf. The uniform one relies on the
// * fact that all leaves are at the same level to pre-compute this width.
// */
// template<class SymbolicData>
// void P2M(typename CellClass::multipole_t* const LeafMultipole,
// const SymbolicData* const LeafSymbData,
// const ContainerClass* const SourceParticles)
// {
// FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafSymbData->depth);
// const FPoint<FReal> LeafCellCenter(
// FBase::getCellCenter(LeafSymbData->getCoordinate(),
// static_cast<int>(LeafSymbData->depth)));
// FBase::Interpolator->applyP2M(LeafCellCenter, leafBoxWidth,
// LeafMultipole->getMultipole(0), SourceParticles);
// for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// // 2) apply Discrete Fourier Transform
// this->M2LHandler.applyZeroPaddingAndDFT(LeafMultipole->getMultipole(idxRhs),
// LeafMultipole->getTransformedMultipole(idxRhs));
// }
// }
// /**
// * \brief Adaptive L2P
// *
// * Computes the leaf box width for every leaf. The uniform one relies on the
// * fact that all leaves are at the same level to pre-compute this width.
// */
// template<class SymbolicData>
// void L2P(const typename CellClass::local_expansion_t* const LeafCell,
// const SymbolicData* const LeafSymbData,
// ContainerClass* const TargetParticles)
// {
// FReal leafBoxWidth = FBase::BoxWidth / FReal(1 << LeafSymbData->depth);
// const FPoint<FReal> LeafCellCenter(
// FBase::getCellCenter(LeafSymbData->getCoordinate(),
// static_cast<int>(LeafSymbData->depth)));
// FReal localExp[NVALS*FBase::nnodes];
// for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// // 1) Apply Inverse Discete Fourier Transform
// FBase::M2LHandler.unapplyZeroPaddingAndDFT(LeafCell->getTransformedLocal(idxRhs),
// localExp + idxRhs*FBase::nnodes);
// FBlas::add(FBase::nnodes,const_cast<FReal*>(LeafCell->getLocal(idxRhs)),localExp + idxRhs*FBase::nnodes);
// }
// // 2.a) apply Sx
// FBase::Interpolator->applyL2P(LeafCellCenter, leafBoxWidth,
// localExp, TargetParticles);
// // 2.b) apply Px (grad Sx)
// FBase::Interpolator->applyL2PGradient(LeafCellCenter, leafBoxWidth,
// localExp, TargetParticles);
// }
/**
* \brief P2L operator
......@@ -268,30 +270,6 @@ public:
}
};
void P2M(CellClass* const LeafCell,
const ContainerClass* const SourceParticles)
{
CellData symb {LeafCell->getLevel(), static_cast<std::size_t>(LeafCell->getMortonIndex())};
this->P2M(LeafCell->up, &symb, SourceParticles);
}
void L2P(const CellClass* const LeafCell,
ContainerClass* const TargetParticles)
{
CellData symb {LeafCell->getLevel(), static_cast<std::size_t>(LeafCell->getMortonIndex())};
this->L2P(LeafCell->down, &symb, TargetParticles);
}
void P2L(CellClass* const local, const ContainerClass* const particles) {
CellData symb {local->getLevel(), static_cast<std::size_t>(local->getMortonIndex())};
return this->P2L(local->down, &symb , particles);
}
void M2P(const CellClass* const pole, ContainerClass* const particles) {
CellData symb {pole->getLevel(), static_cast<std::size_t>(pole->getMortonIndex())};
return this->M2P(pole->up, &symb , particles);
}
};
......
......@@ -78,9 +78,9 @@ protected:
BoxCorner.getZ() + (FReal(Coordinate.getZ()) + FReal(.5)) * BoxWidthLeaf);
}
/**
/**
* @brief Return the position of the center of a cell from its tree
* coordinate
* coordinate
* @param FTreeCoordinate
* @param inLevel the current level of Cell
*/
......@@ -88,14 +88,14 @@ protected:
{
//Set the boxes width needed
FReal widthAtCurrentLevel = BoxWidthLeaf*FReal(1 << (TreeHeight-(inLevel+1)));
FReal widthAtCurrentLevel = BoxWidthLeaf*FReal(1 << (TreeHeight-(inLevel+1)));
FReal widthAtCurrentLevelDiv2 = widthAtCurrentLevel/FReal(2.);
//Set the center real coordinates from box corner and widths.
FReal X = BoxCorner.getX() + FReal(coordinate.getX())*widthAtCurrentLevel + widthAtCurrentLevelDiv2;
FReal Y = BoxCorner.getY() + FReal(coordinate.getY())*widthAtCurrentLevel + widthAtCurrentLevelDiv2;
FReal Z = BoxCorner.getZ() + FReal(coordinate.getZ())*widthAtCurrentLevel + widthAtCurrentLevelDiv2;
return FPoint<FReal>(X,Y,Z);
}
......@@ -127,46 +127,6 @@ public:
const InterpolatorClass * getPtrToInterpolator() const
{ return Interpolator.getPtr(); }
virtual void P2M(CellClass* const LeafCell,
const ContainerClass* const SourceParticles) = 0;
virtual void M2M(CellClass* const FRestrict ParentCell,
const CellClass*const FRestrict *const FRestrict ChildCells,
const int TreeLevel) = 0;
virtual void M2L(CellClass* const FRestrict TargetCell, const CellClass* SourceCells[],
const int neighborPositions[], const int inSize, const int TreeLevel) = 0;
virtual void L2L(const CellClass* const FRestrict ParentCell,
CellClass* FRestrict *const FRestrict ChildCells,
const int TreeLevel) = 0;
virtual void L2P(const CellClass* const LeafCell,
ContainerClass* const TargetParticles) = 0;
virtual void P2P(const FTreeCoordinate& /* LeafCellCoordinate */, // needed for periodic boundary conditions
ContainerClass* const FRestrict TargetParticles,
const ContainerClass* const FRestrict /*SourceParticles*/,
ContainerClass* const NeighborSourceParticles[],
const int neighborPositions[],
const int /* size */) = 0;
virtual void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets,
const ContainerClass* const FRestrict /*inSources*/,
const ContainerClass* const inNeighbors[],
const int neighborPositions[],
const int /*inSize*/) = 0;
};
......
......@@ -57,6 +57,23 @@ public:
{ return this->transformed_multipole_exp + inRhs*TransformedVectorSize; }
FComplex<FReal>* getTransformedMultipole(const int inRhs)
{ return this->transformed_multipole_exp + inRhs*TransformedVectorSize; }
// to extend FAbstractSendable
template <class BufferWriterClass>
void serialize(BufferWriterClass& buffer) const{
buffer.write(this->multipole_exp, VectorSize*NVALS*NRHS);
buffer.write(this->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
}
template <class BufferReaderClass>
void deserialize(BufferReaderClass& buffer){
buffer.fillArray(this->multipole_exp, VectorSize*NVALS*NRHS);
buffer.fillArray(this->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
}
};
struct local_expansion_t {
......@@ -74,6 +91,18 @@ public:
FComplex<FReal>* getTransformedLocal(const int inRhs)
{ return this->transformed_local_exp + inRhs*TransformedVectorSize; }
// to extend FAbstractSendable
template <class BufferWriterClass>
void serialize(BufferWriterClass& buffer) const{
buffer.write(this->local_exp, VectorSize*NVALS*NLHS);
buffer.write(this->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
}
template <class BufferReaderClass>
void deserialize(BufferReaderClass& buffer){
buffer.fillArray(this->local_exp, VectorSize*NVALS*NLHS);
buffer.fillArray(this->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
}
};
multipole_t m_data;
......@@ -93,86 +122,50 @@ public:
~FUnifCell() {}
/** Get Multipole */
const FReal* getMultipole(const int inRhs) const
{ return this->up->getMultipole(inRhs); }
/** Get Local */
const FReal* getLocal(const int inRhs) const{
return this->down->local_exp + inRhs*VectorSize;
}
/** Get Multipole */
FReal* getMultipole(const int inRhs){
return this->up->getMultipole(inRhs);
bool hasMultipoleData() const noexcept {
return up != nullptr;
}
/** Get Local */
FReal* getLocal(const int inRhs){
return this->down->local_exp + inRhs*VectorSize;
bool hasLocalExpansionData() const noexcept {
return up != nullptr;
}
/** To get the leading dim of a vec */
int getVectorSize() const{
return VectorSize;
}
/** Get Transformed Multipole */
const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{
return this->up->transformed_multipole_exp + inRhs*TransformedVectorSize;
multipole_t& getMultipoleData() noexcept {
return *up;
}
/** Get Transformed Local */
const FComplex<FReal>* getTransformedLocal(const int inRhs) const{
return this->down->transformed_local_exp + inRhs*TransformedVectorSize;
const multipole_t& getMultipoleData() const noexcept {
return *up;
}
/** Get Transformed Multipole */
FComplex<FReal>* getTransformedMultipole(const int inRhs){
return this->up->transformed_multipole_exp + inRhs*TransformedVectorSize;
local_expansion_t& getLocalExpansionData() noexcept {
return *down;
}
/** Get Transformed Local */
FComplex<FReal>* getTransformedLocal(const int inRhs){
return this->down->transformed_local_exp + inRhs*TransformedVectorSize;
}
/** To get the leading dim of a vec */
int getTransformedVectorSize() const{
return TransformedVectorSize;
const local_expansion_t& getLocalExpansionData() const noexcept {
return *down;
}
/** Make it like the begining */
void resetToInitialState(){
memset(up->multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize);
memset(down->local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize);
memset(up->transformed_multipole_exp, 0,
sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize);
memset(down->transformed_local_exp, 0,
sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize);
}
///////////////////////////////////////////////////////
// to extend FAbstractSendable
///////////////////////////////////////////////////////
template <class BufferWriterClass>
void serializeUp(BufferWriterClass& buffer) const{
buffer.write(up->multipole_exp, VectorSize*NVALS*NRHS);
buffer.write(up->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
up->serialize(buffer);
}
template <class BufferReaderClass>
void deserializeUp(BufferReaderClass& buffer){
buffer.fillArray(up->multipole_exp, VectorSize*NVALS*NRHS);
buffer.fillArray(up->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
up->deserialize(buffer);
}
template <class BufferWriterClass>
void serializeDown(BufferWriterClass& buffer) const{
buffer.write(down->local_exp, VectorSize*NVALS*NLHS);
buffer.write(down->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
down->serialize(buffer);
}
template <class BufferReaderClass>
void deserializeDown(BufferReaderClass& buffer){
buffer.fillArray(down->local_exp, VectorSize*NVALS*NLHS);
buffer.fillArray(down->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
down->deserialize(buffer);
}
///////////////////////////////////////////////////////
......
......@@ -87,36 +87,32 @@ public:
{ }
void P2M(CellClass* const LeafCell,
template<class SymbolicData>
void P2M(typename CellClass::multipole_t* const LeafMultipole,
const SymbolicData* const LeafSymbData,
const ContainerClass* const SourceParticles)
override
{
const FPoint<FReal> LeafCellCenter(AbstractBaseClass::getLeafCellCenter(LeafCell->getCoordinate()));
// 1) apply Sy
AbstractBaseClass::Interpolator->applyP2M(LeafCellCenter, AbstractBaseClass::BoxWidthLeaf,
LeafCell->getMultipole(0), SourceParticles);
FReal leafBoxWidth = AbstractBaseClass::BoxWidth / FReal(1 << LeafSymbData->getLevel());
const FPoint<FReal> LeafCellCenter(
AbstractBaseClass::getCellCenter(LeafSymbData->getCoordinate(),
static_cast<int>(LeafSymbData->getLevel())));
AbstractBaseClass::Interpolator->applyP2M(LeafCellCenter, leafBoxWidth,
LeafMultipole->getMultipole(0), SourceParticles);
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 2) apply Discrete Fourier Transform
M2LHandler.applyZeroPaddingAndDFT(LeafCell->getMultipole(idxRhs),
LeafCell->getTransformedMultipole(idxRhs));
this->M2LHandler.applyZeroPaddingAndDFT(LeafMultipole->getMultipole(idxRhs),
LeafMultipole->getTransformedMultipole(idxRhs));
}
}
void M2M(CellClass* const FRestrict ParentCell,
const CellClass*const FRestrict *const FRestrict ChildCells,
const int TreeLevel)
override
{
std::array<const typename CellClass::multipole_t*, 8> child_multipoles;
std::transform(ChildCells, ChildCells+8, child_multipoles.data(),
[](const CellClass * data) {return data ? data->up : nullptr;});
this->M2M(ParentCell->up, child_multipoles.data(), TreeLevel);
}
void M2M(typename CellClass::multipole_t* const FRestrict ParentMultipole,
const typename CellClass::multipole_t*const FRestrict *const FRestrict ChildMultipoles,
const int /*TreeLevel*/)
override
{
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 1) apply Sy
......@@ -135,29 +131,12 @@ public:
}
void M2L(CellClass* const FRestrict TargetCell, const CellClass* SourceCells[],
const int neighborPositions[], const int inSize, const int TreeLevel)
override
{
const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel)));
const FReal scale(MatrixKernel->getScaleFactor(CellWidth));
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
FComplex<FReal> *const TransformedLocalExpansion = TargetCell->getTransformedLocal(idxRhs);
for(int idxExistingNeigh = 0 ; idxExistingNeigh < inSize ; ++idxExistingNeigh){
const int idxNeigh = neighborPositions[idxExistingNeigh];
M2LHandler.applyFC(idxNeigh, TreeLevel, scale,
SourceCells[idxExistingNeigh]->getTransformedMultipole(idxRhs),
TransformedLocalExpansion);
}
}
}
void M2L(typename CellClass::local_expansion_t * const FRestrict TargetExpansion,
const typename CellClass::multipole_t * const FRestrict SourceMultipoles[],
const int neighborPositions[], const int inSize, const int TreeLevel)
override
{
const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel)));
const FReal scale(MatrixKernel->getScaleFactor(CellWidth));
......@@ -175,22 +154,10 @@ public:
}
void L2L(const CellClass* const FRestrict ParentCell,
CellClass* FRestrict *const FRestrict ChildCells,
const int TreeLevel)
override
{
std::array<typename CellClass::local_expansion_t*, 8> child_expansions;
std::transform(ChildCells, ChildCells+8, child_expansions.data(),
[](CellClass * data) {return data ? data->down : nullptr;});
this->L2L(ParentCell->down, child_expansions.data(), TreeLevel);
}
void L2L(const typename CellClass::local_expansion_t * const FRestrict ParentExpansion,
typename CellClass::local_expansion_t * FRestrict * const FRestrict ChildExpansion,
const int /*TreeLevel*/)
override
{
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 1) Apply Inverse Discete Fourier Transform
......@@ -210,33 +177,31 @@ public:
}
void L2P(const CellClass* const LeafCell,
template<class SymbolicData>
void L2P(const typename CellClass::local_expansion_t* const LeafCell,
const SymbolicData* const LeafSymbData,
ContainerClass* const TargetParticles)
override
{
const FPoint<FReal> LeafCellCenter(AbstractBaseClass::getLeafCellCenter(LeafCell->getCoordinate()));
FReal leafBoxWidth = AbstractBaseClass::BoxWidth / FReal(1 << LeafSymbData->getLevel());
const FPoint<FReal> LeafCellCenter(
AbstractBaseClass::getCellCenter(LeafSymbData->getCoordinate(),
static_cast<int>(LeafSymbData->getLevel())));
FReal localExp[NVALS*AbstractBaseClass::nnodes];
for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){
// 1) Apply Inverse Discete Fourier Transform
M2LHandler.unapplyZeroPaddingAndDFT(LeafCell->getTransformedLocal(idxRhs),
this->M2LHandler.unapplyZeroPaddingAndDFT(LeafCell->getTransformedLocal(idxRhs),
localExp + idxRhs*AbstractBaseClass::nnodes);
FBlas::add(AbstractBaseClass::nnodes,const_cast<FReal*>(LeafCell->getLocal(idxRhs)),localExp + idxRhs*AbstractBaseClass::nnodes);
}
// 2.a) apply Sx
AbstractBaseClass::Interpolator->applyL2P(LeafCellCenter, AbstractBaseClass::BoxWidthLeaf,
localExp, TargetParticles);
AbstractBaseClass::Interpolator->applyL2P(LeafCellCenter, leafBoxWidth,
localExp, TargetParticles);
// 2.b) apply Px (grad Sx)
AbstractBaseClass::Interpolator->applyL2PGradient(LeafCellCenter, AbstractBaseClass::BoxWidthLeaf,
localExp, TargetParticles);
AbstractBaseClass::Interpolator->applyL2PGradient(LeafCellCenter, leafBoxWidth,
localExp, TargetParticles);
}
......
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