diff --git a/Tests/GroupTree/testBlockedImplicitChebyshev.cpp b/Tests/GroupTree/testBlockedImplicitChebyshev.cpp index 7a3cdf1c12635a80e5ea313bb1f4a14eb5e9914e..7ea04171bfeb7b5ce6ee55dd83b7410e26b59c55 100644 --- a/Tests/GroupTree/testBlockedImplicitChebyshev.cpp +++ b/Tests/GroupTree/testBlockedImplicitChebyshev.cpp @@ -39,6 +39,7 @@ using namespace std; #include "../../Src/Utils/FParameterNames.hpp" #include "../../Src/Files/FFmaGenericLoader.hpp" +#include "../../Src/Files/FGenerateDistribution.hpp" #include "../../Src/Core/FFmmAlgorithm.hpp" typedef double FReal; @@ -59,7 +60,7 @@ using namespace std; typedef FStarPUCpuWrapper<typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass> GroupCpuWrapper; typedef FGroupTaskStarPUImplicitAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupCpuWrapper > GroupAlgorithm; -#define LOAD_FILE +//#define LOAD_FILE #ifndef LOAD_FILE typedef FRandomLoader<FReal> LoaderClass; #else @@ -77,9 +78,12 @@ int main(int argc, char* argv[]){ "The size of the block of the blocked tree" }; const FParameterNames LocalOptionNoValidate { {"-no-validation"}, "To avoid comparing with direct computation"}; + const FParameterNames LocalOptionEllipsoid = {{"-ellipsoid"} , " non uniform distribution on an ellipsoid of aspect ratio given by 0.5:0.25:0.125"}; + const FParameterNames LocalOptionPlummer = {{"-plummer"} , " (Highly non uniform) plummer distribution (astrophysics)"}; FHelpDescribeAndExit(argc, argv, "Loutre", FParameterDefinitions::OctreeHeight, FParameterDefinitions::NbParticles, - FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::InputFile, LocalOptionBlocSize, LocalOptionNoValidate); + FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::InputFile, LocalOptionBlocSize, + LocalOptionNoValidate, LocalOptionEllipsoid, LocalOptionPlummer); // Get params const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5); @@ -107,19 +111,33 @@ int main(int argc, char* argv[]){ //Fill particles #ifndef LOAD_FILE + FReal boxWidth = 1.0; { + FRandomLoader<FReal> loader(NbParticles, boxWidth, FPoint<FReal>(0,0,0), mpiComm.global().processId()); + FAssertLF(loader.isOpen()); FSize idxPart = 0; for(int i = 0; i < mpiComm.global().processCount(); ++i){ FSize NbParticlesPerNode = getNbParticlesPerNode(nproc, i, NbParticles); - LoaderClass loader(NbParticlesPerNode, 1.0, FPoint<FReal>(0,0,0), i); - FAssertLF(loader.isOpen()); + setSeed(i); + FReal * tmpParticles = new FReal[4*NbParticlesPerNode]; + if(FParameters::existParameter(argc, argv, "-ellipsoid")) { + nonunifRandonPointsOnElipsoid(NbParticlesPerNode, boxWidth/2, boxWidth/4, boxWidth/8, tmpParticles); + } + else if(FParameters::existParameter(argc, argv, "-plummer")) { + //The M argument is not used in the algorithm of the plummer distribution + unifRandonPlummer(NbParticlesPerNode, boxWidth/2, 0.0, tmpParticles) ; + } + else { //Uniform cube + unifRandonPointsOnCube(NbParticlesPerNode, boxWidth/2, boxWidth/2, boxWidth/2, tmpParticles); + } for(FSize j= 0 ; j < NbParticlesPerNode ; ++j){ - loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not + allParticlesToSort[idxPart].setPosition(tmpParticles[j*4], tmpParticles[j*4+1], tmpParticles[j*4+2]);//Same with file or not ++idxPart; } + delete[] tmpParticles; } } - LoaderClass loader(NbParticles, 1.0, FPoint<FReal>(0,0,0)); + LoaderClass loader(NbParticles, boxWidth, FPoint<FReal>(0,0,0)); #else for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FReal physicalValue = 0.1; diff --git a/Tests/GroupTree/testBlockedMpiChebyshev.cpp b/Tests/GroupTree/testBlockedMpiChebyshev.cpp index b570d8f8c72d9d227a976851b2a65c988d09e7d5..1fa729579a6389f6cc07da62b6a8873a585180c5 100644 --- a/Tests/GroupTree/testBlockedMpiChebyshev.cpp +++ b/Tests/GroupTree/testBlockedMpiChebyshev.cpp @@ -43,6 +43,7 @@ #include "../../Src/GroupTree/Core/FGroupTaskStarpuMpiAlgorithm.hpp" #include "../../Src/Files/FMpiFmaGenericLoader.hpp" +#include "../../Src/Files/FGenerateDistribution.hpp" #include "../../Src/Containers/FCoordinateComputer.hpp" #include "../../Src/GroupTree/StarPUUtils/FStarPUKernelCapacities.hpp" @@ -55,10 +56,12 @@ FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total); 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"}; + const FParameterNames LocalOptionEllipsoid = {{"-ellipsoid"} , " non uniform distribution on an ellipsoid of aspect ratio given by 0.5:0.25:0.125"}; + const FParameterNames LocalOptionPlummer = {{"-plummer"} , " (Highly non uniform) plummer distribution (astrophysics)"}; FHelpDescribeAndExit(argc, argv, "Test the blocked tree by counting the particles.", FParameterDefinitions::OctreeHeight,FParameterDefinitions::InputFile, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles, - LocalOptionBlocSize, LocalOptionNoValidate); + LocalOptionBlocSize, LocalOptionNoValidate, LocalOptionEllipsoid, LocalOptionPlummer); typedef double FReal; // Initialize the types @@ -107,20 +110,35 @@ int main(int argc, char* argv[]){ } }; -#define LOAD_FILE +//#define LOAD_FILE #ifndef LOAD_FILE - // open particle file - FRandomLoader<FReal> loader(NbParticles, 1.0, FPoint<FReal>(0,0,0), mpiComm.global().processId()); + FReal boxWidth = 1.0; + FRandomLoader<FReal> loader(NbParticles, boxWidth, FPoint<FReal>(0,0,0), mpiComm.global().processId()); FAssertLF(loader.isOpen()); + setSeed(mpiComm.global().processId()); TestParticle* allParticles = new TestParticle[loader.getNumberOfParticles()]; + FReal * tmpParticles = new FReal[4*loader.getNumberOfParticles()]; memset(allParticles,0,(unsigned int) (sizeof(TestParticle)* loader.getNumberOfParticles())); + memset(tmpParticles,0,(unsigned int) (sizeof(FReal)* loader.getNumberOfParticles() * 4)); + if(FParameters::existParameter(argc, argv, "-ellipsoid")) { + nonunifRandonPointsOnElipsoid(loader.getNumberOfParticles(), boxWidth/2, boxWidth/4, boxWidth/8, tmpParticles); + } + else if(FParameters::existParameter(argc, argv, "-plummer")) { + //The M argument is not used in the algorithm of the plummer distribution + unifRandonPlummer(loader.getNumberOfParticles(), boxWidth/2, 0.0, tmpParticles) ; + } + else { //Uniform cube + unifRandonPointsOnCube(loader.getNumberOfParticles(), boxWidth/2, boxWidth/2, boxWidth/2, tmpParticles); + } + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(&allParticles[idxPart].position); + allParticles[idxPart].position.setPosition(tmpParticles[idxPart*4], tmpParticles[idxPart*4+1], tmpParticles[idxPart*4+2]); allParticles[idxPart].physicalValue = 0.1; } - + delete[] tmpParticles; #else + // open particle file const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.fma"); FMpiFmaGenericLoader<FReal> loader(filename,mpiComm.global()); FAssertLF(loader.isOpen()); diff --git a/Tests/noDist/testFmmAlgorithmThreadProc.cpp b/Tests/noDist/testFmmAlgorithmThreadProc.cpp index 2474f0f7f7a991f1d1b00ad390a9f73fd502e2be..a407c1c0acbd197af3ff9488a245f1d963aa85e9 100644 --- a/Tests/noDist/testFmmAlgorithmThreadProc.cpp +++ b/Tests/noDist/testFmmAlgorithmThreadProc.cpp @@ -34,6 +34,7 @@ #include "../../Src/GroupTree/Core/FGroupTaskStarpuMpiAlgorithm.hpp" #include "../../Src/Files/FMpiFmaGenericLoader.hpp" +#include "../../Src/Files/FGenerateDistribution.hpp" #include "../../Src/Containers/FCoordinateComputer.hpp" @@ -45,10 +46,12 @@ FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total); 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"}; + const FParameterNames LocalOptionEllipsoid = {{"-ellipsoid"} , " non uniform distribution on an ellipsoid of aspect ratio given by 0.5:0.25:0.125"}; + const FParameterNames LocalOptionPlummer = {{"-plummer"} , " (Highly non uniform) plummer distribution (astrophysics)"}; FHelpDescribeAndExit(argc, argv, "Test the blocked tree by counting the particles.", FParameterDefinitions::OctreeHeight,FParameterDefinitions::InputFile, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles, - LocalOptionBlocSize, LocalOptionNoValidate); + LocalOptionBlocSize, LocalOptionNoValidate, LocalOptionEllipsoid, LocalOptionPlummer); typedef double FReal; // Initialize the types @@ -83,19 +86,33 @@ int main(int argc, char* argv[]){ } }; -#define LOAD_FILE +//#define LOAD_FILE #ifndef LOAD_FILE - // open particle file - FRandomLoader<FReal> loader(NbParticles, 1.0, FPoint<FReal>(0,0,0), mpiComm.global().processId()); + FReal boxWidth = 1.0; + FRandomLoader<FReal> loader(NbParticles, boxWidth, FPoint<FReal>(0,0,0), mpiComm.global().processId()); FAssertLF(loader.isOpen()); + setSeed(mpiComm.global().processId()); TestParticle* allParticles = new TestParticle[loader.getNumberOfParticles()]; + FReal * tmpParticles = new FReal[4*loader.getNumberOfParticles()]; memset(allParticles,0,(unsigned int) (sizeof(TestParticle)* loader.getNumberOfParticles())); + memset(tmpParticles,0,(unsigned int) (sizeof(FReal)* loader.getNumberOfParticles() * 4)); + if(FParameters::existParameter(argc, argv, "-ellipsoid")) { + nonunifRandonPointsOnElipsoid(loader.getNumberOfParticles(), boxWidth/2, boxWidth/4, boxWidth/8, tmpParticles); + } + else if(FParameters::existParameter(argc, argv, "-plummer")) { + //The M argument is not used in the algorithm of the plummer distribution + unifRandonPlummer(loader.getNumberOfParticles(), boxWidth/2, 0.0, tmpParticles) ; + } + else { //Uniform cube + unifRandonPointsOnCube(loader.getNumberOfParticles(), boxWidth/2, boxWidth/2, boxWidth/2, tmpParticles); + } + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(&allParticles[idxPart].position); + allParticles[idxPart].position.setPosition(tmpParticles[idxPart*4], tmpParticles[idxPart*4+1], tmpParticles[idxPart*4+2]); allParticles[idxPart].physicalValue = 0.1; } - + delete[] tmpParticles; #else const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.fma"); FMpiFmaGenericLoader<FReal> loader(filename,mpiComm.global());