File: processConfig.h

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 33,764 kB
  • sloc: cpp: 175,964; ansic: 160,510; f90: 14,630; yacc: 12,668; python: 7,275; perl: 7,126; sh: 2,825; lisp: 1,106; xml: 1,049; makefile: 579; lex: 557
file content (112 lines) | stat: -rw-r--r-- 2,693 bytes parent folder | download | duplicates (2)
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
/*
 * processConfig.h
 *
 *  Created on: Oct 2018
 *      Author: Norbert Podhorszki
 */

#ifndef PROCESS_CONFIG_H
#define PROCESS_CONFIG_H

#include <map>
#include <string>
#include <vector>

#include "adios2.h"

#include "settings.h"

struct VariableInfo
{
    std::string name;
    std::string type;
    adios2::ShapeID shapeID;
    size_t ndim;
    adios2::Dims shape;
    adios2::Dims decomp;
    adios2::Dims start;
    adios2::Dims count;
    size_t elemsize;
    size_t datasize;
    std::vector<char> data;
    bool readFromInput;
};

enum Operation
{
    Sleep,
    Busy,
    Write,
    Read
};

class Command
{
public:
    Operation op;
    std::string conditionalStream;
    Command(Operation operation);
    virtual ~Command() = 0;
};

class CommandSleep : public Command
{
public:
    const size_t sleepTime_us = 0; // in microseconds
    CommandSleep(size_t time);
    ~CommandSleep();
};

class CommandBusy : public Command
{
public:
    const size_t cycles = 1;
    const size_t busyTime_us = 0; // in microseconds per cycle
    CommandBusy(size_t cycles, size_t time);
    ~CommandBusy();
};

class CommandWrite : public Command
{
public:
    const std::string streamName;
    const std::string groupName;
    std::vector<std::shared_ptr<VariableInfo>> variables;
    CommandWrite(std::string stream, std::string group);
    ~CommandWrite();
};

class CommandRead : public Command
{
public:
    const adios2::StepMode stepMode;
    const std::string streamName;
    const std::string groupName;
    const float timeout_sec;
    std::vector<std::shared_ptr<VariableInfo>> variables;
    CommandRead(std::string stream, std::string group, const float timeoutSec = -1.0);
    ~CommandRead();
};

struct Config
{
    size_t nSteps = 1;
    // list of input streams that we loop over instead of nSteps
    std::map<std::string, bool> stepOverStreams;
    // groupName, list of variables to preserve user defined order
    std::map<std::string, std::vector<std::shared_ptr<VariableInfo>>> groupVariableListMap;
    // same group/variables but in an ordered map for finding
    // a particular variable
    std::map<std::string, std::map<std::string, std::shared_ptr<VariableInfo>>> groupVariablesMap;
    // appID, list of commands
    std::vector<std::shared_ptr<Command>> commands;
    // Read streams status flag for supporting conditionals
    std::map<std::string, adios2::StepStatus> condMap; // stream name
};

const std::vector<std::pair<std::string, size_t>> supportedTypes = {
    {"double", sizeof(double)}, {"float", sizeof(float)}, {"int", sizeof(int)}};

Config processConfig(const Settings &settings, size_t *currentConfigLineNumber);

#endif /* PROCESS_CONFIG_H */