testFmmAlgorithmBalancedArgs.hpp 3.37 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
// ==== CMAKE ====
// Keep in private GIT
// @SCALFMM_PRIVATE

#ifndef _LOADFMAANDRUNFMMARGS_HPP_
#define _LOADFMAANDRUNFMMARGS_HPP_

#include <string>
#include <omp.h>

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


class loadFMAAndRunFMMArgs {
    const int _treeHeightInit = 5;
    const int _subTreeHeightInit = 1;
    const int _zoneCountInit = omp_get_max_threads();
    const int _verboseInit = 0;
    const char* _inFileNameInit = "";
    const char* _outFileNameInit = "balancetest";
    const char* _outFileNameExtInit = "csv";

    int _argc;
    char** _argv;

    const FParameterNames OutputFileBasename =
    {{"--output-file-basename", "-fout-base"},
     "Output files' basename. One file is created for each level in "
     "the tree. Each file has a level-in-tree based extension."};

    const FParameterNames OutputFileExtension =
    {{"--output-file-extention", "-fout-ext"},
     "Output files extension. One file is created for each level in the"
     " tree. Each file has a 'basename_$nbZones$z.$i$.extension' "
     "extension where $i is the level."};

    const FParameterNames ZoneCount = 
    {{"--zone-count","-z"},"Number of zones to create."};

public:
    int treeHeight() const {
        using namespace FParameterDefinitions;
        using namespace FParameters;

        return getValue(_argc, _argv, OctreeHeight.options, _treeHeightInit);
    }

    int subTreeHeight() const {
        using namespace FParameterDefinitions;
        using namespace FParameters;

        return getValue(_argc, _argv, OctreeSubHeight.options,
                        _subTreeHeightInit);
    }

    int zoneCount()     const {
        using namespace FParameterDefinitions;
        using namespace FParameters;

        return getValue(_argc, _argv, ZoneCount.options, _zoneCountInit);
    }

    int verboseLevel()  const {
        using namespace FParameterDefinitions;
        using namespace FParameters;

        return getValue(_argc, _argv, EnabledVerbose.options, _verboseInit);
    }

    std::string inFileName()  const {
        using namespace FParameterDefinitions;
        using namespace FParameters;

        return getStr(_argc, _argv, InputFile.options, _inFileNameInit);
    } 

    std::string outFileName() const {
        using namespace FParameterDefinitions;
        using namespace FParameters;

        return getStr(_argc, _argv, OutputFileBasename.options, _outFileNameInit);
    } 

    std::string outFileExt() const {
        using namespace FParameterDefinitions;
        using namespace FParameters;
        
        std::string ext = getStr(_argc, _argv, OutputFileExtension.options,
                                 _outFileNameExtInit);
        if ( ext.at(0) != '.' )
            return '.' + ext;
        return ext;
    } 

    loadFMAAndRunFMMArgs(int argc, char** argv) : _argc(argc), _argv(argv) {
        parse();
    }

    int parse() {
    using namespace FParameterDefinitions;
    using namespace FParameters;

        FHelpDescribeAndExit
            (_argc, _argv,
             "Loads an FMA file into a tree and runs a pseudo FMM algorithm "
             "through it to compute load balancing.",
             OctreeHeight,
             OctreeSubHeight,
             InputFile,
             OutputFileBasename,
             OutputFileExtension,
             ZoneCount,
             EnabledVerbose
             );
        return 0;
    }

};


#endif