Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

FFmmAlgorithmThread.hpp 18.9 KB
Newer Older
1
// ===================================================================================
2
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas, Matthias Messner
3 4 5 6
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
7 8
// abiding by the rules of distribution of free software.
//
9 10 11 12
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public and CeCILL-C Licenses for more details.
13
// "http://www.cecill.info".
14
// "http://www.gnu.org/licenses".
15
// ===================================================================================
16 17
#ifndef FFMMALGORITHMTHREAD_HPP
#define FFMMALGORITHMTHREAD_HPP
18

19

BRAMAS Berenger's avatar
BRAMAS Berenger committed
20
#include "../Utils/FAssert.hpp"
BRAMAS Berenger's avatar
BRAMAS Berenger committed
21
#include "../Utils/FLog.hpp"
22

23 24
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
25
#include "Utils/FAlgorithmTimers.hpp"
26 27 28

#include "../Containers/FOctree.hpp"

29
#include "FCoreCommon.hpp"
30 31 32 33

#include <omp.h>

/**
34 35
* \author Berenger Bramas (berenger.bramas@inria.fr)
* \brief Implements an FMM algorithm threaded using OpenMP.
36
*
37
* Please read the license
38
*
39 40 41 42
* This class runs a threaded FMM algorithm.  It just iterates on a tree and call
* the kernels with good arguments.  The inspector-executor model is used : the
* class iterates on the tree and builds an array and works in parallel on this
* array.
43
*
berenger-bramas's avatar
berenger-bramas committed
44
* When using this algorithm the P2P is thread safe.
45 46
*
* This class does not deallocate pointers given to its constructor.
47
*/
48
template<class OctreeClass, class CellClass, class ContainerClass, class KernelClass, class LeafClass>
49
class FFmmAlgorithmThread : public FAbstractAlgorithm, public FAlgorithmTimers{
50 51
    OctreeClass* const tree;                  ///< The octree to work on.
    KernelClass** kernels;                    ///< The kernels.
52

berenger-bramas's avatar
berenger-bramas committed
53
    typename OctreeClass::Iterator* iterArray;
54
    int leafsNumber;
55 56

    static const int SizeShape = 3*3*3;
57
    int shapeLeaf[SizeShape];
berenger-bramas's avatar
berenger-bramas committed
58

59
    const int MaxThreads;                     ///< The maximum number of threads.
60

61
    const int OctreeHeight;                   ///< The height of the given tree.
62

63
public:
64 65 66 67 68 69 70 71
    /** Class constructor
     * 
     * The constructor needs the octree and the kernels used for computation.
     * \param inTree the octree to work on.
     * \param inKernels the kernels to call.
     *
     * \except An exception is thrown if one of the arguments is NULL.
     */
berenger-bramas's avatar
berenger-bramas committed
72
    FFmmAlgorithmThread(OctreeClass* const inTree, KernelClass* const inKernels)
73
        : tree(inTree) , kernels(nullptr), iterArray(nullptr), leafsNumber(0),
74
          MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()) {
75

BRAMAS Berenger's avatar
BRAMAS Berenger committed
76
        FAssertLF(tree, "tree cannot be null");
77

berenger-bramas's avatar
berenger-bramas committed
78
        this->kernels = new KernelClass*[MaxThreads];
79
        #pragma omp parallel for schedule(static)
berenger-bramas's avatar
berenger-bramas committed
80
        for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
81
            #pragma omp critical (InitFFmmAlgorithmThread)
82 83 84
            {
                this->kernels[idxThread] = new KernelClass(*inKernels);
            }
85 86
        }

87 88
        FAbstractAlgorithm::setNbLevelsInTree(tree->getHeight());

BRAMAS Berenger's avatar
BRAMAS Berenger committed
89
        FLOG(FLog::Controller << "FFmmAlgorithmThread (Max Thread " << omp_get_max_threads() << ")\n");
90 91 92 93
    }

    /** Default destructor */
    virtual ~FFmmAlgorithmThread(){
berenger-bramas's avatar
berenger-bramas committed
94
        for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
95 96
            delete this->kernels[idxThread];
        }
