Commit c22ccd0a authored by BRAMAS Berenger's avatar BRAMAS Berenger

move to new periodic

parent b1d39835
......@@ -9,7 +9,7 @@ project(Lib_scalfmm)
set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})
ADD_DEFINITIONS(${ScaLFMM_CXX_FLAGS})
MESSAGE( ${ScaLFMM_CXX_FLAGS})
# Searching all cpp file
file(
GLOB_RECURSE
......
......@@ -34,14 +34,6 @@ class FMpiBufferReader : public FAbstractBufferReader {
std::unique_ptr<char[]> array; //< Allocated Array
int currentIndex;
/** Test and exit if not enought space */
void assertRemainingSpace(const size_t requestedSpace) const {
if(int(currentIndex + requestedSpace) > arrayCapacity){
printf("Error FMpiBufferReader has not enough space\n");
exit(0);
}
}
public :
/*Constructor with a default arrayCapacity of 512 bytes */
FMpiBufferReader(const MPI_Comm inComm, const int inCapacity = 512):
......@@ -97,7 +89,7 @@ public :
ClassType getValue(){
ClassType value;
int previousIndex = currentIndex;
seek(sizeof(value) + previousIndex);
seek(int(sizeof(value) + previousIndex));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm);
return value;
}
......@@ -107,7 +99,7 @@ public :
ClassType getValue(const int ind){
ClassType value;
int previousIndex = ind;
seek(sizeof(value)+ind);
seek(int(sizeof(value)+ind));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm);
return value;
}
......@@ -116,7 +108,7 @@ public :
template <class ClassType>
void fillValue(ClassType* const inValue){
int previousIndex = currentIndex;
seek(sizeof(ClassType) + previousIndex);
seek(int(sizeof(ClassType) + previousIndex));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inValue,1,FMpi::GetType(*inValue),comm);
}
......@@ -124,7 +116,7 @@ public :
template <class ClassType>
void fillArray(ClassType* const inArray, const int inSize){
int previousIndex = currentIndex;
seek(sizeof(ClassType) * inSize + previousIndex);
seek(int(sizeof(ClassType) * inSize + previousIndex));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inArray,inSize,FMpi::GetType(*inArray),comm);
}
......
......@@ -77,7 +77,6 @@ public:
/** Write data by packing cpy */
template <class ClassType>
void write(const ClassType& object){
//printf("Space need in the write : %d, index set on %d \n",sizeof(ClassType),currentIndex);
assertRemainingSpace(sizeof(ClassType));
MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &currentIndex, mpiComm);
}
......@@ -87,7 +86,6 @@ public:
*/
template <class ClassType>
void write(const ClassType&& object){
// printf("Space need in the write : %d \n",sizeof(ClassType));
assertRemainingSpace(sizeof(ClassType));
MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &currentIndex, mpiComm);
}
......@@ -108,7 +106,6 @@ public:
*/
template <class ClassType>
void write(const ClassType* const objects, const int inSize){
// printf("Space need in the write : %d, index set on %d, and capacity is %d \n",sizeof(ClassType)*inSize,currentIndex,arrayCapacity);
assertRemainingSpace(sizeof(ClassType) * inSize);
MPI_Pack( const_cast<ClassType*>(objects), inSize, FMpi::GetType(*objects), array.get(), arrayCapacity, &currentIndex, mpiComm);
}
......
......@@ -69,13 +69,13 @@ public:
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
static FAbstractAlgorithm* BuildAlgorithm(OctreeClass*const tree, KernelClass*const kernel,
const MPI_Comm mpiComm = (MPI_Comm)0, const bool isPeriodic = false,
const int periodicUpperlevel = 0, const int inPeriodicDirections = AllDirs){
const int periodicUpperlevel = 0){
#ifdef ScalFMM_USE_MPI
if(isPeriodic == false){
return new FFmmAlgorithmThreadProc<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(FMpi::FComm(mpiComm), tree, kernel);
}
else{
auto algo = new FFmmAlgorithmThreadProcPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(FMpi::FComm(mpiComm), tree, periodicUpperlevel, inPeriodicDirections);
auto algo = new FFmmAlgorithmThreadProcPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(FMpi::FComm(mpiComm), tree, periodicUpperlevel);
algo->setKernel(kernel);
return algo;
}
......@@ -84,7 +84,7 @@ public:
return new FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(tree, kernel);
}
else{
auto algo = new FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(tree, periodicUpperlevel, inPeriodicDirections);
auto algo = new FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(tree, periodicUpperlevel);
algo->setKernel(kernel);
return algo;
}
......
This diff is collapsed.
......@@ -129,7 +129,7 @@ int main(int argc, char ** argv){
}
else{
FmmClass algo(&tree,PeriodicDeep);
std::cout << "The simulation box is repeated " << algo.repetitions() << " in X/Y/Z" << std::endl;
std::cout << "The simulation box is repeated " << algo.theoricalRepetition() << " in X/Y/Z" << std::endl;
KernelClass kernels( DevP, algo.extendedTreeHeight(), algo.extendedBoxWidth(),algo.extendedBoxCenter());
algo.setKernel(&kernels);
algo.execute();
......
......@@ -66,13 +66,6 @@ int main(int argc, char ** argv){
const long NbParticles = FParameters::getValue(argc,argv,"-nb", 1000);
const int PeriodicDeep = FParameters::getValue(argc,argv,"-per", 2);
// choose in +x dir or -/+x dir or all dirs
int PeriodicDirs = (FParameters::existParameter(argc,argv,"-x")?DirMinusX:0) |
(FParameters::existParameter(argc,argv,"+x")?DirPlusX:0) |
(FParameters::existParameter(argc,argv,"-y")?DirMinusY:0) |
(FParameters::existParameter(argc,argv,"+y")?DirPlusY:0) |
(FParameters::existParameter(argc,argv,"-z")?DirMinusZ:0) |
(FParameters::existParameter(argc,argv,"+z")?DirPlusZ:0);
if( PeriodicDirs == 0 ) PeriodicDirs = AllDirs;
FTic counter;
......@@ -106,7 +99,7 @@ int main(int argc, char ** argv){
counter.tic();
KernelClass kernels;
FmmClass algo( &tree, PeriodicDeep, PeriodicDirs);
FmmClass algo( &tree, PeriodicDeep);
algo.setKernel(&kernels);
algo.execute();
......@@ -134,10 +127,9 @@ int main(int argc, char ** argv){
}
}
{
const FTreeCoordinate repetitions = algo.repetitions();
const int totalRepeatedBox = repetitions.getX() * repetitions.getY() * repetitions.getZ();
std::cout << "The box is repeated " << repetitions.getX() <<" "<< repetitions.getY()<<" "<<
repetitions.getZ() << " there are " << totalRepeatedBox << " boxes in total\n";
const long repetitions = algo.theoricalRepetition();
const long totalRepeatedBox = repetitions * repetitions * repetitions;
std::cout << "The box is repeated " << repetitions << " there are " << totalRepeatedBox << " boxes in total\n";
const long long NbParticlesEntireSystem = loader.getNumberOfParticles() * totalRepeatedBox;
std::cout << "The total number of particles is " << NbParticlesEntireSystem << "\n";
......
......@@ -69,15 +69,7 @@ int main(int argc, char ** argv){
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbParticles = FParameters::getValue(argc,argv,"-nb", 5);
const int PeriodicDeep = FParameters::getValue(argc,argv,"-per", 2);
// choose in +x dir or -/+x dir or all dirs
int PeriodicDirs = (FParameters::existParameter(argc,argv,"-x")?DirMinusX:0) |
(FParameters::existParameter(argc,argv,"+x")?DirPlusX:0) |
(FParameters::existParameter(argc,argv,"-y")?DirMinusY:0) |
(FParameters::existParameter(argc,argv,"+y")?DirPlusY:0) |
(FParameters::existParameter(argc,argv,"-z")?DirMinusZ:0) |
(FParameters::existParameter(argc,argv,"+z")?DirPlusZ:0);
if( PeriodicDirs == 0 ) PeriodicDirs = AllDirs;
if( FParameters::existParameter(argc,argv,"-nodir") ) PeriodicDirs = 0;
FMpi app(argc, argv);
......@@ -127,7 +119,7 @@ int main(int argc, char ** argv){
counter.tic();
KernelClass kernels;
FmmClass algo( app.global(), &tree, PeriodicDeep, PeriodicDirs);
FmmClass algo( app.global(), &tree, PeriodicDeep);
algo.setKernel(&kernels);
algo.execute();
......@@ -138,10 +130,8 @@ int main(int argc, char ** argv){
//////////////////////////////////////////////////////////////////////////////////
{
const FTreeCoordinate repetitions = algo.repetitions();
const int totalRepeatedBox = repetitions.getX() * repetitions.getY() * repetitions.getZ();
std::cout << "The box is repeated " << repetitions.getX() <<" "<< repetitions.getY()<<" "<<
repetitions.getZ() << " there are " << totalRepeatedBox << " boxes in total\n";
long long totalRepeatedBox = algo.theoricalRepetition();
totalRepeatedBox = (totalRepeatedBox*totalRepeatedBox*totalRepeatedBox);
const long long NbParticlesEntireSystem = (NbParticles * app.global().processCount()) * totalRepeatedBox;
std::cout << "The total number of particles is " << NbParticlesEntireSystem << "\n";
FTreeCoordinate min, max;
......@@ -177,7 +167,7 @@ int main(int argc, char ** argv){
}
}
FmmClassSeq algoSeq( &treeSeq, PeriodicDeep, PeriodicDirs);
FmmClassSeq algoSeq( &treeSeq, PeriodicDeep);
algoSeq.setKernel(&kernels);
algoSeq.execute();
......
......@@ -75,7 +75,7 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> {
// Run FMM
Print("Fmm...");
FmmClass algo(&tree,PeriodicDeep, DirX | DirMinusY | DirPlusZ);
FmmClass algo(&tree,PeriodicDeep);
KernelClass kernels( algo.extendedTreeHeight(), algo.extendedBoxWidth(), algo.extendedBoxCenter());
algo.setKernel(&kernels);
algo.execute();
......
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