Commit 0e30f4d3 authored by COULAUD Olivier's avatar COULAUD Olivier

Fix some problems

parent fec0225f
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include "Utils/FLeafBalance.hpp" #include "Utils/FLeafBalance.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp" #include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
#include "Kernels/Chebyshev/FChebSymKernel.hpp"
#include "Kernels/Chebyshev/FChebCell.hpp"
#include "Components/FSimpleLeaf.hpp" #include "Components/FSimpleLeaf.hpp"
#include "Kernels/P2P/FP2PParticleContainerIndexed.hpp" #include "Kernels/P2P/FP2PParticleContainerIndexed.hpp"
...@@ -80,9 +78,12 @@ int main(int argc, char* argv[]) ...@@ -80,9 +78,12 @@ int main(int argc, char* argv[])
FParameterDefinitions::NbThreads, FParameterDefinitions::NbThreads,
FParameterDefinitions::PeriodicityNbLevels, FParameterDefinitions::PeriodicityNbLevels,
localIncreaseBox localIncreaseBox
) ) ;
;
// Initialize values for MPI
FMpi app(argc,argv);
const bool masterIO = ( app.global().processId() == 0 );
//
const std::string defaultFile("../Data/test20k.fma"); const std::string defaultFile("../Data/test20k.fma");
const std::string filename = FParameters::getStr(argc,argv, FParameterDefinitions::InputFile.options, defaultFile.c_str()); 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 TreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeHeight.options, 5);
...@@ -95,27 +96,25 @@ int main(int argc, char* argv[]) ...@@ -95,27 +96,25 @@ int main(int argc, char* argv[])
const unsigned int aboveTree = FParameters::getValue(argc, argv, FParameterDefinitions::PeriodicityNbLevels.options, 5); const unsigned int aboveTree = FParameters::getValue(argc, argv, FParameterDefinitions::PeriodicityNbLevels.options, 5);
omp_set_num_threads(NbThreads); omp_set_num_threads(NbThreads);
std::cout << "\n>> Using " << omp_get_max_threads() << " threads.\n" << std::endl; if(masterIO){
std::cout << "\n>> Using " << omp_get_max_threads() << " threads.\n" << std::endl;
//
std::cout << "Parameters"<< std::endl //
<< " Octree Depth " << TreeHeight << std::endl std::cout << "Parameters"<< std::endl
<< " SubOctree depth " << SubTreeHeight << std::endl; << " Octree Depth " << TreeHeight << std::endl
if(periodicCondition){ << " SubOctree depth " << SubTreeHeight << std::endl;
if(periodicCondition){
std::cout << " AboveTree "<< aboveTree <<std::endl; std::cout << " AboveTree "<< aboveTree <<std::endl;
} }
std::cout << " Input file name: " << filename << std::endl std::cout << " Input file name: " << filename << std::endl
<< " Thread count : " << NbThreads << std::endl << " Thread count : " << NbThreads << std::endl
<< std::endl; << std::endl;
}
///////// VAR INIT ///////////////////////////////////////////////// ///////// VAR INIT /////////////////////////////////////////////////
// Initialize values for MPI
FMpi app(argc,argv);
const bool masterIO = ( app.global().processId() == 0 );
//
// Initialize timer // Initialize timer
FTic time; FTic time;
...@@ -221,21 +220,19 @@ int main(int argc, char* argv[]) ...@@ -221,21 +220,19 @@ int main(int argc, char* argv[])
} }
// ----------------------------------------------------- // -----------------------------------------------------
std::vector<MortonIndex> mortonLeafDistribution(2*app.global().processCount());
FAbstractAlgorithm * algorithm = nullptr; FAbstractAlgorithm * algorithm = nullptr;
FAlgorithmTimers * timer = nullptr; FAlgorithmTimers * timer = nullptr;
{ // ----------------------------------------------------- // -----------------------------------------------------
if(masterIO) { if(masterIO) {
std::cout << "\n"<<interpolationType<<" FMM Proc (ORDER="<< ORDER << ") ... " << std::endl; std::cout << "\n"<<interpolationType<<" FMM Proc (ORDER="<< ORDER << ") ... " << std::endl;
} }
time.tic();
// Kernels to use (pointer because of the limited size of the stack) // Kernels to use (pointer because of the limited size of the stack)
// non periodic FMM algorithm // non periodic FMM algorithm
std::unique_ptr<KernelClass> kernelsNoPer(new KernelClass(TreeHeight, boxWidth, std::unique_ptr<KernelClass> kernelsNoPer(new KernelClass(TreeHeight, boxWidth,
loader.getCenterOfBox(),&MatrixKernel)); loader.getCenterOfBox(),
&MatrixKernel));
FmmClassProc algoNoPer(app.global(),&tree, kernelsNoPer.get()); FmmClassProc algoNoPer(app.global(),&tree, kernelsNoPer.get());
// //
// periodic FMM algorithm // periodic FMM algorithm
...@@ -256,20 +253,20 @@ int main(int argc, char* argv[]) ...@@ -256,20 +253,20 @@ int main(int argc, char* argv[])
} }
// //
// FMM exectution FFmmFarField FFmmNearField FFmmP2M|FFmmM2M|FFmmM2L|FFmmL2L // FMM exectution FFmmFarField FFmmNearField FFmmP2M|FFmmM2M|FFmmM2L|FFmmL2L
time.tic();
algorithm->execute(); algorithm->execute();
time.tac();
// //
algorithm->getMortonLeafDistribution(mortonLeafDistribution);
if(masterIO) // if(masterIO)
{ // {
std::cout << app.global().processId() <<" Morton distribution "<< std::endl ; // std::cout << app.global().processId() <<" Morton distribution "<< std::endl ;
for(auto v : mortonLeafDistribution) // for(auto v : mortonLeafDistribution)
std::cout << v << " "; // std::cout << v << " ";
std::cout << std::endl; // std::cout << std::endl;
} // }
app.global().barrier(); // app.global().barrier();
time.tac();
timeUsed = time.elapsed(); timeUsed = time.elapsed();
MPI_Reduce(&timeUsed,&minTime,1,MPI_DOUBLE,MPI_MIN,0,app.global().getComm()); MPI_Reduce(&timeUsed,&minTime,1,MPI_DOUBLE,MPI_MIN,0,app.global().getComm());
MPI_Reduce(&timeUsed,&maxTime,1,MPI_DOUBLE,MPI_MAX,0,app.global().getComm()); MPI_Reduce(&timeUsed,&maxTime,1,MPI_DOUBLE,MPI_MAX,0,app.global().getComm());
...@@ -287,7 +284,7 @@ int main(int argc, char* argv[]) ...@@ -287,7 +284,7 @@ int main(int argc, char* argv[])
<< std::endl; << std::endl;
} }
}
// ----------------------------------------------------- // -----------------------------------------------------
// //
...@@ -321,33 +318,36 @@ int main(int argc, char* argv[]) ...@@ -321,33 +318,36 @@ int main(int argc, char* argv[])
const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); const FVector<FSize>& indexes = leaf->getTargets()->getIndexes();
for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const FSize indexPartOrig = indexes[idxPart]; const FSize indexPartOrig = indexes[idxPart];
if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) )
{ {
std::cout << "Proc "<< app.global().processId() << " Index "<< indexPartOrig <<" potential " << potentials[idxPart] std::cout << "Proc "<< app.global().processId() << " Index "<< indexPartOrig <<" potential " << potentials[idxPart]
<< " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart] << " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart]
<< " Forces: " << forcesX[idxPart] << " " << forcesY[idxPart] << " "<< forcesZ[idxPart] <<std::endl; << " Forces: " << forcesX[idxPart] << " " << forcesY[idxPart] << " "<< forcesZ[idxPart] <<std::endl;
} }
energy += potentials[idxPart]*physicalValues[idxPart] ; energy += potentials[idxPart]*physicalValues[idxPart] ;
locTotalPhysicalValue += physicalValues[idxPart] ; locTotalPhysicalValue += physicalValues[idxPart] ;
} }
}); });
FReal gloEnergy = app.global().reduceSum(energy); FReal gloEnergy = app.global().reduceSum(energy);
FReal TotalPhysicalValue = app.global().reduceSum(locTotalPhysicalValue); FReal TotalPhysicalValue = app.global().reduceSum(locTotalPhysicalValue);
if(masterIO){ if(masterIO){
std::cout <<std::endl<<"aboveRoot: " << aboveTree << " Energy: "<< gloEnergy <<" TotalPhysicalValue: " << TotalPhysicalValue<< std::endl; std::cout <<std::endl<<"aboveRoot: " << aboveTree << " Energy: "<< gloEnergy <<" TotalPhysicalValue: " << TotalPhysicalValue<< std::endl;
std::cout <<std::endl <<" &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<<std::endl<<std::endl; std::cout <<std::endl <<" &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "<<std::endl<<std::endl;
} }
} }
// ----------------------------------------------------- // -----------------------------------------------------
if(FParameters::existParameter(argc, argv, FParameterDefinitions::OutputFile.options)){ if(FParameters::existParameter(argc, argv, FParameterDefinitions::OutputFile.options)){
std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma")); std::vector<MortonIndex> mortonLeafDistribution(2*app.global().processCount());
FMpiFmaGenericWriter<FReal> paraWriter(name,app); algorithm->getMortonLeafDistribution(mortonLeafDistribution);
paraWriter.writeDistributionOfParticlesFromOctree(tree,loader.getNumberOfParticles(),localParticlesNumber,mortonLeafDistribution); std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma"));
FMpiFmaGenericWriter<FReal> paraWriter(name,app);
paraWriter.writeDistributionOfParticlesFromOctree(tree,loader.getNumberOfParticles(),localParticlesNumber,
mortonLeafDistribution);
} }
return 0; return 0;
} }
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