Commit e1ff7623 authored by BRAMAS Berenger's avatar BRAMAS Berenger

add a parallel loop in the threaded tree builder and clean the test to compare both approach

parent 5a80e451
......@@ -96,6 +96,7 @@ public:
std::unique_ptr<IndexedParticle[]> particleIndexes(new IndexedParticle[numberOfParticle]);
FLOG(copyTimer.tic());
#pragma omp parallel for schedule(static)
for(FSize idxParts=0; idxParts<numberOfParticle ; ++idxParts ){
// Get the Morton Index
const FTreeCoordinate host(
......
......@@ -68,12 +68,11 @@ int main(int argc, char** argv){
// -----------------------------------------------------
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
// -----------------------------------------------------
{
ContainerClass particles;
particles.reserve(loader.getNumberOfParticles());
FTic timer;
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
FPoint<FReal> particlePosition;
......@@ -81,8 +80,34 @@ int main(int argc, char** argv){
loader.fillParticle(&particlePosition,&physicalValue);
particles.push(particlePosition, physicalValue );
}
std::cout << "Load the file in " << timer.tacAndElapsed() << "s\n";
timer.tic();
{
const FReal*const partX = particles.getPositions()[0];
const FReal*const partY = particles.getPositions()[1];
const FReal*const partZ = particles.getPositions()[2];
const FReal*const physicalValues = particles.getPhysicalValues();
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
const FPoint<FReal> particlePosition(
partX[idxPart], partY[idxPart], partZ[idxPart]
);
tree.insert(particlePosition, physicalValues[idxPart] );
}
}
std::cout << "Create the tree in sequential " << timer.tacAndElapsed() << "s\n";
timer.tic();
{
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
// This will modify particles!
FTreeBuilder<FReal,OctreeClass, LeafClass>::BuildTreeFromArray(&tree, particles);
}
std::cout << "Create the tree in parallel " << timer.tacAndElapsed() << "s\n";
FTreeBuilder<FReal,OctreeClass, LeafClass>::BuildTreeFromArray(&tree, particles);
}
// -----------------------------------------------------
......
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