-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml_parser.h
73 lines (64 loc) · 1.3 KB
/
xml_parser.h
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
// xml_parser.h
#ifndef XML_PARSER_H
#define XML_PARSER_H
#include <vector>
#include <string>
#include <memory>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>
enum buffer_type {
INPUT,
OUTPUT,
SCRATCH,
BUFFER_UNKNOWN
};
enum op_type{
NOP,
SEND,
RECV,
REDUCE,
RECV_REDUCE_COPY,
RECV_COPY_SEND,
RECV_REDUCE_SEND,
RECV_REDUCE_COPY_SEND,
OP_UNKNOWN
};
struct Step {
int s;
enum op_type type;
enum buffer_type srcbuf;
int srcoff;
enum buffer_type dstbuf;
int dstoff;
int cnt;
int depid;
int deps;
int hasdep;
};
struct ThreadBlock {
int id;
int send;
int recv;
int chan;
std::vector<std::shared_ptr<Step>> steps;
};
struct Rank {
int id;
int i_chunks;
int o_chunks;
int s_chunks;
std::vector<std::shared_ptr<ThreadBlock>> tbs;
};
class XMLParser {
public:
void parseXMLAndFillStructs(const std::string& filename);
void displayRanks(); // Utility function to display GPU information
std::vector<std::shared_ptr<Rank>> ranks;
int nchunksperloop;
private:
void parseRank(xmlNode* node);
void parseThreadBlock(xmlNode* node, std::shared_ptr<Rank>& rank);
void parseStep(xmlNode* node, std::shared_ptr<ThreadBlock>& tb);
};
#endif // XML_PARSER_H