Commit 24ced909 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Build intervals in task

parent e47c9ae9
......@@ -203,9 +203,20 @@ protected:
}
// Allocate the working buffer
std::unique_ptr<WorkloadTemp[]> workloadBuffer(new WorkloadTemp[leafsNumber]);
std::unique_ptr<WorkloadTemp*[]> workloadBufferThread(new WorkloadTemp*[MaxThreads]);
memset(workloadBufferThread.get(), 0, MaxThreads*sizeof(WorkloadTemp*));
#pragma omp parallel
{
#pragma omp single
{
#pragma omp task
{ // Prepare P2M
if(workloadBufferThread[omp_get_thread_num()] == nullptr){
workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber];
}
WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()];
/// FLOG(FLog::Controller << "[Balance] P2M:\n");
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
......@@ -221,10 +232,15 @@ protected:
++idxLeaf;
} while(octreeIterator.moveRight());
generateIntervalFromWorkload(&workloadP2M, totalWork, workloadBuffer.get(), idxLeaf);
generateIntervalFromWorkload(&workloadP2M, totalWork, workloadBuffer, idxLeaf);
}
#pragma omp task
{ // Prepare L2P
if(workloadBufferThread[omp_get_thread_num()] == nullptr){
workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber];
}
WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()];
/// FLOG(FLog::Controller << "[Balance] L2P:\n");
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
......@@ -240,10 +256,15 @@ protected:
++idxLeaf;
} while(octreeIterator.moveRight());
generateIntervalFromWorkload(&workloadL2P, totalWork, workloadBuffer.get(), idxLeaf);
generateIntervalFromWorkload(&workloadL2P, totalWork, workloadBuffer, idxLeaf);
}
#pragma omp task
{// Do it for the M2L
if(workloadBufferThread[omp_get_thread_num()] == nullptr){
workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber];
}
WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()];
/// FLOG(FLog::Controller << "[Balance] M2L:\n");
workloadM2L.resize(OctreeHeight);
typename OctreeClass::Iterator avoidGotoLeftIterator(tree);
......@@ -252,7 +273,7 @@ protected:
const CellClass* neighbors[343];
for(int idxLevel = OctreeHeight-1 ; idxLevel >= 2 ; --idxLevel){
FLOG(FLog::Controller << "[Balance] \t level " << idxLevel << ":\n");
/// FLOG(FLog::Controller << "[Balance] \t level " << idxLevel << ":\n");
typename OctreeClass::Iterator octreeIterator(avoidGotoLeftIterator);
avoidGotoLeftIterator.moveUp();
......@@ -269,10 +290,15 @@ protected:
} while(octreeIterator.moveRight());
// Now split between thread
generateIntervalFromWorkload(&workloadM2L[idxLevel], totalWork, workloadBuffer.get(), idxCell);
generateIntervalFromWorkload(&workloadM2L[idxLevel], totalWork, workloadBuffer, idxCell);
}
}
#pragma omp task
{// Do it for the M2M L2L
if(workloadBufferThread[omp_get_thread_num()] == nullptr){
workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber];
}
WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()];
/// FLOG(FLog::Controller << "[Balance] M2M L2L:\n");
workloadM2M.resize(OctreeHeight);
workloadL2L.resize(OctreeHeight);
......@@ -281,7 +307,7 @@ protected:
avoidGotoLeftIterator.moveUp();
for(int idxLevel = OctreeHeight-2 ; idxLevel >= 2 ; --idxLevel){
FLOG(FLog::Controller << "[Balance] \t level " << idxLevel << ":\n");
/// FLOG(FLog::Controller << "[Balance] \t level " << idxLevel << ":\n");
typename OctreeClass::Iterator octreeIterator(avoidGotoLeftIterator);
avoidGotoLeftIterator.moveUp();
......@@ -302,12 +328,17 @@ protected:
} while(octreeIterator.moveRight());
// Now split between thread
generateIntervalFromWorkload(&workloadM2M[idxLevel], totalWork, workloadBuffer.get(), idxCell);
generateIntervalFromWorkload(&workloadL2L[idxLevel], totalWork, workloadBuffer.get(), idxCell);
generateIntervalFromWorkload(&workloadM2M[idxLevel], totalWork, workloadBuffer, idxCell);
generateIntervalFromWorkload(&workloadL2L[idxLevel], totalWork, workloadBuffer, idxCell);
}
}
#pragma omp task
{
if(workloadBufferThread[omp_get_thread_num()] == nullptr){
workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber];
}
WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()];
// Prepare the P2P
const int LeafIndex = OctreeHeight - 1;
leafsDataArray.reset(new LeafData[leafsNumber]);
......@@ -391,6 +422,14 @@ protected:
}
}
#pragma omp barrier
}
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
delete[] workloadBufferThread[idxThread];
}
}
/////////////////////////////////////////////////////////////////////////////
// P2M
......
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