berenger-bramas's avatar
berenger-bramas committed
97
        delete [] this->kernels;
98 99
    }

100
protected:
101
    /**
102
      * Runs the complete algorithm.
103
      */
104
    void executeCore(const unsigned operationsToProceed) override {
105 106 107 108 109 110

        for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
            this->shapeLeaf[idxShape] = 0;
        }

        // Count leaf
111
        leafsNumber = 0;
berenger-bramas's avatar
berenger-bramas committed
112
        typename OctreeClass::Iterator octreeIterator(tree);
113 114
        octreeIterator.gotoBottomLeft();
        do{
115
            ++leafsNumber;
116
            const FTreeCoordinate& coord = octreeIterator.getCurrentCell()->getCoordinate();
117 118 119
            ++this->shapeLeaf[(coord.getX()%3)*9 + (coord.getY()%3)*3 + (coord.getZ()%3)];

        } while(octreeIterator.moveRight());
berenger-bramas's avatar
berenger-bramas committed
120
        iterArray = new typename OctreeClass::Iterator[leafsNumber];
BRAMAS Berenger's avatar
BRAMAS Berenger committed
121
        FAssertLF(iterArray, "iterArray bad alloc");
122

123
        Timers[P2MTimer].tic();
124
        if(operationsToProceed & FFmmP2M) bottomPass();
125
        Timers[P2MTimer].tac();
126

127
        Timers[M2MTimer].tic();
128
        if(operationsToProceed & FFmmM2M) upwardPass();
129
        Timers[M2MTimer].tac();
130

131
        Timers[M2LTimer].tic();
132
        if(operationsToProceed & FFmmM2L) transferPass();
133
        Timers[M2LTimer].tac();
134

135
        Timers[L2LTimer].tic();
136
        if(operationsToProceed & FFmmL2L) downardPass();
137
        Timers[L2LTimer].tac();
138

139 140 141
        Timers[NearTimer].tic();
        if( (operationsToProceed & FFmmP2P) || (operationsToProceed & FFmmL2P) ) directPass((operationsToProceed & FFmmP2P),(operationsToProceed & FFmmL2P));
        Timers[NearTimer].tac();
142 143

        delete [] iterArray;
144
        iterArray = nullptr;
145 146
    }

berenger-bramas's avatar
berenger-bramas committed
147 148 149 150
    /////////////////////////////////////////////////////////////////////////////
    // P2M
    /////////////////////////////////////////////////////////////////////////////

151
    /** Runs the P2M kernel. */
152
    void bottomPass(){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
153
        FLOG( FLog::Controller.write("\tStart Bottom Pass\n").write(FLog::Flush) );
BRAMAS Berenger's avatar
BRAMAS Berenger committed
154
        FLOG(FTic counterTime);
155

berenger-bramas's avatar
berenger-bramas committed
156
        typename OctreeClass::Iterator octreeIterator(tree);
157 158 159 160 161 162 163 164
        int leafs = 0;
        // Iterate on leafs
        octreeIterator.gotoBottomLeft();
        do{
            iterArray[leafs] = octreeIterator;
            ++leafs;
        } while(octreeIterator.moveRight());

165 166
        const int chunkSize = FMath::Max(1 , leafs/(omp_get_max_threads()*omp_get_max_threads()));

BRAMAS Berenger's avatar
BRAMAS Berenger committed
167
        FLOG(FTic computationCounter);
BRAMAS Berenger's avatar
BRAMAS Berenger committed
168
        #pragma omp parallel
169
        {
berenger-bramas's avatar
berenger-bramas committed
170
            KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
171
            #pragma omp for nowait schedule(dynamic, chunkSize)
172 173 174 175 176 177
            for(int idxLeafs = 0 ; idxLeafs < leafs ; ++idxLeafs){
                // We need the current cell that represent the leaf
                // and the list of particles
                myThreadkernels->P2M( iterArray[idxLeafs].getCurrentCell() , iterArray[idxLeafs].getCurrentListSrc());
            }
        }
BRAMAS Berenger's avatar
BRAMAS Berenger committed
178
        FLOG(computationCounter.tac() );
179

BRAMAS Berenger's avatar
BRAMAS Berenger committed
180 181
        FLOG( FLog::Controller << "\tFinished (@Bottom Pass (P2M) = "  << counterTime.tacAndElapsed() << "s)\n" );
        FLOG( FLog::Controller << "\t\t Computation : " << computationCounter.elapsed() << " s\n" );
182

183 184
    }

