Commit 5b32a526 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Use inc method to access memory part in cell blocks

parent 13350c58
......@@ -74,9 +74,14 @@ public:
// Move the pointers to the correct position
allocatedMemoryInByte = (inAllocatedMemoryInByte);
memoryBuffer = (inBuffer);
blockHeader = reinterpret_cast<BlockHeader*>(memoryBuffer);
blockIndexesTable = reinterpret_cast<int*>(memoryBuffer+sizeof(BlockHeader));
blockCells = reinterpret_cast<SymboleCellClass*>(memoryBuffer+sizeof(BlockHeader)+(blockHeader->blockIndexesTableSize*sizeof(int)));
blockHeader = reinterpret_cast<BlockHeader*>(inBuffer);
inBuffer += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(inBuffer);
inBuffer += (blockHeader->blockIndexesTableSize*sizeof(int));
blockCells = reinterpret_cast<SymboleCellClass*>(inBuffer);
inBuffer += (sizeof(SymboleCellClass)*blockHeader->numberOfCellsInBlock);
FAssertLF(size_t(inBuffer-memoryBuffer) == allocatedMemoryInByte);
cellMultipoles = (PoleCellClass*)inCellMultipoles;
cellLocals = (LocalCellClass*)inCellLocals;
deleteBuffer = (false);
......@@ -93,9 +98,14 @@ public:
blockHeader(nullptr), blockIndexesTable(nullptr), blockCells(nullptr),
cellMultipoles(nullptr), cellLocals(nullptr), deleteBuffer(false){
// Move the pointers to the correct position
blockHeader = reinterpret_cast<BlockHeader*>(memoryBuffer);
blockIndexesTable = reinterpret_cast<int*>(memoryBuffer+sizeof(BlockHeader));
blockCells = reinterpret_cast<SymboleCellClass*>(memoryBuffer+sizeof(BlockHeader)+(blockHeader->blockIndexesTableSize*sizeof(int)));
blockHeader = reinterpret_cast<BlockHeader*>(inBuffer);
inBuffer += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(inBuffer);
inBuffer += (blockHeader->blockIndexesTableSize*sizeof(int));
blockCells = reinterpret_cast<SymboleCellClass*>(inBuffer);
inBuffer += (sizeof(SymboleCellClass)*blockHeader->numberOfCellsInBlock);
FAssertLF(size_t(inBuffer-memoryBuffer) == allocatedMemoryInByte);
cellMultipoles = (PoleCellClass*)inCellMultipoles;
cellLocals = (LocalCellClass*)inCellLocals;
}
......@@ -123,9 +133,14 @@ public:
memset(memoryBuffer, 0, memoryToAlloc);
// Move the pointers to the correct position
blockHeader = reinterpret_cast<BlockHeader*>(memoryBuffer);
blockIndexesTable = reinterpret_cast<int*>(memoryBuffer+sizeof(BlockHeader));
blockCells = reinterpret_cast<SymboleCellClass*>(memoryBuffer+sizeof(BlockHeader)+(blockIndexesTableSize*sizeof(int)));
unsigned char* ptrBuff = memoryBuffer;
blockHeader = reinterpret_cast<BlockHeader*>(ptrBuff);
ptrBuff += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(ptrBuff);
ptrBuff += (blockIndexesTableSize*sizeof(int));
blockCells = reinterpret_cast<SymboleCellClass*>(ptrBuff);
ptrBuff += (sizeof(SymboleCellClass)*inNumberOfCells);
FAssertLF(size_t(ptrBuff-memoryBuffer) == allocatedMemoryInByte);
// Init header
blockHeader->startingIndex = inStartingIndex;
......
......@@ -53,9 +53,14 @@ public:
// Move the pointers to the correct position
allocatedMemoryInByte = (inAllocatedMemoryInByte);
memoryBuffer = (inBuffer);
blockHeader = reinterpret_cast<BlockHeader*>(memoryBuffer);
blockIndexesTable = reinterpret_cast<int*>(memoryBuffer+sizeof(BlockHeader));
blockCells = reinterpret_cast<SymboleCellClass*>(memoryBuffer+sizeof(BlockHeader)+(blockHeader->blockIndexesTableSize*sizeof(int)));
blockHeader = reinterpret_cast<BlockHeader*>(inBuffer);
inBuffer += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(inBuffer);
inBuffer += (blockHeader->blockIndexesTableSize*sizeof(int));
blockCells = reinterpret_cast<SymboleCellClass*>(inBuffer);
inBuffer += (sizeof(SymboleCellClass)*blockHeader->numberOfCellsInBlock);
//FAssertLF(size_t(inBuffer-memoryBuffer) == allocatedMemoryInByte);
cellMultipoles = (PoleCellClass*)inCellMultipoles;
cellLocals = (LocalCellClass*)inCellLocals;
}
......@@ -71,9 +76,14 @@ public:
blockHeader(nullptr), blockIndexesTable(nullptr), blockCells(nullptr),
cellMultipoles(nullptr), cellLocals(nullptr){
// Move the pointers to the correct position
blockHeader = reinterpret_cast<BlockHeader*>(memoryBuffer);
blockIndexesTable = reinterpret_cast<int*>(memoryBuffer+sizeof(BlockHeader));
blockCells = reinterpret_cast<SymboleCellClass*>(memoryBuffer+sizeof(BlockHeader)+(blockHeader->blockIndexesTableSize*sizeof(int)));
blockHeader = reinterpret_cast<BlockHeader*>(inBuffer);
inBuffer += sizeof(BlockHeader);
blockIndexesTable = reinterpret_cast<int*>(inBuffer);
inBuffer += (blockHeader->blockIndexesTableSize*sizeof(int));
blockCells = reinterpret_cast<SymboleCellClass*>(inBuffer);
inBuffer += (sizeof(SymboleCellClass)*blockHeader->numberOfCellsInBlock);
//FAssertLF(size_t(inBuffer-memoryBuffer) == allocatedMemoryInByte);
cellMultipoles = (PoleCellClass*)inCellMultipoles;
cellLocals = (LocalCellClass*)inCellLocals;
}
......
......@@ -409,9 +409,14 @@ struct FOpenCLGroupOfCells BuildFOpenCLGroupOfCells(__global unsigned char* inBu
group.allocatedMemoryInByte = (inAllocatedMemoryInByte);
// Move the pointers to the correct position
group.blockHeader = (__global struct FOpenCLGroupOfCellsBlockHeader*)(group.memoryBuffer);
group.blockIndexesTable = (__global int*)(group.memoryBuffer+sizeof(struct FOpenCLGroupOfCellsBlockHeader));
group.blockCells = (__global struct FSymboleCellClass*)(group.memoryBuffer+sizeof(struct FOpenCLGroupOfCellsBlockHeader)+(group.blockHeader->blockIndexesTableSize*sizeof(int)));
group.blockHeader = (__global struct FOpenCLGroupOfCellsBlockHeader*)(inBuffer);
inBuffer += sizeof(struct FOpenCLGroupOfCellsBlockHeader);
group.blockIndexesTable = (__global int*)(inBuffer);
inBuffer += (group.blockHeader->blockIndexesTableSize*sizeof(int));
group.blockCells = (__global struct FSymboleCellClass*)(inBuffer);
inBuffer += (group.blockHeader->numberOfCellsInBlock*sizeof(struct FSymboleCellClass));
// Assert(((size_t)(inBuffer-group.memoryBuffer) == inAllocatedMemoryInByte);
group.cellMultipoles = (__global FPoleCellClass*)inCellMultipoles;
group.cellLocals = (__global FLocalCellClass*)inCellLocals;
return group;
......
Supports Markdown
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