Commit 26d60e75 authored by BRAMAS Berenger's avatar BRAMAS Berenger

update conversion from usual octree to blocked tree

parent d8931279
......@@ -79,7 +79,7 @@ public:
* Once allocated each cell receive its morton index and tree coordinate.
* No blocks are allocated at level 0.
*/
template<class OctreeClass, class CellClass>
template<class OctreeClass>
FGroupTree(const int inTreeHeight, const int inNbElementsPerBlock, OctreeClass*const inOctreeSrc)
: treeHeight(inTreeHeight), nbElementsPerBlock(inNbElementsPerBlock), cellBlocksPerLevel(nullptr),
boxCenter(inOctreeSrc->getBoxCenter()), boxCorner(inOctreeSrc->getBoxCenter(),-(inOctreeSrc->getBoxWidth()/2)),
......@@ -116,20 +116,21 @@ public:
int cellIdInBlock = 0;
size_t nbParticlesOffsetBeforeLeaf = 0;
while(cellIdInBlock != sizeOfBlock){
const MortonIndex newNodeIndex = blockIteratorInOctree.getCurrentCell()->getMortonIndex();
const FTreeCoordinate newNodeCoordinate = blockIteratorInOctree.getCurrentCell()->getCoordinate();
// Add cell
const CellClass*const oldNode = blockIteratorInOctree.getCurrentCell();
newBlock->newCell(oldNode->getMortonIndex(), cellIdInBlock);
newBlock->newCell(newNodeIndex, cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(oldNode->getMortonIndex());
newNode.setMortonIndex(oldNode->getMortonIndex());
newNode.setCoordinate(oldNode->getCoordinate());
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
newNode.setMortonIndex(newNodeIndex);
newNode.setCoordinate(newNodeCoordinate);
// Add leaf
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(oldNode->getMortonIndex(), cellIdInBlock,
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(newNodeIndex, cellIdInBlock,
blockIteratorInOctree.getCurrentLeaf()->getSrc()->getNbParticles(),
nbParticlesOffsetBeforeLeaf);
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(oldNode->getMortonIndex());
BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(newNodeIndex);
attachedLeaf.copyFromContainer(blockIteratorInOctree.getCurrentLeaf()->getSrc(), 0);
cellIdInBlock += 1;
......@@ -166,12 +167,13 @@ public:
// Initialize each cell of the block
int cellIdInBlock = 0;
while(cellIdInBlock != sizeOfBlock){
const CellClass*const oldNode = blockIteratorInOctree.getCurrentCell();
newBlock->newCell(oldNode->getMortonIndex(), cellIdInBlock);
const MortonIndex newNodeIndex = blockIteratorInOctree.getCurrentCell()->getMortonIndex();
const FTreeCoordinate newNodeCoordinate = blockIteratorInOctree.getCurrentCell()->getCoordinate();
newBlock->newCell(newNodeIndex, cellIdInBlock);
CompositeCellClass newNode = newBlock->getCompleteCell(oldNode->getMortonIndex());
newNode.setMortonIndex(oldNode->getMortonIndex());
newNode.setCoordinate(oldNode->getCoordinate());
CompositeCellClass newNode = newBlock->getCompleteCell(newNodeIndex);
newNode.setMortonIndex(newNodeIndex);
newNode.setCoordinate(newNodeCoordinate);
cellIdInBlock += 1;
blockIteratorInOctree.moveRight();
......
......@@ -38,6 +38,7 @@
#include "../../Src/GroupTree/StarPUUtils/FStarPUKernelCapacities.hpp"
#endif
#include "../../Src/GroupTree/Core/FP2PGroupParticleContainer.hpp"
#include "../../Src/GroupTree/Rotation/FRotationCellPOD.hpp"
#include "../../Src/Utils/FParameterNames.hpp"
......@@ -55,10 +56,17 @@ int main(int argc, char* argv[]){
static const int P = 3;
typedef FRotationCell<P> CellClass;
typedef FP2PParticleContainer<> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FOctree< CellClass, ContainerClass , LeafClass > OctreeClass;
typedef FGroupTree< CellClass, FP2PGroupParticleContainer<>, 5, FReal> GroupOctreeClass;
typedef FRotationCellPODCore GroupCellSymbClass;
typedef FRotationCellPODPole<P> GroupCellUpClass;
typedef FRotationCellPODLocal<P> GroupCellDownClass;
typedef FRotationCellPOD<P> GroupCellClass;
typedef FP2PGroupParticleContainer<> GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupCellSymbClass, GroupCellUpClass, GroupCellDownClass, GroupContainerClass, 1, 4, FReal> GroupOctreeClass;
FTic counter;
const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5);
......@@ -96,20 +104,22 @@ int main(int argc, char* argv[]){
groupedTree3.printInfoBlocks();
#ifdef ScalFMM_USE_STARPU
typedef FStarPUAllYesCapacities<FRotationKernel< CellClass, FP2PGroupParticleContainer<> , P>> KernelClass;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, CellClass, KernelClass, typename GroupOctreeClass::ParticleGroupClass, FP2PGroupParticleContainer<> > GroupAlgorithm;
typedef FStarPUAllYesCapacities<FRotationKernel< GroupCellClass, GroupContainerClass , P>> GroupKernelClass;
typedef FStarPUCpuWrapper<typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass> GroupCpuWrapper;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupCpuWrapper > GroupAlgorithm;
#elif defined(ScalFMM_USE_OMP4)
typedef FRotationKernel< CellClass, FP2PGroupParticleContainer<> , P> KernelClass;
typedef FGroupTaskDepAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, CellClass, KernelClass, typename GroupOctreeClass::ParticleGroupClass, FP2PGroupParticleContainer<> > GroupAlgorithm;
typedef FRotationKernel< GroupCellClass, GroupContainerClass , P> GroupKernelClass;
// Set the number of threads
omp_set_num_threads(FParameters::getValue(argc,argv,FParameterDefinitions::NbThreads.options, omp_get_max_threads()));
typedef FGroupTaskDepAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm;
#else
typedef FRotationKernel< CellClass, FP2PGroupParticleContainer<> , P> KernelClass;
//typedef FGroupSeqAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, CellClass, KernelClass, typename GroupOctreeClass::ParticleGroupClass, FP2PGroupParticleContainer<> > GroupAlgorithm;
typedef FGroupTaskAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, CellClass, KernelClass, typename GroupOctreeClass::ParticleGroupClass, FP2PGroupParticleContainer<> > GroupAlgorithm;
typedef FRotationKernel< GroupCellClass, GroupContainerClass , P> GroupKernelClass;
//typedef FGroupSeqAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm;
typedef FGroupTaskAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm;
#endif
KernelClass kernel(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
GroupKernelClass kernel(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
GroupAlgorithm algo(&groupedTree2,&kernel);
algo.execute();
......
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