berenger-bramas's avatar
berenger-bramas committed
185 186 187 188
    /////////////////////////////////////////////////////////////////////////////
    // Upward
    /////////////////////////////////////////////////////////////////////////////

189
    /** Runs the M2M kernel. */
190
    void upwardPass(){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
191
        FLOG( FLog::Controller.write("\tStart Upward Pass\n").write(FLog::Flush); );
BRAMAS Berenger's avatar
BRAMAS Berenger committed
192 193
        FLOG(FTic counterTime);
        FLOG(FTic computationCounter);
194 195

        // Start from leal level - 1
berenger-bramas's avatar
berenger-bramas committed
196
        typename OctreeClass::Iterator octreeIterator(tree);
197 198
        octreeIterator.gotoBottomLeft();
        octreeIterator.moveUp();
199

200
        for(int idxLevel = OctreeHeight - 2 ; idxLevel > FAbstractAlgorithm::lowerWorkingLevel-1 ; --idxLevel){
201 202 203
            octreeIterator.moveUp();
        }

berenger-bramas's avatar
berenger-bramas committed
204
        typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
205 206

        // for each levels
207
        for(int idxLevel = FMath::Min(OctreeHeight - 2, FAbstractAlgorithm::lowerWorkingLevel - 1) ; idxLevel >= FAbstractAlgorithm::upperWorkingLevel ; --idxLevel ){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
208
            FLOG(FTic counterTimeLevel);
209
            int numberOfCells = 0;
210 211
            // for each cells
            do{
212 213
                iterArray[numberOfCells] = octreeIterator;
                ++numberOfCells;
214 215 216 217
            } while(octreeIterator.moveRight());
            avoidGotoLeftIterator.moveUp();
            octreeIterator = avoidGotoLeftIterator;// equal octreeIterator.moveUp(); octreeIterator.gotoLeft();

218 219
            const int chunkSize = FMath::Max(1 , numberOfCells/(omp_get_max_threads()*omp_get_max_threads()));

BRAMAS Berenger's avatar
BRAMAS Berenger committed
220
            FLOG(computationCounter.tic());
221
            #pragma omp parallel
222
            {
berenger-bramas's avatar
berenger-bramas committed
223
                KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
224
                #pragma omp for nowait  schedule(dynamic, chunkSize)
225
                for(int idxCell = 0 ; idxCell < numberOfCells ; ++idxCell){
226 227
                    // We need the current cell and the child
                    // child is an array (of 8 child) that may be null
228
                    myThreadkernels->M2M( iterArray[idxCell].getCurrentCell() , iterArray[idxCell].getCurrentChild(), idxLevel);
229 230
                }
            }
berenger-bramas's avatar
berenger-bramas committed
231

BRAMAS Berenger's avatar
BRAMAS Berenger committed
232
            FLOG(computationCounter.tac());
BRAMAS Berenger's avatar
BRAMAS Berenger committed
233
            FLOG( FLog::Controller << "\t\t>> Level " << idxLevel << " = "  << counterTimeLevel.tacAndElapsed() << "s\n" );
234 235
        }

berenger-bramas's avatar
berenger-bramas committed
236

BRAMAS Berenger's avatar
BRAMAS Berenger committed
237 238
        FLOG( FLog::Controller << "\tFinished (@Upward Pass (M2M) = "  << counterTime.tacAndElapsed() << "s)\n" );
        FLOG( FLog::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
239

240 241
    }

berenger-bramas's avatar
berenger-bramas committed
242
    /////////////////////////////////////////////////////////////////////////////
243
    // Transfer
berenger-bramas's avatar
berenger-bramas committed
244 245
    /////////////////////////////////////////////////////////////////////////////

246
    /** Runs the M2L kernel. */
247
    void transferPass(){
248

BRAMAS Berenger's avatar
BRAMAS Berenger committed
249
        FLOG( FLog::Controller.write("\tStart Downward Pass (M2L)\n").write(FLog::Flush); );
BRAMAS Berenger's avatar
BRAMAS Berenger committed
250 251
        FLOG(FTic counterTime);
        FLOG(FTic computationCounter);
berenger-bramas's avatar
berenger-bramas committed
252

253 254
        typename OctreeClass::Iterator octreeIterator(tree);
        octreeIterator.moveDown();
255

256
        for(int idxLevel = 2 ; idxLevel < FAbstractAlgorithm::upperWorkingLevel ; ++idxLevel){
257 258 259
            octreeIterator.moveDown();
        }

260 261 262
        typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);

        // for each levels
263
        for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < FAbstractAlgorithm::lowerWorkingLevel ; ++idxLevel ){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
264
            FLOG(FTic counterTimeLevel);
265 266 267 268 269 270 271 272 273
            int numberOfCells = 0;
            // for each cells
            do{
                iterArray[numberOfCells] = octreeIterator;
                ++numberOfCells;
            } while(octreeIterator.moveRight());
            avoidGotoLeftIterator.moveDown();
            octreeIterator = avoidGotoLeftIterator;

274 275
            const int chunkSize = FMath::Max(1 , numberOfCells/(omp_get_max_threads()*omp_get_max_threads()));

BRAMAS Berenger's avatar
BRAMAS Berenger committed
276
            FLOG(computationCounter.tic());
277
            #pragma omp parallel
278 279
            {
                KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
280
                const CellClass* neighbors[343];
281

282
                #pragma omp for  schedule(dynamic, chunkSize) nowait
283
                for(int idxCell = 0 ; idxCell < numberOfCells ; ++idxCell){
284
                    const int counter = tree->getInteractionNeighbors(neighbors,  iterArray[idxCell].getCurrentGlobalCoordinate(),idxLevel);
285
                    if(counter) myThreadkernels->M2L( iterArray[idxCell].getCurrentCell() , neighbors, counter, idxLevel);
286
                }
287 288

                myThreadkernels->finishedLevelM2L(idxLevel);
289
            }
BRAMAS Berenger's avatar
BRAMAS Berenger committed
290
            FLOG(computationCounter.tac());
BRAMAS Berenger's avatar
BRAMAS Berenger committed
291
            FLOG( FLog::Controller << "\t\t>> Level " << idxLevel << " = "  << counterTimeLevel.tacAndElapsed() << "s\n" );
292 293
        }

