Commit cc21eddf authored by BRAMAS Berenger's avatar BRAMAS Berenger

First stage in the dissociation of symbilic and computational data

parent 0e7cc53c
......@@ -47,8 +47,13 @@ public:
positionsPointers[2] = reinterpret_cast<FReal*>(reinterpret_cast<unsigned char*>(inPositionBuffer) + inLeadingPosition*2);
// Redirect pointers to data
for(unsigned idxAttribute = 0 ; idxAttribute < NbAttributesPerParticle ; ++idxAttribute){
attributes[idxAttribute] = reinterpret_cast<AttributeClass*>(reinterpret_cast<unsigned char*>(inAttributesBuffer) + idxAttribute*inLeadingAttributes);
if(inAttributesBuffer){
for(unsigned idxAttribute = 0 ; idxAttribute < NbAttributesPerParticle ; ++idxAttribute){
attributes[idxAttribute] = reinterpret_cast<AttributeClass*>(reinterpret_cast<unsigned char*>(inAttributesBuffer) + idxAttribute*inLeadingAttributes);
}
}
else{
memset(attributes, 0, sizeof(AttributeClass*)*NbAttributesPerParticle);
}
}
......
This diff is collapsed.
......@@ -78,7 +78,8 @@ protected:
FReal* particlePosition[3];
//< Pointers to the particles data inside the block memory
AttributeClass* particleAttributes[NbAttributesPerParticle];
AttributeClass* attributesBuffer;
AttributeClass* particleAttributes[NbAttributesPerParticle];
/** To know if we have to delete the buffer */
bool deleteBuffer;
......@@ -89,10 +90,11 @@ public:
* @param inBuffer
* @param inAllocatedMemoryInByte
*/
FGroupOfParticles(unsigned char* inBuffer, const size_t inAllocatedMemoryInByte)
FGroupOfParticles(unsigned char* inBuffer, const size_t inAllocatedMemoryInByte,
unsigned char* inAttributes)
: allocatedMemoryInByte(inAllocatedMemoryInByte), memoryBuffer(inBuffer),
blockHeader(nullptr), blockIndexesTable(nullptr), leafHeader(nullptr), nbParticlesInGroup(0),
deleteBuffer(false){
attributesBuffer(nullptr), deleteBuffer(false){
// Move the pointers to the correct position
blockHeader = reinterpret_cast<BlockHeader*>(memoryBuffer);
blockIndexesTable = reinterpret_cast<int*>(memoryBuffer+sizeof(BlockHeader));
......@@ -107,10 +109,11 @@ public:
// Redirect pointer to data
blockHeader->attributeOffset = (sizeof(AttributeClass) * blockHeader->nbParticlesAllocatedInGroup);
unsigned char* previousPointer = reinterpret_cast<unsigned char*>(particlePosition[2] + blockHeader->nbParticlesAllocatedInGroup);
for(unsigned idxAttribute = 0 ; idxAttribute < NbAttributesPerParticle ; ++idxAttribute){
particleAttributes[idxAttribute] = reinterpret_cast<AttributeClass*>(previousPointer);
previousPointer += sizeof(AttributeClass)*blockHeader->nbParticlesAllocatedInGroup;
if(inAttributes){
attributesBuffer = (AttributeClass*)inAttributes;
for(unsigned idxAttribute = 0 ; idxAttribute < NbAttributesPerParticle ; ++idxAttribute){
particleAttributes[idxAttribute] = &attributesBuffer[idxAttribute*(blockHeader->nbParticlesAllocatedInGroup/sizeof(AttributeClass))];
}
}
}
......@@ -132,7 +135,7 @@ public:
const int blockIndexesTableSize = int(inEndingIndex-inStartingIndex);
FAssertLF(inNumberOfLeaves <= blockIndexesTableSize);
// Total number of bytes in the block
const size_t sizeOfOneParticle = (3*sizeof(FReal) + NbAttributesPerParticle*sizeof(AttributeClass));
const size_t sizeOfOneParticle = (3*sizeof(FReal));
const size_t memoryToAlloc = sizeof(BlockHeader)
+ (blockIndexesTableSize*sizeof(int))
+ (inNumberOfLeaves*sizeof(LeafHeader))
......@@ -166,10 +169,11 @@ public:
// Redirect pointer to data
blockHeader->attributeOffset = (sizeof(AttributeClass) * nbParticlesAllocatedInGroup);
unsigned char* previousPointer = reinterpret_cast<unsigned char*>(particlePosition[2] + nbParticlesAllocatedInGroup);
attributesBuffer = (AttributeClass*)FAlignedMemory::Allocate32BAligned(blockHeader->attributeOffset*NbAttributesPerParticle);
memset(attributesBuffer, 0, blockHeader->attributeOffset*NbAttributesPerParticle);
for(unsigned idxAttribute = 0 ; idxAttribute < NbAttributesPerParticle ; ++idxAttribute){
particleAttributes[idxAttribute] = reinterpret_cast<AttributeClass*>(previousPointer);
previousPointer += sizeof(AttributeClass)*nbParticlesAllocatedInGroup;
particleAttributes[idxAttribute] = &attributesBuffer[idxAttribute*(blockHeader->nbParticlesAllocatedInGroup/sizeof(AttributeClass))];
}
// Set all index to not used
......@@ -182,6 +186,7 @@ public:
~FGroupOfParticles(){
if(deleteBuffer){
FAlignedMemory::Dealloc32BAligned(memoryBuffer);
FAlignedMemory::Dealloc32BAligned(attributesBuffer);
}
}
......@@ -195,6 +200,16 @@ public:
return allocatedMemoryInByte;
}
/** Give access to the buffer to send the data */
const AttributeClass* getRawAttributesBuffer() const{
return attributesBuffer;
}
/** The the size of the allocated buffer */
int getAttributesBufferSizeInByte() const {
return blockHeader->attributeOffset*NbAttributesPerParticle;
}
/** To know if the object will delete the memory block */
bool getDeleteMemory() const{
return deleteBuffer;
......
......@@ -17,12 +17,13 @@
template <class CellClass, class GroupAttachedLeafClass, unsigned NbAttributesPerParticle, class AttributeClass = FReal>
template <class CompositeCellClass, class SymboleCellClass, class PoleCellClass, class LocalCellClass,
class GroupAttachedLeafClass, unsigned NbAttributesPerParticle, class AttributeClass = FReal>
class FGroupTree {
public:
typedef GroupAttachedLeafClass BasicAttachedClass;
typedef FGroupOfParticles<NbAttributesPerParticle,AttributeClass> ParticleGroupClass;
typedef FGroupOfCells<CellClass> CellGroupClass;
typedef FGroupOfCells<CompositeCellClass, SymboleCellClass, PoleCellClass, LocalCellClass> CellGroupClass;
protected:
//< This value is for not used cells
......@@ -78,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>
template<class OctreeClass, class CellClass>
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)),
......@@ -119,9 +120,9 @@ public:
const CellClass*const oldNode = blockIteratorInOctree.getCurrentCell();
newBlock->newCell(oldNode->getMortonIndex(), cellIdInBlock);
CellClass* newNode = newBlock->getCell(oldNode->getMortonIndex());
newNode->setMortonIndex(oldNode->getMortonIndex());
newNode->setCoordinate(oldNode->getCoordinate());
CompositeCellClass newNode = newBlock->getCompleteCell(oldNode->getMortonIndex());
newNode.setMortonIndex(oldNode->getMortonIndex());
newNode.setCoordinate(oldNode->getCoordinate());
// Add leaf
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(oldNode->getMortonIndex(), cellIdInBlock,
......@@ -168,9 +169,9 @@ public:
const CellClass*const oldNode = blockIteratorInOctree.getCurrentCell();
newBlock->newCell(oldNode->getMortonIndex(), cellIdInBlock);
CellClass* newNode = newBlock->getCell(oldNode->getMortonIndex());
newNode->setMortonIndex(oldNode->getMortonIndex());
newNode->setCoordinate(oldNode->getCoordinate());
CompositeCellClass newNode = newBlock->getCompleteCell(oldNode->getMortonIndex());
newNode.setMortonIndex(oldNode->getMortonIndex());
newNode.setCoordinate(oldNode->getCoordinate());
cellIdInBlock += 1;
blockIteratorInOctree.moveRight();
......@@ -274,11 +275,11 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CellClass* newNode = newBlock->getCell(currentBlockIndexes[cellIdInBlock]);
newNode->setMortonIndex(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
newNode->setCoordinate(coord);
newNode.setCoordinate(coord);
// Add leaf
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(currentBlockIndexes[cellIdInBlock], cellIdInBlock,
......@@ -344,11 +345,11 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CellClass* newNode = newBlock->getCell(currentBlockIndexes[cellIdInBlock]);
newNode->setMortonIndex(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
newNode->setCoordinate(coord);
newNode.setCoordinate(coord);
}
// Keep the block
......@@ -453,11 +454,11 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CellClass* newNode = newBlock->getCell(currentBlockIndexes[cellIdInBlock]);
newNode->setMortonIndex(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
newNode->setCoordinate(coord);
newNode.setCoordinate(coord);
// Add leaf
nbParticlesOffsetBeforeLeaf = newParticleBlock->newLeaf(currentBlockIndexes[cellIdInBlock], cellIdInBlock,
......@@ -537,11 +538,11 @@ public:
for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){
newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock);
CellClass* newNode = newBlock->getCell(currentBlockIndexes[cellIdInBlock]);
newNode->setMortonIndex(currentBlockIndexes[cellIdInBlock]);
CompositeCellClass newNode = newBlock->getCompleteCell(currentBlockIndexes[cellIdInBlock]);
newNode.setMortonIndex(currentBlockIndexes[cellIdInBlock]);
FTreeCoordinate coord;
coord.setPositionFromMorton(currentBlockIndexes[cellIdInBlock], idxLevel);
newNode->setCoordinate(coord);
newNode.setCoordinate(coord);
}
// Keep the block
......@@ -589,7 +590,7 @@ public:
* @brief forEachLeaf iterate on the cell and apply the function
* @param function
*/
void forEachCell(std::function<void(CellClass*)> function){
void forEachCell(std::function<void(CompositeCellClass)> function){
for(int idxLevel = 0 ; idxLevel < treeHeight ; ++idxLevel){
std::vector<CellGroupClass*>& levelBlocks = cellBlocksPerLevel[idxLevel];
for (CellGroupClass* block: levelBlocks){
......@@ -602,7 +603,7 @@ public:
* @brief forEachLeaf iterate on the cell and apply the function
* @param function
*/
void forEachCellWithLevel(std::function<void(CellClass*,const int)> function){
void forEachCellWithLevel(std::function<void(CompositeCellClass,const int)> function){
for(int idxLevel = 0 ; idxLevel < treeHeight ; ++idxLevel){
std::vector<CellGroupClass*>& levelBlocks = cellBlocksPerLevel[idxLevel];
for (CellGroupClass* block: levelBlocks){
......@@ -616,7 +617,7 @@ public:
* @param function
*/
template<class ParticlesAttachedClass>
void forEachCellLeaf(std::function<void(CellClass*,ParticlesAttachedClass*)> function){
void forEachCellLeaf(std::function<void(CompositeCellClass,ParticlesAttachedClass*)> function){
CellGroupIterator iterCells = cellBlocksPerLevel[treeHeight-1].begin();
const CellGroupIterator iterEndCells = cellBlocksPerLevel[treeHeight-1].end();
......@@ -624,8 +625,8 @@ public:
const ParticleGroupIterator iterEndLeaves = particleBlocks.end();
while(iterCells != iterEndCells && iterLeaves != iterEndLeaves){
(*iterCells)->forEachCell([&](CellClass* aCell){
ParticlesAttachedClass aLeaf = (*iterLeaves)->template getLeaf <ParticlesAttachedClass>(aCell->getMortonIndex());
(*iterCells)->forEachCell([&](CompositeCellClass aCell){
ParticlesAttachedClass aLeaf = (*iterLeaves)->template getLeaf <ParticlesAttachedClass>(aCell.getMortonIndex());
FAssertLF(aLeaf.isAttachedToSomething());
function(aCell, &aLeaf);
});
......
......@@ -7,76 +7,85 @@
#include "../StarPUUtils/FStarPUDefaultAlign.hpp"
struct alignas(FStarPUDefaultAlign::StructAlign) FTestCellPODCore {
FTestCellPODCore(){
mortonIndex = (0);
coordinates[0] = 0;
coordinates[1] = 0;
coordinates[2] = 0;
}
MortonIndex mortonIndex;
int coordinates[3];
long long int dataUp, dataDown;
};
class alignas(FStarPUDefaultAlign::StructAlign) FTestCellPOD {
typedef long long FTestCellPODData;
class FTestCellPOD {
protected:
FTestCellPODCore data;
FTestCellPODCore* symb;
FTestCellPODData* up;
FTestCellPODData* down;
public:
FTestCellPOD() {
data.mortonIndex = (0);
data.dataUp = (0);
data.dataDown = (0);
data.coordinates[0] = 0;
data.coordinates[1] = 0;
data.coordinates[2] = 0;
FTestCellPOD(FTestCellPODCore* inSymb, FTestCellPODData* inUp,
FTestCellPODData* inDown)
: symb(inSymb), up(inUp), down(inDown){
}
FTestCellPOD()
: symb(nullptr), up(nullptr), down(nullptr){
}
/** To get the morton index */
MortonIndex getMortonIndex() const {
return data.mortonIndex;
return symb->mortonIndex;
}
/** To set the morton index */
void setMortonIndex(const MortonIndex inMortonIndex) {
data.mortonIndex = inMortonIndex;
symb->mortonIndex = inMortonIndex;
}
/** To get the position */
FTreeCoordinate getCoordinate() const {
return FTreeCoordinate(data.coordinates[0],
data.coordinates[1], data.coordinates[2]);
return FTreeCoordinate(symb->coordinates[0],
symb->coordinates[1], symb->coordinates[2]);
}
/** To set the position */
void setCoordinate(const FTreeCoordinate& inCoordinate) {
data.coordinates[0] = inCoordinate.getX();
data.coordinates[1] = inCoordinate.getY();
data.coordinates[2] = inCoordinate.getZ();
symb->coordinates[0] = inCoordinate.getX();
symb->coordinates[1] = inCoordinate.getY();
symb->coordinates[2] = inCoordinate.getZ();
}
/** To set the position from 3 FReals */
void setCoordinate(const int inX, const int inY, const int inZ) {
data.coordinates[0] = inX;
data.coordinates[1] = inY;
data.coordinates[2] = inZ;
symb->coordinates[0] = inX;
symb->coordinates[1] = inY;
symb->coordinates[2] = inZ;
}
/** When doing the upward pass */
long long int getDataUp() const {
return data.dataUp;
return (*up);
}
/** When doing the upward pass */
void setDataUp(const long long int inData){
data.dataUp = inData;
(*up) = inData;
}
/** When doing the downard pass */
long long int getDataDown() const {
return data.dataDown;
return (*down);
}
/** When doing the downard pass */
void setDataDown(const long long int inData){
data.dataDown = inData;
(*down) = inData;
}
/** Make it like the begining */
void resetToInitialState(){
data.dataDown = 0;
data.dataUp = 0;
(*down) = 0;
(*up) = 0;
}
/////////////////////////////////////////////////
......@@ -84,23 +93,23 @@ public:
/** Save the current cell in a buffer */
template <class BufferWriterClass>
void save(BufferWriterClass& buffer) const{
buffer << data.mortonIndex << data.coordinates[0]
<< data.coordinates[1] << data.coordinates[2];
buffer << data.dataDown << data.dataUp;
buffer << symb->mortonIndex << symb->coordinates[0]
<< symb->coordinates[1] << symb->coordinates[2];
buffer << (*down) << (*up);
}
/** Restore the current cell from a buffer */
template <class BufferReaderClass>
void restore(BufferReaderClass& buffer){
buffer >> data.mortonIndex >> data.coordinates[0]
>> data.coordinates[1] >> data.coordinates[2];
buffer >> data.dataDown >> data.dataUp;
buffer >> symb->mortonIndex >> symb->coordinates[0]
>> symb->coordinates[1] >> symb->coordinates[2];
buffer >> (*down) >> (*up);
}
int getSavedSize() const {
return int(sizeof(data.mortonIndex) + sizeof(data.coordinates[0]) +
sizeof(data.coordinates[1]) + sizeof(data.coordinates[2]) +
sizeof(data.dataDown) + sizeof(data.dataUp));
return int(sizeof(symb->mortonIndex) + sizeof(symb->coordinates[0]) +
sizeof(symb->coordinates[1]) + sizeof(symb->coordinates[2]) +
sizeof((*down)) + sizeof((*up)));
}
/////////////////////////////////////////////////
......@@ -108,35 +117,34 @@ public:
/** Serialize only up data in a buffer */
template <class BufferWriterClass>
void serializeUp(BufferWriterClass& buffer) const {
buffer << data.dataUp;
buffer << (*up);
}
/** Deserialize only up data in a buffer */
template <class BufferReaderClass>
void deserializeUp(BufferReaderClass& buffer){
buffer >> data.dataUp;
buffer >> (*up);
}
/** Serialize only down data in a buffer */
template <class BufferWriterClass>
void serializeDown(BufferWriterClass& buffer) const {
buffer << data.dataDown;
buffer << (*down);
}
/** Deserialize only up data in a buffer */
template <class BufferReaderClass>
void deserializeDown(BufferReaderClass& buffer){
buffer >> data.dataDown;
buffer >> (*down);
}
int getSavedSizeDown() {
return int(sizeof(long long int));
return int(sizeof(FTestCellPODData));
}
int getSavedSizeUp() {
return int(sizeof(long long int));
return int(sizeof(FTestCellPODData));
}
};
static_assert(sizeof(FTestCellPODCore) == sizeof(FTestCellPOD), "Core should be equal to cell class size");
#endif // FTESTCELLPOD_HPP
......@@ -25,6 +25,8 @@
#ifdef ScalFMM_USE_STARPU
#include "../../Src/GroupTree/Core/FGroupTaskStarpuAlgorithm.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUKernelCapacities.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUCpuWrapper.hpp"
#endif
#include "../../Src/GroupTree/Core/FP2PGroupParticleContainer.hpp"
#include "../../Src/GroupTree/Core/FGroupTaskAlgorithm.hpp"
......@@ -35,6 +37,7 @@
#include "../../Src/Components/FTestCell.hpp"
#include "../../Src/Components/FTestKernels.hpp"
#include "../../Src/GroupTree/TestKernel/FGroupTestParticleContainer.hpp"
#include "../../Src/GroupTree/TestKernel/FTestCellPOD.hpp"
#include "../../Src/Files/FFmaGenericLoader.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
......@@ -48,12 +51,19 @@ int main(int argc, char* argv[]){
FParameterDefinitions::OctreeHeight, FParameterDefinitions::NbThreads,
FParameterDefinitions::NbParticles, LocalOptionBlocSize);
// Initialize the types
typedef FTestCell GroupCellClass;
typedef FTestCellPODCore GroupCellSymbClass;
typedef FTestCellPODData GroupCellUpClass;
typedef FTestCellPODData GroupCellDownClass;
typedef FTestCellPOD GroupCellClass;
typedef FGroupTestParticleContainer GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupContainerClass, 2, long long int> GroupOctreeClass;
typedef FGroupTree< GroupCellClass, GroupCellSymbClass, GroupCellUpClass, GroupCellDownClass,
GroupContainerClass, 2, long long int> GroupOctreeClass;
#ifdef ScalFMM_USE_STARPU
typedef FStarPUAllYesCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm;
typedef FStarPUAllCpuCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> 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 FTestKernels< GroupCellClass, GroupContainerClass > GroupKernelClass;
// Set the number of threads
......@@ -111,14 +121,14 @@ int main(int argc, char* argv[]){
groupedTree.printInfoBlocks();
// Check tree structure at leaf level
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass* gcell, FGroupTestParticleContainer* gleaf){
const ContainerClass* src = tree.getLeafSrc(gcell->getMortonIndex());
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass gcell, FGroupTestParticleContainer* gleaf){
const ContainerClass* src = tree.getLeafSrc(gcell.getMortonIndex());
if(src == nullptr){
std::cout << "[PartEmpty] Error cell should not exist " << gcell->getMortonIndex() << "\n";
std::cout << "[PartEmpty] Error cell should not exist " << gcell.getMortonIndex() << "\n";
}
else {
if(src->getNbParticles() != gleaf->getNbParticles()){
std::cout << "[Part] Nb particles is different at index " << gcell->getMortonIndex() << " is " << gleaf->getNbParticles() << " should be " << src->getNbParticles() << "\n";
std::cout << "[Part] Nb particles is different at index " << gcell.getMortonIndex() << " is " << gleaf->getNbParticles() << " should be " << src->getNbParticles() << "\n";
}
}
});
......@@ -134,33 +144,33 @@ int main(int argc, char* argv[]){
algo.execute();
// Validate the result
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass* cell, FGroupTestParticleContainer* leaf){
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass cell, FGroupTestParticleContainer* leaf){
const int nbPartsInLeaf = leaf->getNbParticles();
if(cell->getDataUp() != nbPartsInLeaf){
std::cout << "[P2M] Error a Cell has " << cell->getDataUp() << " (it should be " << nbPartsInLeaf << ")\n";
if(cell.getDataUp() != nbPartsInLeaf){
std::cout << "[P2M] Error a Cell has " << cell.getDataUp() << " (it should be " << nbPartsInLeaf << ")\n";
}
});
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass* cell, FGroupTestParticleContainer* leaf){
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass cell, FGroupTestParticleContainer* leaf){
const int nbPartsInLeaf = leaf->getNbParticles();
const long long int* dataDown = leaf->getDataDown();
for(int idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){
if(dataDown[idxPart] != loader.getNumberOfParticles()-1){
std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (loader.getNumberOfParticles()-1) << ") at index " << cell->getMortonIndex() << "\n";
std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (loader.getNumberOfParticles()-1) << ") at index " << cell.getMortonIndex() << "\n";
}
}
});
// Compare the results
groupedTree.forEachCellWithLevel([&](GroupCellClass* gcell, const int level){
const CellClass* cell = tree.getCell(gcell->getMortonIndex(), level);
groupedTree.forEachCellWithLevel([&](GroupCellClass gcell, const int level){
const CellClass* cell = tree.getCell(gcell.getMortonIndex(), level);
if(cell == nullptr){
std::cout << "[Empty] Error cell should not exist " << gcell->getMortonIndex() << "\n";
std::cout << "[Empty] Error cell should not exist " << gcell.getMortonIndex() << "\n";
}
else {
if(gcell->getDataUp() != cell->getDataUp()){
std::cout << "[Up] Up is different at index " << gcell->getMortonIndex() << " level " << level << " is " << gcell->getDataUp() << " should be " << cell->getDataUp() << "\n";
if(gcell.getDataUp() != cell->getDataUp()){
std::cout << "[Up] Up is different at index " << gcell.getMortonIndex() << " level " << level << " is " << gcell.getDataUp() << " should be " << cell->getDataUp() << "\n";
}
if(gcell->getDataDown() != cell->getDataDown()){
std::cout << "[Down] Down is different at index " << gcell->getMortonIndex() << " level " << level << " is " << gcell->getDataDown() << " should be " << cell->getDataDown() << "\n";
if(gcell.getDataDown() != cell->getDataDown()){
std::cout << "[Down] Down is different at index " << gcell.getMortonIndex() << " level " << level << " is " << gcell.getDataDown() << " should be " << cell->getDataDown() << "\n";
}
}
});
......
......@@ -28,16 +28,19 @@
#include "../../Src/Utils/FParameterNames.hpp"
#include "../../Src/Components/FTestParticleContainer.hpp"
#include "../../Src/Components/FTestCell.hpp"
#include "../../Src/Components/FTestKernels.hpp"
#include "../../Src/Components/FTestCell.hpp"
#include "../../Src/GroupTree/TestKernel/FGroupTestParticleContainer.hpp"
#include "../../Src/GroupTree/TestKernel/FTestCellPOD.hpp"
#include "../../Src/BalanceTree/FLeafBalance.hpp"
#include "../../Src/Files/FMpiTreeBuilder.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUKernelCapacities.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUCpuWrapper.hpp"
int getTreeCoordinate(const FReal inRelativePosition, const FReal boxWidth,
......@@ -75,11 +78,17 @@ int main(int argc, char* argv[]){
FParameterDefinitions::NbParticles, FParameterDefinitions::NbThreads,
LocalOptionBlocSize);
// Initialize the types
typedef FTestCell GroupCellClass;
typedef FTestCellPODCore GroupCellSymbClass;
typedef FTestCellPODData GroupCellUpClass;
typedef FTestCellPODData GroupCellDownClass;
typedef FTestCellPOD GroupCellClass;
typedef FGroupTestParticleContainer GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupContainerClass, 2, long long int> GroupOctreeClass;
typedef FStarPUAllYesCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FGroupTaskStarPUMpiAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm;
typedef FGroupTree< GroupCellClass, GroupCellSymbClass, GroupCellUpClass, GroupCellDownClass,
GroupContainerClass, 2, long long int> GroupOctreeClass;
typedef FStarPUAllCpuCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FStarPUCpuWrapper<typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass> GroupCpuWrapper;
typedef FGroupTaskStarPUMpiAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupCpuWrapper, GroupContainerClass > GroupAlgorithm;
FMpi mpiComm(argc, argv);
// Get params
......@@ -155,12 +164,12 @@ int main(int argc, char* argv[]){
GroupAlgorithm groupalgo(mpiComm.global(), &groupedTree,&groupkernel,maxThreads);
groupalgo.execute();
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass* cell, FGroupTestParticleContainer* leaf){
groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass cell, FGroupTestParticleContainer* leaf){
const int nbPartsInLeaf = leaf->getNbParticles();
const long long int* dataDown = leaf->getDataDown();
for(int idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){
if(dataDown[idxPart] != totalNbParticles-1){
std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (totalNbParticles-1) << ") at index " << cell->getMortonIndex() << "\n";
std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (totalNbParticles-1) << ") at index " << cell.getMortonIndex() << "\n";
}
}
});
......@@ -186,25 +195,25 @@ int main(int argc, char* argv[]){
// algo.execute();
// // Validate the result
// groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass* cell, FGroupTestParticleContainer* leaf){
// groupedTree.forEachCellLeaf<FGroupTestParticleContainer>([&](GroupCellClass cell, FGroupTestParticleContainer* leaf){
// const int nbPartsInLeaf = leaf->getNbParticles();
// if(cell->getDataUp() != nbPartsInLeaf){
// std::cout << "[P2M] Error a Cell has " << cell->getDataUp() << " (it should be " << nbPartsInLeaf << ")\n";
// if(cell.getDataUp() != nbPartsInLeaf){
// std::cout << "[P2M] Error a Cell has " << cell.getDataUp() << " (it should be " << nbPartsInLeaf << ")\n";
// }
// });
// // Compare the results
// groupedTree.forEachCellWithLevel([&](GroupCellClass* gcell, const int level){
// const CellClass* cell = tree.getCell(gcell->getMortonIndex(), level);
// groupedTree.forEachCellWithLevel([&](GroupCellClass gcell, const int level){
// const CellClass* cell = tree.getCell(gcell.getMortonIndex(), level);
// if(cell == nullptr){
// std::cout << "[Empty] Error cell should not exist " << gcell->getMortonIndex() << "\n";
// std::cout << "[Empty] Error cell should not exist " << gcell.getMortonIndex() << "\n";
// }
// else {
// if(gcell->getDataUp() != cell->getDataUp()){
// std::cout << "[Up] Up is different at index " << gcell->getMortonIndex() << " level " << level << " is " << gcell->getDataUp() << " should be " << cell->getDataUp() << "\n";
// if(gcell.getDataUp() != cell->getDataUp()){
// std::cout << "[Up] Up is different at index " << gcell.getMortonIndex() << " level " << level << " is " << gcell.getDataUp() << " should be " << cell->getDataUp() << "\n";
// }
// // if(gcell->getDataDown() != cell->getDataDown()){
// // std::cout << "[Down] Down is different at index " << gcell->getMortonIndex() << " level " << level << " is " << gcell->getDataDown() << " should be " << cell->getDataDown() << "\n";
// // if(gcell.getDataDown() != cell->getDataDown()){
// // std::cout << "[Down] Down is different at index " << gcell.getMortonIndex() << " level " << level << " is " << gcell.getDataDown() << " should be " << cell->getDataDown() << "\n";
// // }
// }
// });
......@@ -226,17 +235,17 @@ int main(int argc, char* argv[]){
algo.execute();
// Compare the results
groupedTree.forEachCellWithLevel([&](GroupCellClass* gcell, const int level){