PerfTest.cpp 4.4 KB
Newer Older
1
2
3
4
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE

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

/**
 * \file
 * \author Quentin Khan
 *
 * This program is used to run different performance tests for the various
 * algorithms that have been implemented for ScalFMM.
 *
 * See the PerfUtils.hpp file classes for some more in depth information. Run
 * with argument --help for usage information.
 */


#include <iostream>
#include <string>

#include "Utils/FParameters.hpp"
#include "Utils/FParameterNames.hpp"

#include "PerfTestUtils.hpp"

#include "TreeLoaderFCheb.hpp"

#include "KernelLoaderFChebSym.hpp"

#include "AlgoLoaderThread.hpp"
#include "AlgoLoaderTask.hpp"
32
#include "AlgoLoaderSectionTask.hpp"
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "AlgoLoaderCostZones.hpp"

/**
 * \brief Runs a generic sequence of actions to use an algorithm.
 *
 * This function runs the basic steps that are needed to run an FMM algorithm
 * over a set of particles. It does the following steps :
 *
 *    - Load a tree using the class defined as a TreeLoader
 *    - Prepares the needed kernels using the KernelLoader
 *    - Prepares and runs the algorithm using the AlgorithmLoader
 *
 * See documentation of FTreeLoader, FKernelLoader, FAlgoLoader.
 */
template <class TreeLoader,
48
49
          template <typename TL_1> class KernelLoader,
          template <typename TL_2, template <typename TL_3> class KL> class AlgoLoader>
50
51
52
53
54
55
void runperf(FPerfTestParams& params)
{
    TreeLoader treeLoader(params);
    KernelLoader<TreeLoader> kernelLoader(params, treeLoader);
    AlgoLoader<TreeLoader, KernelLoader> algoLoader(params, treeLoader, kernelLoader);
    algoLoader.run();
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

    auto& algo = *(algoLoader._algo);
    std::cout << "@@ "
              << "algo:" << params.algo << " "
              << "file:" << params.filename.substr(params.filename.find_last_of('/')+1) << " "
              << "particles:" << treeLoader._loader.getNumberOfParticles() << " "
              << "threads:" << params.nbThreads                            << " "
              << "height:" << params.treeHeight                            << " "
              << "subheight:" << params.subTreeHeight                     << " "
              << algoLoader.getRunInfoString()
              << "P2M:" << algo.getTime(FAlgorithmTimers::P2MTimer)        << " "
              << "M2M:" << algo.getTime(FAlgorithmTimers::M2MTimer)        << " "
              << "M2L:" << algo.getTime(FAlgorithmTimers::M2LTimer)        << " "
              << "L2L:" << algo.getTime(FAlgorithmTimers::L2LTimer)        << " "
              << "P2PL2P:" << algo.getTime(FAlgorithmTimers::NearTimer)    << " "
              << std::endl;

73
74
75
76
77
78
79
80
81
82
}

int main (int argc, char** argv)
{
    FHelpDescribeAndExit(argc, argv,
                         "Driver for Chebyshev interpolation kernel  (1/r kernel).",
                         FParameterDefinitions::InputFile,
                         FParameterDefinitions::OctreeHeight,
                         FParameterDefinitions::OctreeSubHeight,
                         FParameterDefinitions::NbThreads,
83
84
                         {{"--algo"},"Algorithm to run (costzones, basic, task)"},
                         {{"--schedule"},"OpenMP scheduling policy (static, dynamic)."});
85
86
87
88
89
90
91
92
93
94
    FPerfTestParams params;
    {
        using namespace FParameterDefinitions;
        using namespace FParameters;
        params.filename = getStr(argc,argv,InputFile.options,
                                 "../Data/unitCubeXYZQ100.bfma");
        params.treeHeight = getValue(argc, argv, OctreeHeight.options, 5);
        params.subTreeHeight = getValue(argc, argv, OctreeSubHeight.options, 2);
        params.nbThreads = getValue(argc, argv, NbThreads.options, 1);
        params.algo = getStr(argc,argv,{"--algo"},"task");
95
96
        params.omp_static_schedule =
            getStr(argc,argv,{"--schedule"},"dynamic") == std::string("static");
97
98
    }

99
    omp_set_num_threads(params.nbThreads);
100

Quentin Khan's avatar
Quentin Khan committed
101
    if( "basic" == params.algo ) {
102
103
104
105
106
        runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderThread>(params);
    } else if( "task" == params.algo ) {
        runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderTask>(params);
    } else if ( "costzones" == params.algo ) {
        runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderCostZones>(params);
107
108
    } else if ( "sectiontask" == params.algo ) {
        runperf<TreeLoaderFCheb<>, KernelLoaderFChebSym, AlgoLoaderSectionTask>(params);
109
110
    } else {
        std::cout << "Unknown algorithm: " << params.algo << std::endl;
111
112
113
114
    }
    

}