BRAMAS Berenger's avatar
BRAMAS Berenger committed
294 295
        FLOG( FLog::Controller << "\tFinished (@Downward Pass (M2L) = "  << counterTime.tacAndElapsed() << "s)\n" );
        FLOG( FLog::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
296
    }
berenger-bramas's avatar
berenger-bramas committed
297

298
    /////////////////////////////////////////////////////////////////////////////
COULAUD Olivier's avatar
COULAUD Olivier committed
299
    // Downward
300 301
    /////////////////////////////////////////////////////////////////////////////

302 303
    /** Runs the L2L kernel. */
    void downardPass(){
304

BRAMAS Berenger's avatar
BRAMAS Berenger committed
305
        FLOG( FLog::Controller.write("\tStart Downward Pass (L2L)\n").write(FLog::Flush); );
BRAMAS Berenger's avatar
BRAMAS Berenger committed
306 307
        FLOG(FTic counterTime);
        FLOG(FTic computationCounter);
308 309 310 311

        typename OctreeClass::Iterator octreeIterator(tree);
        octreeIterator.moveDown();

312
        for(int idxLevel = 2 ; idxLevel < FAbstractAlgorithm::upperWorkingLevel ; ++idxLevel){
313 314 315
            octreeIterator.moveDown();
        }

316 317
        typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);

318
        const int heightMinusOne = FAbstractAlgorithm::lowerWorkingLevel - 1;
COULAUD Olivier's avatar
COULAUD Olivier committed
319
        // for each levels excepted leaf level
