Commit bb6d26c1 authored by Martin Khannouz's avatar Martin Khannouz Committed by Berenger Bramas

Change test programm's so you can give the total amount of particles.

Before you'd have to split the total amount of particles between the
number of node ...
parent 3d69eea7
...@@ -74,6 +74,7 @@ using namespace std; ...@@ -74,6 +74,7 @@ using namespace std;
void timeAverage(int mpi_rank, int nproc, double elapsedTime); void timeAverage(int mpi_rank, int nproc, double elapsedTime);
void sortParticle(FPoint<FReal> * allParticlesToSort, int treeHeight, int groupSize, vector<vector<int>> & sizeForEachGroup, vector<MortonIndex> & distributedMortonIndex, LoaderClass& loader, int nproc); void sortParticle(FPoint<FReal> * allParticlesToSort, int treeHeight, int groupSize, vector<vector<int>> & sizeForEachGroup, vector<MortonIndex> & distributedMortonIndex, LoaderClass& loader, int nproc);
void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std::vector<std::vector<std::vector<MortonIndex>>>& nodeRepartition, int nproc, int treeHeight); void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std::vector<std::vector<std::vector<MortonIndex>>>& nodeRepartition, int nproc, int treeHeight);
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total);
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
const FParameterNames LocalOptionBlocSize { const FParameterNames LocalOptionBlocSize {
...@@ -107,18 +108,23 @@ int main(int argc, char* argv[]){ ...@@ -107,18 +108,23 @@ int main(int argc, char* argv[]){
const FSize NbParticles = loader.getNumberOfParticles(); const FSize NbParticles = loader.getNumberOfParticles();
#endif #endif
FPoint<FReal> * allParticlesToSort = new FPoint<FReal>[NbParticles*mpiComm.global().processCount()]; FPoint<FReal> * allParticlesToSort = new FPoint<FReal>[NbParticles];
//Fill particles //Fill particles
#ifndef LOAD_FILE #ifndef LOAD_FILE
for(int i = 0; i < mpiComm.global().processCount(); ++i){ {
LoaderClass loader(NbParticles, 1.0, FPoint<FReal>(0,0,0), i); FSize idxPart = 0;
FAssertLF(loader.isOpen()); for(int i = 0; i < mpiComm.global().processCount(); ++i){
for(FSize idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ FSize NbParticlesPerNode = getNbParticlesPerNode(nproc, i, NbParticles);
loader.fillParticle(&allParticlesToSort[(NbParticles*i) + idxPart]);//Same with file or not LoaderClass loader(NbParticlesPerNode, 1.0, FPoint<FReal>(0,0,0), i);
FAssertLF(loader.isOpen());
for(FSize j= 0 ; j < NbParticlesPerNode ; ++j){
loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not
++idxPart;
}
} }
} }
LoaderClass loader(NbParticles*mpiComm.global().processCount(), 1.0, FPoint<FReal>(0,0,0)); LoaderClass loader(NbParticles, 1.0, FPoint<FReal>(0,0,0));
#else #else
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not
...@@ -379,3 +385,9 @@ void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std: ...@@ -379,3 +385,9 @@ void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std:
} }
} }
} }
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total){
if(mpi_rank < (total%mpi_count))
return ((total - (total%mpi_count))/mpi_count)+1;
return ((total - (total%mpi_count))/mpi_count);
}
...@@ -65,9 +65,11 @@ using namespace std; ...@@ -65,9 +65,11 @@ using namespace std;
#else #else
typedef FFmaGenericLoader<FReal> LoaderClass; typedef FFmaGenericLoader<FReal> LoaderClass;
#endif #endif
void timeAverage(int mpi_rank, int nproc, double elapsedTime); void timeAverage(int mpi_rank, int nproc, double elapsedTime);
void sortParticle(FPoint<FReal> * allParticlesToSort, int treeHeight, int groupSize, vector<vector<int>> & sizeForEachGroup, vector<MortonIndex> & distributedMortonIndex, LoaderClass& loader, int nproc); void sortParticle(FPoint<FReal> * allParticlesToSort, int treeHeight, int groupSize, vector<vector<int>> & sizeForEachGroup, vector<MortonIndex> & distributedMortonIndex, LoaderClass& loader, int nproc);
void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std::vector<std::vector<std::vector<MortonIndex>>>& nodeRepartition, int nproc, int treeHeight); void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std::vector<std::vector<std::vector<MortonIndex>>>& nodeRepartition, int nproc, int treeHeight);
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total);
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
const FParameterNames LocalOptionBlocSize { const FParameterNames LocalOptionBlocSize {
...@@ -101,18 +103,23 @@ int main(int argc, char* argv[]){ ...@@ -101,18 +103,23 @@ int main(int argc, char* argv[]){
const FSize NbParticles = loader.getNumberOfParticles(); const FSize NbParticles = loader.getNumberOfParticles();
#endif #endif
FPoint<FReal> * allParticlesToSort = new FPoint<FReal>[NbParticles*mpiComm.global().processCount()]; FPoint<FReal> * allParticlesToSort = new FPoint<FReal>[NbParticles];
//Fill particles //Fill particles
#ifndef LOAD_FILE #ifndef LOAD_FILE
for(int i = 0; i < mpiComm.global().processCount(); ++i){ {
LoaderClass loader(NbParticles, 1.0, FPoint<FReal>(0,0,0), i); FSize idxPart = 0;
FAssertLF(loader.isOpen()); for(int i = 0; i < mpiComm.global().processCount(); ++i){
for(FSize idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ FSize NbParticlesPerNode = getNbParticlesPerNode(nproc, i, NbParticles);
loader.fillParticle(&allParticlesToSort[(NbParticles*i) + idxPart]);//Same with file or not LoaderClass loader(NbParticlesPerNode, 1.0, FPoint<FReal>(0,0,0), i);
FAssertLF(loader.isOpen());
for(FSize j= 0 ; j < NbParticlesPerNode ; ++j){
loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not
++idxPart;
}
} }
} }
LoaderClass loader(NbParticles*mpiComm.global().processCount(), 1.0, FPoint<FReal>(0,0,0)); LoaderClass loader(NbParticles, 1.0, FPoint<FReal>(0,0,0));
#else #else
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not loader.fillParticle(&allParticlesToSort[idxPart]);//Same with file or not
...@@ -414,3 +421,9 @@ void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std: ...@@ -414,3 +421,9 @@ void createNodeRepartition(std::vector<MortonIndex> distributedMortonIndex, std:
} }
} }
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total){
if(mpi_rank < (total%mpi_count))
return ((total - (total%mpi_count))/mpi_count)+1;
return ((total - (total%mpi_count))/mpi_count);
}
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <fstream> #include <fstream>
void timeAverage(int mpi_rank, int nproc, double elapsedTime); void timeAverage(int mpi_rank, int nproc, double elapsedTime);
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total);
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
const FParameterNames LocalOptionBlocSize { const FParameterNames LocalOptionBlocSize {
...@@ -75,9 +76,9 @@ int main(int argc, char* argv[]){ ...@@ -75,9 +76,9 @@ int main(int argc, char* argv[]){
FMpi mpiComm(argc, argv); FMpi mpiComm(argc, argv);
// Get params // Get params
const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5); const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5);
const FSize NbParticles = FParameters::getValue(argc,argv,FParameterDefinitions::NbParticles.options, FSize(20));
const int groupSize = FParameters::getValue(argc,argv,LocalOptionBlocSize.options, 8); const int groupSize = FParameters::getValue(argc,argv,LocalOptionBlocSize.options, 8);
const FSize totalNbParticles = (NbParticles*mpiComm.global().processCount()); const FSize totalNbParticles = FParameters::getValue(argc,argv,FParameterDefinitions::NbParticles.options, FSize(20));
const FSize NbParticles = getNbParticlesPerNode(mpiComm.global().processCount(), mpiComm.global().processId(), totalNbParticles);
// Load the particles // Load the particles
FRandomLoader<FReal> loader(NbParticles, 1.0, FPoint<FReal>(0,0,0), mpiComm.global().processId()); FRandomLoader<FReal> loader(NbParticles, 1.0, FPoint<FReal>(0,0,0), mpiComm.global().processId());
FAssertLF(loader.isOpen()); FAssertLF(loader.isOpen());
...@@ -178,7 +179,7 @@ int main(int argc, char* argv[]){ ...@@ -178,7 +179,7 @@ int main(int argc, char* argv[]){
// Usual octree // Usual octree
OctreeClass tree(NbLevels, 2, loader.getBoxWidth(), loader.getCenterOfBox()); OctreeClass tree(NbLevels, 2, loader.getBoxWidth(), loader.getCenterOfBox());
for(int idxProc = 0 ; idxProc < mpiComm.global().processCount() ; ++idxProc){ for(int idxProc = 0 ; idxProc < mpiComm.global().processCount() ; ++idxProc){
FRandomLoader<FReal> loaderAll(NbParticles, 1.0, FPoint<FReal>(0,0,0), idxProc); FRandomLoader<FReal> loaderAll(getNbParticlesPerNode(mpiComm.global().processCount(), idxProc, totalNbParticles), 1.0, FPoint<FReal>(0,0,0), idxProc);
for(FSize idxPart = 0 ; idxPart < loaderAll.getNumberOfParticles() ; ++idxPart){ for(FSize idxPart = 0 ; idxPart < loaderAll.getNumberOfParticles() ; ++idxPart){
FPoint<FReal> pos; FPoint<FReal> pos;
loaderAll.fillParticle(&pos); loaderAll.fillParticle(&pos);
...@@ -230,3 +231,8 @@ void timeAverage(int mpi_rank, int nproc, double elapsedTime) ...@@ -230,3 +231,8 @@ void timeAverage(int mpi_rank, int nproc, double elapsedTime)
} }
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
} }
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total){
if(mpi_rank < (total%mpi_count))
return ((total - (total%mpi_count))/mpi_count)+1;
return ((total - (total%mpi_count))/mpi_count);
}
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <memory> #include <memory>
void timeAverage(int mpi_rank, int nproc, double elapsedTime); void timeAverage(int mpi_rank, int nproc, double elapsedTime);
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total);
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
const FParameterNames LocalOptionBlocSize { {"-bs"}, "The size of the block of the blocked tree"}; const FParameterNames LocalOptionBlocSize { {"-bs"}, "The size of the block of the blocked tree"};
...@@ -85,8 +86,8 @@ int main(int argc, char* argv[]){ ...@@ -85,8 +86,8 @@ int main(int argc, char* argv[]){
const unsigned int TreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeHeight.options, 5); 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 unsigned int SubTreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeSubHeight.options, 2);
const FSize NbParticles = FParameters::getValue(argc,argv,FParameterDefinitions::NbParticles.options, FSize(20)); const FSize totalNbParticles = FParameters::getValue(argc,argv,FParameterDefinitions::NbParticles.options, FSize(20));
const FSize totalNbParticles = (NbParticles*mpiComm.global().processCount()); const FSize NbParticles = getNbParticlesPerNode(mpiComm.global().processCount(), mpiComm.global().processId(), totalNbParticles);
// init particles position and physical value // init particles position and physical value
struct TestParticle{ struct TestParticle{
...@@ -311,3 +312,8 @@ void timeAverage(int mpi_rank, int nproc, double elapsedTime) ...@@ -311,3 +312,8 @@ void timeAverage(int mpi_rank, int nproc, double elapsedTime)
} }
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
} }
FSize getNbParticlesPerNode(FSize mpi_count, FSize mpi_rank, FSize total){
if(mpi_rank < (total%mpi_count))
return ((total - (total%mpi_count))/mpi_count)+1;
return ((total - (total%mpi_count))/mpi_count);
}
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