diff --git a/Examples/changeFmaFormat.cpp b/Examples/changeFmaFormat.cpp index 45932744e733e6d5090c0bd19c549872cf1868eb..0b378929fc9f737b310889d82d4128b5792f0a3f 100644 --- a/Examples/changeFmaFormat.cpp +++ b/Examples/changeFmaFormat.cpp @@ -60,10 +60,10 @@ int main(int argc, char ** argv){ const FSize NbPoints = loader.getNumberOfParticles(); const unsigned int nbData = loader.getNbRecordPerline() ; - const FSize arraySize =nbData*NbPoints; + const FSize arraySize = nbData*NbPoints; - FReal * particles = new FReal[arraySize] ; - std::memset(particles,0,arraySize*sizeof(FReal)); + FReal * particles = new FReal[arraySize] {}; + // std::memset(particles,0,arraySize*sizeof(FReal)); FSize j = 0 ; for(FSize idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ diff --git a/Examples/sharedMemoryInterpolationFMM.hpp b/Examples/sharedMemoryInterpolationFMM.hpp index 612fa63033f55b5512c7039b4994cd52fa18ac05..7df1cfcb9204a5b3cdfd2382975d8964e39fa7af 100644 --- a/Examples/sharedMemoryInterpolationFMM.hpp +++ b/Examples/sharedMemoryInterpolationFMM.hpp @@ -94,16 +94,16 @@ int main(int argc, char* argv[]) const std::string defaultFile(SCALFMMDataPath+"unitCubeXYZQ100.bfma" ); - const std::string filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, defaultFile.c_str()); - const unsigned int TreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeHeight.options, 5); - const unsigned int SubTreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeSubHeight.options, 2); + const std::string filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, defaultFile.c_str()); + const int TreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeHeight.options, 5); + const int SubTreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeSubHeight.options, 2); #ifdef _OPENMP const unsigned int NbThreads = FParameters::getValue(argc, argv, FParameterDefinitions::NbThreads.options, omp_get_max_threads()); omp_set_num_threads(NbThreads); std::cout << "\n>> Using " << NbThreads << " threads.\n" << std::endl; #else - const unsigned int NbThreads = FParameters::getValue(argc, argv, FParameterDefinitions::NbThreads.options, 1); + const int NbThreads = FParameters::getValue(argc, argv, FParameterDefinitions::NbThreads.options, 1); std::cout << "\n>> Sequential version.\n" << std::endl; #endif // diff --git a/Src/Containers/FOctree.hpp b/Src/Containers/FOctree.hpp index 57a1dc87b4103534d7e165b97da516eaeaad4ac9..40ef189d682eaa18b0f1ccb35f3cb4d43ad6a48a 100644 --- a/Src/Containers/FOctree.hpp +++ b/Src/Containers/FOctree.hpp @@ -42,11 +42,11 @@ template<class FReal, class CellClass, class ContainerClass, class LeafClass_, c class FOctree : public FNoCopyable { public: using FRealType = FReal; - using CellClassType = CellClass; + using CellClassType = CellClass; using ContainerClassType = ContainerClass; //< The type of the container used to store particles in the Octree - using LeafClassType = LeafClass_; //< The type of the Leaf used in the Octree - using LeafClass = LeafClass_; //< The type of the Leaf used in the Octree - using LeafClass_T = LeafClass_; //< The type of the Leaf used in the Octree + using LeafClassType = LeafClass_; //< The type of the Leaf used in the Octree + using LeafClass = LeafClass_; //< The type of the Leaf used in the Octree + using LeafClass_T = LeafClass_; //< The type of the Leaf used in the Octree protected: typedef FOctree<FReal, CellClass , ContainerClass, LeafClass, CellAllocatorClass> OctreeType; @@ -55,10 +55,10 @@ protected: FAbstractSubOctree<FReal, CellClass , ContainerClass, LeafClass, CellAllocatorClass>* root; //< root suboctree - FReal*const boxWidthAtLevel; //< to store the width of each boxs at all levels + FReal*const boxWidthAtLevel; //< to store the width of each box at all levels - const int height; //< tree height - const int subHeight; //< tree height + const int height; //< Total tree height + const int subHeight; //< sub tree height const int leafIndex; //< index of leaf int array const FPoint<FReal> boxCenter; //< the space system center diff --git a/Src/Kernels/Chebyshev/FChebCell.hpp b/Src/Kernels/Chebyshev/FChebCell.hpp index 5fa1910bdf0b9c7c8309a0998e4a9a602e0b7515..4b7a0ccf84bd86b16dc1529a83de406ff26810ca 100644 --- a/Src/Kernels/Chebyshev/FChebCell.hpp +++ b/Src/Kernels/Chebyshev/FChebCell.hpp @@ -4,10 +4,10 @@ #define FCHEBCELL_HPP #include <iostream> -#include "../../Components/FBasicCell.hpp" +#include "Components/FBasicCell.hpp" -#include "./FChebTensor.hpp" -#include "../../Extensions/FExtendCellType.hpp" +#include "FChebTensor.hpp" +#include "Extensions/FExtendCellType.hpp" /** * @author Matthias Messner (matthias.messner@inria.fr) @@ -22,7 +22,7 @@ class FChebCell : public FBasicCell, public FAbstractSendable { // nnodes = ORDER^3 // we multiply by 2 because we store the Multipole expansion end the compressed one. - static const int VectorSize = TensorTraits<ORDER>::nnodes * 2; + static constexpr int VectorSize = TensorTraits<ORDER>::nnodes * 2; public: @@ -60,7 +60,7 @@ public: }; - using multipole_t = exp_impl<class multipole_tag, NRHS>; + using multipole_t = exp_impl<class multipole_tag, NRHS>; using local_expansion_t = exp_impl<class local_expansion_tag, NLHS>; multipole_t m_data {}; diff --git a/Src/Kernels/Chebyshev/FChebInterface.h b/Src/Kernels/Chebyshev/FChebInterface.h index 293b1b7369ebf08d994ebaafde8f87568f68182a..c873f640aafcb0e8c92c9ca64ca11362a63aa153 100644 --- a/Src/Kernels/Chebyshev/FChebInterface.h +++ b/Src/Kernels/Chebyshev/FChebInterface.h @@ -8,7 +8,7 @@ #ifndef FCHEBINTERFACE_H #define FCHEBINTERFACE_H - +#include "Utils/FGlobal.hpp" //To access leaf datas struct FChebLeaf_struct; diff --git a/Src/Kernels/Interpolation/FInterpTensor.hpp b/Src/Kernels/Interpolation/FInterpTensor.hpp index 1fcc0ecd59ab387e843eae86fb932bb233a9d5cd..ab2166e2a691595220a10d8163d70fb6a833d723 100644 --- a/Src/Kernels/Interpolation/FInterpTensor.hpp +++ b/Src/Kernels/Interpolation/FInterpTensor.hpp @@ -2,9 +2,9 @@ #ifndef FINTERPTENSOR_HPP #define FINTERPTENSOR_HPP -#include "../../Utils/FMath.hpp" +#include "Utils/FMath.hpp" -#include "./FInterpMapping.hpp" +#include "FInterpMapping.hpp" /** diff --git a/Src/Kernels/Uniform/FUnifCell.hpp b/Src/Kernels/Uniform/FUnifCell.hpp index a56f4ceaa34f154fa0f226035f7eef5bcaa73024..e7b7ea588a5b7030b7e5c8a63b7e4a34235ca196 100644 --- a/Src/Kernels/Uniform/FUnifCell.hpp +++ b/Src/Kernels/Uniform/FUnifCell.hpp @@ -6,9 +6,9 @@ #include "Utils/stdComplex.hpp" -#include "./FUnifTensor.hpp" -#include "../../Components/FBasicCell.hpp" -#include "../../Extensions/FExtendCellType.hpp" +#include "FUnifTensor.hpp" +#include "Components/FBasicCell.hpp" +#include "Extensions/FExtendCellType.hpp" /** @@ -26,114 +26,46 @@ template < class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FUnifCell : public FBasicCell, public FAbstractSendable { - static const int VectorSize = TensorTraits<ORDER>::nnodes; - static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); + static const int VectorSize = TensorTraits<ORDER>::nnodes; + static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); public: - template<class Tag, std::size_t N> - struct exp_impl { - FReal exp[N * NVALS * VectorSize]; //< Multipole expansion - // Multipole expansion in Fourier space - stdComplex<FReal> transformed_exp[N * NVALS * TransformedVectorSize]; - - const FReal* get(const int inRhs) const - { return this->exp + inRhs*VectorSize; } - FReal* get(const int inRhs) - { return this->exp + inRhs*VectorSize; } - const stdComplex<FReal>* getTransformed(const int inRhs) const - { return this->transformed_exp + inRhs*TransformedVectorSize; } - stdComplex<FReal>* getTransformed(const int inRhs) - { return this->transformed_exp + inRhs*TransformedVectorSize; } - - constexpr int getVectorSize() const { - return VectorSize; - } - - // to extend FAbstractSendable - template <class BufferWriterClass> - void serialize(BufferWriterClass& buffer) const{ - buffer.write(this->exp, VectorSize*NVALS*N); - buffer.write(this->transformed_exp, TransformedVectorSize*NVALS*N); - } - - template <class BufferReaderClass> - void deserialize(BufferReaderClass& buffer){ - buffer.fillArray(this->exp, VectorSize*NVALS*N); - buffer.fillArray(this->transformed_exp, TransformedVectorSize*NVALS*N); - } - - /////////////////////////////////////////////////////// - // to extend Serializable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - buffer.write(this->exp, VectorSize*NVALS*NRHS); - buffer.write(this->transformed_exp, TransformedVectorSize*NVALS*NRHS); - } - - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - buffer.fillArray(this->exp, VectorSize*NVALS*NRHS); - buffer.fillArray(this->transformed_exp, TransformedVectorSize*NVALS*NRHS); - } - - FSize getSavedSize() const { - return N * NVALS * VectorSize * (FSize) sizeof(FReal) - + N * NVALS * TransformedVectorSize * (FSize) sizeof(stdComplex<FReal>); - } - }; - - using multipole_t = exp_impl<class multipole_tag, NRHS>; - using local_expansion_t = exp_impl<class local_expansion_tag, NLHS>; - - multipole_t m_data {}; - local_expansion_t l_data {}; - - bool hasMultipoleData() const noexcept { - return true; - } - bool hasLocalExpansionData() const noexcept { - return true; - } + template<class Tag, std::size_t N> + struct exp_impl { + /// Multipole expansion in Real space + FReal exp[N * NVALS * VectorSize]; //< Multipole expansion + /// Multipole expansion in Fourier space + stdComplex<FReal> transformed_exp[N * NVALS * TransformedVectorSize]; - - multipole_t& getMultipoleData() noexcept { - return m_data; - } - const multipole_t& getMultipoleData() const noexcept { - return m_data; + + const FReal* get(const int inRhs) const + { return this->exp + inRhs*VectorSize; } + + FReal* get(const int inRhs) + { return this->exp + inRhs*VectorSize; } + + const stdComplex<FReal>* getTransformed(const int inRhs) const + { return this->transformed_exp + inRhs*TransformedVectorSize; } + stdComplex<FReal>* getTransformed(const int inRhs) + { return this->transformed_exp + inRhs*TransformedVectorSize; } - local_expansion_t& getLocalExpansionData() noexcept { - return l_data; + constexpr int getVectorSize() const { + return VectorSize; } - const local_expansion_t& getLocalExpansionData() const noexcept { - return l_data; - } - - /////////////////////////////////////////////////////// // to extend FAbstractSendable - /////////////////////////////////////////////////////// template <class BufferWriterClass> - void serializeUp(BufferWriterClass& buffer) const{ - m_data.serialize(buffer); + void serialize(BufferWriterClass& buffer) const{ + buffer.write(this->exp, VectorSize*NVALS*N); + buffer.write(this->transformed_exp, TransformedVectorSize*NVALS*N); } template <class BufferReaderClass> - void deserializeUp(BufferReaderClass& buffer){ - m_data.deserialize(buffer); - } - - template <class BufferWriterClass> - void serializeDown(BufferWriterClass& buffer) const{ - l_data.serialize(buffer); - } - - template <class BufferReaderClass> - void deserializeDown(BufferReaderClass& buffer){ - l_data.deserialize(buffer); + void deserialize(BufferReaderClass& buffer){ + buffer.fillArray(this->exp, VectorSize*NVALS*N); + buffer.fillArray(this->transformed_exp, TransformedVectorSize*NVALS*N); } /////////////////////////////////////////////////////// @@ -141,72 +73,145 @@ public: /////////////////////////////////////////////////////// template <class BufferWriterClass> void save(BufferWriterClass& buffer) const{ - FBasicCell::save(buffer); - m_data.save(buffer); - l_data.save(buffer); + buffer.write(this->exp, VectorSize*NVALS*NRHS); + buffer.write(this->transformed_exp, TransformedVectorSize*NVALS*NRHS); } template <class BufferReaderClass> void restore(BufferReaderClass& buffer){ - FBasicCell::restore(buffer); - m_data.restore(buffer); - l_data.restore(buffer); + buffer.fillArray(this->exp, VectorSize*NVALS*NRHS); + buffer.fillArray(this->transformed_exp, TransformedVectorSize*NVALS*NRHS); } FSize getSavedSize() const { - return m_data.getSavedSize() + l_data.getSavedSize() - + FBasicCell::getSavedSize(); - } - - FSize getSavedSizeUp() const { - return m_data.getSavedSize(); - } - - FSize getSavedSizeDown() const { - return l_data.getSavedSize(); - } - - template <class StreamClass> - friend StreamClass& operator<<(StreamClass& output, const FUnifCell<FReal,ORDER, NRHS, NLHS, NVALS>& cell){ - output << "Multipole exp NRHS " << NRHS - << " NVALS " << NVALS - << " VectorSize " << cell.getVectorSize() - << '\n'; - for (int rhs= 0 ; rhs < NRHS ; ++rhs) { - const FReal* pole = cell.getMultipole(rhs); - for (int val= 0 ; val < NVALS ; ++val) { - output<< " val : " << val << " exp: " ; - for (int i= 0 ; i < cell.getVectorSize() ; ++i) { - output<< pole[i] << " "; - } - output << std::endl; - } - } - return output; - } + return N * NVALS * VectorSize * (FSize) sizeof(FReal) + + N * NVALS * TransformedVectorSize * (FSize) sizeof(stdComplex<FReal>); + } + }; + + using multipole_t = exp_impl<class multipole_tag, NRHS>; + using local_expansion_t = exp_impl<class local_expansion_tag, NLHS>; + + multipole_t m_data {}; + local_expansion_t l_data {}; + + bool hasMultipoleData() const noexcept { + return true; + } + bool hasLocalExpansionData() const noexcept { + return true; + } + + + multipole_t& getMultipoleData() noexcept { + return m_data; + } + const multipole_t& getMultipoleData() const noexcept { + return m_data; + } + + local_expansion_t& getLocalExpansionData() noexcept { + return l_data; + } + const local_expansion_t& getLocalExpansionData() const noexcept { + return l_data; + } + + + /////////////////////////////////////////////////////// + // to extend FAbstractSendable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void serializeUp(BufferWriterClass& buffer) const{ + m_data.serialize(buffer); + } + + template <class BufferReaderClass> + void deserializeUp(BufferReaderClass& buffer){ + m_data.deserialize(buffer); + } + + template <class BufferWriterClass> + void serializeDown(BufferWriterClass& buffer) const{ + l_data.serialize(buffer); + } + + template <class BufferReaderClass> + void deserializeDown(BufferReaderClass& buffer){ + l_data.deserialize(buffer); + } + + /////////////////////////////////////////////////////// + // to extend Serializable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FBasicCell::save(buffer); + m_data.save(buffer); + l_data.save(buffer); + } + + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FBasicCell::restore(buffer); + m_data.restore(buffer); + l_data.restore(buffer); + } + + FSize getSavedSize() const { + return m_data.getSavedSize() + l_data.getSavedSize() + + FBasicCell::getSavedSize(); + } + + FSize getSavedSizeUp() const { + return m_data.getSavedSize(); + } + + FSize getSavedSizeDown() const { + return l_data.getSavedSize(); + } + + template <class StreamClass> + friend StreamClass& operator<<(StreamClass& output, const FUnifCell<FReal,ORDER, NRHS, NLHS, NVALS>& cell){ + output << "Multipole exp NRHS " << NRHS + << " NVALS " << NVALS + << " VectorSize " << cell.getVectorSize() + << '\n'; + for (int rhs= 0 ; rhs < NRHS ; ++rhs) { + const FReal* pole = cell.getMultipole(rhs); + for (int val= 0 ; val < NVALS ; ++val) { + output<< " val : " << val << " exp: " ; + for (int i= 0 ; i < cell.getVectorSize() ; ++i) { + output<< pole[i] << " "; + } + output << std::endl; + } + } + return output; + } }; template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FTypedUnifCell : public FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>, public FExtendCellType { public: - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::save(buffer); - FExtendCellType::save(buffer); - } - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::restore(buffer); - FExtendCellType::restore(buffer); - } - void resetToInitialState(){ - FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); - FExtendCellType::resetToInitialState(); - } - FSize getSavedSize() const { - return FExtendCellType::getSavedSize() + FUnifCell<FReal, ORDER,NRHS,NLHS,NVALS>::getSavedSize(); - } + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::save(buffer); + FExtendCellType::save(buffer); + } + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::restore(buffer); + FExtendCellType::restore(buffer); + } + void resetToInitialState(){ + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); + FExtendCellType::resetToInitialState(); + } + FSize getSavedSize() const { + return FExtendCellType::getSavedSize() + FUnifCell<FReal, ORDER,NRHS,NLHS,NVALS>::getSavedSize(); + } }; #endif //FUNIFCELL_HPP diff --git a/Src/Kernels/Uniform/FUnifTensor.hpp b/Src/Kernels/Uniform/FUnifTensor.hpp index 00f334edb0f46d66862d2304afe853b8fd36467d..23320da976028faa69fdabded9b2b3ea4faa37ae 100644 --- a/Src/Kernels/Uniform/FUnifTensor.hpp +++ b/Src/Kernels/Uniform/FUnifTensor.hpp @@ -4,7 +4,7 @@ #ifndef FUNIFTENSOR_HPP #define FUNIFTENSOR_HPP -#include "../../Utils/FMath.hpp" +#include "Utils/FMath.hpp" #include "FUnifRoots.hpp" #include "../Interpolation/FInterpTensor.hpp" @@ -81,17 +81,26 @@ class FUnifTensor : public FInterpTensor<FReal, ORDER,FUnifRoots<FReal, ORDER>> // Convention: // lj=order-1 & li=0:order-1 => li-lj=1-order:0 // lj=1 & li=0:order-1 => li-lj=1:order-1 - if(l<ORDER-1) lj=ORDER-1; else lj=0; + if(l<ORDER-1) { + lj=ORDER-1;} + else{ + lj=0;} li=(l-(ORDER-1))+lj; for(unsigned int m=0; m<2*ORDER-1; ++m){ - if(m<ORDER-1) mj=ORDER-1; else mj=0; + if(m<ORDER-1){ + mj=ORDER-1;} + else { + mj=0;} mi=(m-(ORDER-1))+mj; for(unsigned int n=0; n<2*ORDER-1; ++n){ - if(n<ORDER-1) nj=ORDER-1; else nj=0; + if(n<ORDER-1){ + nj=ORDER-1;} + else{ + nj=0;} ni=(n-(ORDER-1))+nj; NodeIdsPairs[ido][0]=li*ORDER*ORDER + mi*ORDER + ni;