320
        for(int idxLevel = FAbstractAlgorithm::upperWorkingLevel ; idxLevel < heightMinusOne ; ++idxLevel ){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
321
            FLOG(FTic counterTimeLevel);
322 323 324 325 326 327 328 329 330
            int numberOfCells = 0;
            // for each cells
            do{
                iterArray[numberOfCells] = octreeIterator;
                ++numberOfCells;
            } while(octreeIterator.moveRight());
            avoidGotoLeftIterator.moveDown();
            octreeIterator = avoidGotoLeftIterator;

BRAMAS Berenger's avatar
BRAMAS Berenger committed
331
            FLOG(computationCounter.tic());
332
            const int chunkSize = FMath::Max(1 , numberOfCells/(omp_get_max_threads()*omp_get_max_threads()));
333
            #pragma omp parallel
334 335
            {
                KernelClass * const myThreadkernels = kernels[omp_get_thread_num()];
336
                #pragma omp for nowait schedule(dynamic, chunkSize)
337 338
                for(int idxCell = 0 ; idxCell < numberOfCells ; ++idxCell){
                    myThreadkernels->L2L( iterArray[idxCell].getCurrentCell() , iterArray[idxCell].getCurrentChild(), idxLevel);
339 340
                }
            }
BRAMAS Berenger's avatar
BRAMAS Berenger committed
341
            FLOG(computationCounter.tac());
BRAMAS Berenger's avatar
BRAMAS Berenger committed
342
            FLOG( FLog::Controller << "\t\t>> Level " << idxLevel << " = "  << counterTimeLevel.tacAndElapsed() << "s\n" );
343 344
        }

BRAMAS Berenger's avatar
BRAMAS Berenger committed
345 346
        FLOG( FLog::Controller << "\tFinished (@Downward Pass (L2L) = "  << counterTime.tacAndElapsed() << "s)\n" );
        FLOG( FLog::Controller << "\t\t Computation : " << computationCounter.cumulated() << " s\n" );
347 348
    }

349 350


berenger-bramas's avatar
berenger-bramas committed
351 352 353 354
    /////////////////////////////////////////////////////////////////////////////
    // Direct
    /////////////////////////////////////////////////////////////////////////////

355 356 357 358 359
    /** Runs the P2P & L2P kernels.
      *
     * \param p2pEnabled Run the P2P kernel.
     * \param l2pEnabled Run the L2P kernel.
     */
360
    void directPass(const bool p2pEnabled, const bool l2pEnabled){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
361
        FLOG( FLog::Controller.write("\tStart Direct Pass\n").write(FLog::Flush); );
BRAMAS Berenger's avatar
BRAMAS Berenger committed
362 363 364
        FLOG(FTic counterTime);
        FLOG(FTic computationCounter);
        FLOG(FTic computationCounterP2P);
365

366
        omp_lock_t lockShape[SizeShape];
367
        for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
368
            omp_init_lock(&lockShape[idxShape]);
369 370
        }

371 372 373
        struct LeafData{
            MortonIndex index;
            CellClass* cell;
berenger-bramas's avatar
berenger-bramas committed
374 375
            ContainerClass* targets;
            ContainerClass* sources;
376 377 378
        };
        LeafData* const leafsDataArray = new LeafData[this->leafsNumber];

379
        const int LeafIndex = OctreeHeight - 1;
380 381 382 383 384 385 386

        int startPosAtShape[SizeShape];
        startPosAtShape[0] = 0;
        for(int idxShape = 1 ; idxShape < SizeShape ; ++idxShape){
            startPosAtShape[idxShape] = startPosAtShape[idxShape-1] + this->shapeLeaf[idxShape-1];
        }

387
        #pragma omp parallel
