loadFMAAndRunFMMArgs.hpp 3.16 KB
Newer Older
Quentin Khan's avatar
Quentin Khan committed
1
2
3
#ifndef _LOADFMAANDRUNFMMARGS_HPP_
#define _LOADFMAANDRUNFMMARGS_HPP_

4
5
6
#include "tclap/CmdLine.h"
#include "tclap/LinuxOutput.hpp"
#include "tclap/CompletionVisitor.h"
Quentin Khan's avatar
Quentin Khan committed
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

class loadFMAAndRunFMMArgs {
    using vs = std::vector<std::string>;
    
    const int _treeHeightInit = 5;
    const int _subTreeHeightInit = 1;
    const int _zoneCountInit = 4;
    const std::string _inFileNameInit = "";
    const std::string _outFileNameInit = "balancetest";
    const std::string _outFileNameExtInit = "csv";

    TCLAP::CmdLine
    _cmd {  "Loads an FMA file into a tree and runs a pseudo FMM algorithm "
            "through it to compute load balancing.", ' ', "0.0"};
    
    TCLAP::LinuxOutput _cmdFormat;
    
    TCLAP::BashCompletion::Visitor _compVistor;
    TCLAP::SwitchArg
    _compArg { "",
            "completion",
            "Show completion arguments",
            _cmd, false, &_compVistor};


    TCLAP::ValueArg <int>
    _subTreeHeight { "", vs{"subtree-height", "sth"},
            "Subtree height.", false, _subTreeHeightInit, "sub-tree height", _cmd};
    
    TCLAP::ValueArg <int>
    _treeHeight { "H", vs{"tree-height", "th"},
            "Tree height.", true, _treeHeightInit, "tree height", _cmd};

    TCLAP::ValueArg <int>
    _zoneCount { "z", vs{"zone-count"},
            "Number of zones to create", true, _zoneCountInit, "zone count", _cmd};

    TCLAP::ValueArg <std::string>
    _outFileExt { "x", "output-file-extension",
            "Output files extension. One file is created for each level in the"
Quentin Khan's avatar
Quentin Khan committed
47
48
49
            " tree. Each file has a 'basename_$nbZones$z.$i$.extension' "
            "extension where $i is the level. Default value is "
            + _outFileNameExtInit + ".",
Quentin Khan's avatar
Quentin Khan committed
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
            false, _outFileNameExtInit, "suffix", _cmd};

    TCLAP::ValueArg <std::string>
    _outFileName { "o", "output-file-basename",
            "Output files' basename. One file is created for each level in "
            "the tree. Each file has a level-in-tree based extension.",
            false, _outFileNameInit, "basename", _cmd};
    
    TCLAP::ValueArg <std::string>
    _inFileName { "f", "input-file",
            "Input file name.", true, _inFileNameInit, "filename", _cmd};
    
public:
    int treeHeight()    {return _treeHeight.getValue();}
    int subTreeHeight() {return _subTreeHeight.getValue();}
    int zoneCount() {return _zoneCount.getValue();}
    std::string inFileName() {return _inFileName.getValue();} 
    std::string outFileName() {return _outFileName.getValue();} 
    std::string outFileExt() {
        std::string ext = _outFileExt.getValue();
        if ( ext.at(0) != '.' )
            return '.' + ext;
        return ext;
    } 

    loadFMAAndRunFMMArgs(int argc, char** argv) 
        : _compVistor(argc, argv, &_cmd, {
                { &_inFileName,{TCLAP::BashCompletion::FILE, "!*.fma" }},
                {&_outFileExt, {"csv"}}}
            ){
        int columns = 80;
        struct winsize w;
        if (ioctl(0, TIOCGWINSZ, &w) == 0)
            columns = w.ws_col;

        _compArg.setHideDesc(true);
        _cmdFormat.setTextWidth(columns);                        
        _cmd.setOutput(&_cmdFormat);
        _cmd.parse(argc,argv);
    }
};


#endif