Commit 92b728a0 authored by berenger-bramas's avatar berenger-bramas

Change the sphere test file to sphere[number of particles]

+
Remove a bug in the mpi version.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@83 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 9dec457e
......@@ -10,6 +10,13 @@ endif(insource)
project(Lib_scalfmm)
set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})
# Test if openmp is here
include(FindOpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
# Searching all cpp file
file(
GLOB_RECURSE
......
......@@ -66,7 +66,7 @@ int OctreeHeight, int SubtreeHeight>
const int nbProcess; //< Number of process
const int idPorcess; //< Id of current process
const static int BufferSize = 500; //< To know max of the buffer we receive
const static int BufferSize = 2000; //< To know max of the buffer we receive
FBufferVector<BufferSize> * sendBuffer; //< To put data to send into a buffer
/** To swap between two arrays
......@@ -366,7 +366,6 @@ public:
{
FDEBUG(receiveCounter.tic());
int needToReceive = FMath::Max(0,-rightOffset) + FMath::Max(0,-leftOffset);
FDEBUG( FDebug::Controller << "\t\tNeed to receive " << needToReceive << " cells.\n" );
int source = 0, filled = 0;
int position;
......@@ -504,6 +503,7 @@ public:
}
indexToReceive->setToZeros();
// to count missing data
int needToReceive = 0;
......@@ -537,7 +537,7 @@ public:
if(indexCell < startIdxIndex){
--idxReceiver;
while(idxReceiver && indexCell < upperLimitForProc[idxReceiver-1]){
while(idxReceiver && indexCell <= upperLimitForProc[idxReceiver-1]){
--idxReceiver;
}
}
......@@ -613,9 +613,11 @@ public:
// received computed data
#pragma omp single
{
FDEBUG( FDebug::Controller << "\t\tNeed to receive " << needToReceive << " cells.\n" );
FDEBUG(receiveCounter.tic());
//FDEBUG( FDebug::Controller << "\t\tNeed to receive " << needToReceive << " cells.\n" );
int source = 0, filled = 0;
int position;
char buffer[BufferSize];
......@@ -746,7 +748,7 @@ public:
{
FDEBUG(receiveCounter.tic());
int needToReceive = FMath::Max(0,rightOffsets[idxLevel]) + FMath::Max(0,leftOffsets[idxLevel]);
FDEBUG( FDebug::Controller << "\t\tNeed to receive " << needToReceive << " cells.\n" );
//FDEBUG( FDebug::Controller << "\t\tNeed to receive " << needToReceive << " cells.\n" );
int source = 0, filled = 0;
int position;
......
......@@ -28,6 +28,9 @@
#include "../Src/Files/FFmaLoader.hpp"
//#define VALIDATE_FMM
// With openmp : g++ testFmbAlgorithm.cpp ../Src/Utils/FAssertable.cpp ../Src/Utils/FDebug.cpp ../Src/Utils/FTrace.cpp -lgomp -fopenmp -O2 -o testFmbAlgorithm.exe
// icpc -openmp -openmp-lib=compat testFmbAlgorithm.cpp ../Src/Utils/FAssertable.cpp ../Src/Utils/FDebug.cpp -O2 -o testFmbAlgorithm.exe
......@@ -117,7 +120,7 @@ public:
};
#ifdef VALIDATE_FMM
template<template< class ParticleClass, class CellClass, int OctreeHeight> class KernelClass,
class ParticleClass, class CellClass,
template<class ParticleClass> class LeafClass,
......@@ -240,7 +243,7 @@ void ValidateFMMAlgoProc(FOctree<ParticleClass, CellClass, LeafClass, OctreeHeig
std::cout << "Done\n";
}
#endif
// Simply create particles and try the kernels
int main(int argc, char ** argv){
......@@ -275,20 +278,23 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
FOctree<FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> tree(loader.getBoxWidth(),loader.getCenterOfBox());
#ifdef VALIDATE_FMM
FOctree<FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> treeValide(loader.getBoxWidth(),loader.getCenterOfBox());
#endif
// -----------------------------------------------------
std::cout << "Creating " << loader.getNumberOfParticles() << " particles ..." << std::endl;
counter.tic();
FmbParticle*const particles = new FmbParticle[loader.getNumberOfParticles()];
#ifdef VALIDATE_FMM
FmbParticle*const particlesValide = new FmbParticle[loader.getNumberOfParticles()];
#endif
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(&particles[idxPart]);
#ifdef VALIDATE_FMM
particlesValide[idxPart] = particles[idxPart];
#endif
}
counter.tac();
......@@ -300,7 +306,9 @@ int main(int argc, char ** argv){
counter.tic();
for(long idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
tree.insert(&particles[idxPart]);
#ifdef VALIDATE_FMM
treeValide.insert(&particlesValide[idxPart]);
#endif
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
......@@ -314,10 +322,10 @@ int main(int argc, char ** argv){
FFmmAlgorithmThreadProc<FFmbKernels, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(app,&tree,&kernels);
algo.execute();
#ifdef VALIDATE_FMM
FFmmAlgorithm<FFmbKernels, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algoValide(&treeValide,&kernels);
algoValide.execute();
#endif
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
......@@ -325,16 +333,16 @@ int main(int argc, char ** argv){
{ // get sum forces&potential
FReal potential = 0;
F3DPosition forces;
#ifdef VALIDATE_FMM
FReal potentialValide = 0;
F3DPosition forcesValide;
#endif
FOctree<FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels>::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
#ifdef VALIDATE_FMM
FOctree<FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels>::Iterator octreeIteratorValide(&treeValide);
octreeIteratorValide.gotoBottomLeft();
#endif
FOctree<FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels>::Iterator countLeafsIterator(octreeIterator);
int NbLeafs = 0;
do{
......@@ -348,35 +356,44 @@ int main(int argc, char ** argv){
for(int idxLeaf = 0 ; idxLeaf < startIdx ; ++idxLeaf){
octreeIterator.moveRight();
#ifdef VALIDATE_FMM
octreeIteratorValide.moveRight();
#endif
}
for(int idxLeaf = startIdx ; idxLeaf < endIdx ; ++idxLeaf){
FList<FmbParticle*>::ConstBasicIterator iter(*octreeIterator.getCurrentListTargets());
#ifdef VALIDATE_FMM
FList<FmbParticle*>::ConstBasicIterator iterValide(*octreeIteratorValide.getCurrentListTargets());
while( iter.isValide() && iterValide.isValide() ){
#endif
while( iter.isValide()
#ifdef VALIDATE_FMM
&& iterValide.isValide()
#endif
){
potential += iter.value()->getPotential() * iter.value()->getPhysicalValue();
forces += iter.value()->getForces();
#ifdef VALIDATE_FMM
potentialValide += iterValide.value()->getPotential() * iterValide.value()->getPhysicalValue();
forcesValide += iterValide.value()->getForces();
iterValide.progress();
#endif
iter.progress();
}
octreeIterator.moveRight();
#ifdef VALIDATE_FMM
octreeIteratorValide.moveRight();
#endif
}
#ifdef VALIDATE_FMM
std::cout << "MPI Foces Sum x = " << forces.getX() << " y = " << forces.getY() << " z = " << forces.getZ() << std::endl;
std::cout << "Valide Foces Sum x = " << forcesValide.getX() << " y = " << forcesValide.getY() << " z = " << forcesValide.getZ() << std::endl;
std::cout << "MPI Potential = " << potential << std::endl;
std::cout << "Valide Potential = " << potentialValide << std::endl;
#endif
potential = app.reduceSum(potential);
forces.setX(app.reduceSum(forces.getX()));
forces.setY(app.reduceSum(forces.getY()));
......@@ -387,15 +404,17 @@ int main(int argc, char ** argv){
}
}
#ifdef VALIDATE_FMM
ValidateFMMAlgoProc<FFmbKernels, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels>(&tree,&treeValide,&algo);
#endif
// -----------------------------------------------------
std::cout << "Deleting particles ..." << std::endl;
counter.tic();
delete [] particles;
#ifdef VALIDATE_FMM
delete [] particlesValide;
#endif
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl;
......
......@@ -26,7 +26,7 @@ int main(int argc, char ** argv){
//////////////////////////////////////////////////////////////
// Nb of particles
const long NbParticles = 10;
const long NbParticles = 2000000;
// Center of the box
const float XCenter = 0.5;
......
......@@ -12,21 +12,31 @@
class TestArray : public FUTester<TestArray> {
void TestGetSet(){
FBoolArray array(10);
for(int idx = 0 ; idx < 10 ; ++idx){
FBoolArray array(500);
for(int idx = 0 ; idx < 500 ; ++idx){
assert(!array.get(idx));
}
for(int idx = 0 ; idx < 10 ; ++idx){
for(int idx = 0 ; idx < 500 ; ++idx){
array.set(idx, true);
assert(array.get(idx));
array.set(idx, false);
assert(!array.get(idx));
}
for(int idx = 0 ; idx < 500 ; ++idx){
array.set(idx, true);
}
array.setToZeros();
for(int idx = 0 ; idx < 500 ; ++idx){
assert(!array.get(idx));
}
}
void TestGetSet2(){
FBoolArray array(10);
FBoolArray array(100);
for(int idx = 0 ; idx < 10 ; ++idx){
for(int idx = 0 ; idx < 100 ; ++idx){
if(idx%3){
array.set(idx, true);
assert(array.get(idx));
......
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