388
        {
389

390 391 392
            const float step = float(this->leafsNumber) / float(omp_get_num_threads());
            const int start = int(FMath::Ceil(step * float(omp_get_thread_num())));
            const int tempEnd = int(FMath::Ceil(step * float(omp_get_thread_num()+1)));
393
            const int end = (tempEnd > this->leafsNumber ? this->leafsNumber : tempEnd);
394

berenger-bramas's avatar
berenger-bramas committed
395
            typename OctreeClass::Iterator octreeIterator(tree);
396
            octreeIterator.gotoBottomLeft();
397 398 399 400 401

            for(int idxPreLeaf = 0 ; idxPreLeaf < start ; ++idxPreLeaf){
                octreeIterator.moveRight();
            }

402
            // for each leafs
403
            for(int idxMyLeafs = start ; idxMyLeafs < end ; ++idxMyLeafs){
404
                //iterArray[leafs] = octreeIterator;
405
                //++leafs;
406
                const FTreeCoordinate& coord = octreeIterator.getCurrentGlobalCoordinate();
407
                const int shapePosition = (coord.getX()%3)*9 + (coord.getY()%3)*3 + (coord.getZ()%3);
408

409 410 411
                omp_set_lock(&lockShape[shapePosition]);
                const int positionToWork = startPosAtShape[shapePosition]++;
                omp_unset_lock(&lockShape[shapePosition]);
412

COULAUD Olivier's avatar
COULAUD Olivier committed
413 414
                leafsDataArray[positionToWork].index   = octreeIterator.getCurrentGlobalIndex();
                leafsDataArray[positionToWork].cell    = octreeIterator.getCurrentCell();
415 416
                leafsDataArray[positionToWork].targets = octreeIterator.getCurrentListTargets();
                leafsDataArray[positionToWork].sources = octreeIterator.getCurrentListSrc();
417

418 419
                octreeIterator.moveRight();
            }
420

421
            #pragma omp barrier
422

BRAMAS Berenger's avatar
BRAMAS Berenger committed
423
            FLOG(if(!omp_get_thread_num()) computationCounter.tic());
424

berenger-bramas's avatar
berenger-bramas committed
425
            KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
426
            // There is a maximum of 26 neighbors
berenger-bramas's avatar
berenger-bramas committed
427
            ContainerClass* neighbors[27];
428
            int previous = 0;
429 430

            for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
431
                const int endAtThisShape = this->shapeLeaf[idxShape] + previous;
432 433
                const int chunkSize = FMath::Max(1 , endAtThisShape/(omp_get_num_threads()*omp_get_num_threads()));
                #pragma omp for schedule(dynamic, chunkSize)
434 435
                for(int idxLeafs = previous ; idxLeafs < endAtThisShape ; ++idxLeafs){
                    LeafData& currentIter = leafsDataArray[idxLeafs];
436 437 438 439 440 441 442 443 444 445 446
                    if(l2pEnabled){
                        myThreadkernels.L2P(currentIter.cell, currentIter.targets);
                    }
                    if(p2pEnabled){
                        // need the current particles and neighbors particles
                        FLOG(if(!omp_get_thread_num()) computationCounterP2P.tic());
                        const int counter = tree->getLeafsNeighbors(neighbors, currentIter.cell->getCoordinate(), LeafIndex);
                        myThreadkernels.P2P(currentIter.cell->getCoordinate(), currentIter.targets,
                                            currentIter.sources, neighbors, counter);
                        FLOG(if(!omp_get_thread_num()) computationCounterP2P.tac());
                    }
447
                }
448 449

                previous = endAtThisShape;
450 451
            }
        }
452

BRAMAS Berenger's avatar
BRAMAS Berenger committed
453
        FLOG(computationCounter.tac());
454

455
        delete [] leafsDataArray;
456 457 458 459
        for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
            omp_destroy_lock(&lockShape[idxShape]);
        }

460

BRAMAS Berenger's avatar
BRAMAS Berenger committed
461
        FLOG( FLog::Controller << "\tFinished (@Direct Pass (L2P + P2P) = "  << counterTime.tacAndElapsed() << "s)\n" );
COULAUD Olivier's avatar
COULAUD Olivier committed
462 463
        FLOG( FLog::Controller << "\t\t Computation L2P + P2P : " << computationCounter.cumulated()    << " s\n" );
        FLOG( FLog::Controller << "\t\t Computation P2P :       " << computationCounterP2P.cumulated() << " s\n" );
464

465 466 467 468 469 470
    }

};


#endif //FFMMALGORITHMTHREAD_HPP