testP2PEfficency.cpp 3.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
// ===================================================================================
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas, Matthias Messner
// 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
// abiding by the rules of distribution of free software.
//
// 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.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================

#include <iostream>
#include <iomanip>

#include <cstdio>  //printf
#include <cstdlib>
#include <cstring>  //memset

#include <cmath>
#include <algorithm>
#include <string>

#include  "ScalFmmConfig.h"
#include "../../Src/Utils/FTic.hpp"
#include "../../Src/Utils/FMath.hpp"
#include "../../Src/Utils/FParameters.hpp"
#include "../../Src/Utils/FParameterNames.hpp"
#include "../../Src/Utils/FIOVtk.hpp"

#include "../../Src/Containers/FOctree.hpp"
#include "../../Src/Files/FRandomLoader.hpp"

#include "../../Src/Kernels/P2P/FP2PR.hpp"
#include "../../Src/Kernels/P2P/FP2PParticleContainerIndexed.hpp"

// Simply create particles and try the kernels
int main(int argc, char ** argv){
    FHelpDescribeAndExit(argc, argv,
                         ">> This executable test the efficiency of the computation of the P2P",
                         FParameterDefinitions::NbParticles);

    const int nbParticles = FParameters::getValue(argc, argv, FParameterDefinitions::NbParticles.options, 1000);
    std::cout << "Test with " << nbParticles << " particles." << std::endl;

    //////////////////////////////////////////////////////////

    FRandomLoader loader(nbParticles*2);

    FTic timer;
    FP2PParticleContainer<> leaf1;
    for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
        FPoint pos;
        loader.fillParticle(&pos);
        leaf1.push(pos, 1.0);
    }

    FP2PParticleContainer<> leaf2;
    for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
        FPoint pos;
        loader.fillParticle(&pos);
        leaf2.push(pos, 1.0);
    }
    FP2PParticleContainer<> * const pleaf2 = &leaf2;
    std::cout << "Timer taken to create and insert the particles = " << timer.tacAndElapsed() << "s" << std::endl;

    //////////////////////////////////////////////////////////

    timer.tic();
BRAMAS Berenger's avatar
BRAMAS Berenger committed
75
    FP2PRT<FReal>::FullMutual<FP2PParticleContainer<>>( &leaf1, &pleaf2, 1);
76 77 78 79
    timer.tac();
    std::cout << "Timer taken by FullMutual = " << timer.elapsed() << "s" << std::endl;

    timer.tic();
BRAMAS Berenger's avatar
BRAMAS Berenger committed
80
    FP2PRT<FReal>::FullRemote<FP2PParticleContainer<>>( &leaf1, &pleaf2, 1);
81 82 83 84 85 86 87
    timer.tac();
    std::cout << "Timer taken by FullRemote = " << timer.elapsed() << "s" << std::endl;

    //////////////////////////////////////////////////////////

    return 0;
}