UGRAMM
Loading...
Searching...
No Matches
UGRAMM.h
1//===================================================================//
2// Universal GRAaph Minor Mapping (UGRAMM) method for CGRA //
3// file : UGRAMM.h //
4// description: contains global variables and associated functions //
5//===================================================================//
6
7#ifndef UGRAMM_H
8#define UGRAMM_H
9
10#include <boost/config.hpp>
11#include <iostream>
12#include <fstream>
13#include <boost/graph/graph_traits.hpp>
14#include <boost/graph/adjacency_list.hpp>
15#include <boost/graph/dijkstra_shortest_paths.hpp>
16#include <boost/property_map/property_map.hpp>
17#include <boost/graph/graphviz.hpp>
18#include <boost/graph/copy.hpp>
19#include <queue>
20#include <map>
21#include <list>
22#include <bitset>
23#include <algorithm>
24#include <vector>
25#include <limits>
26#include <boost/algorithm/string.hpp>
27#include <sys/time.h>
28#include "spdlog/spdlog.h"
29#include <spdlog/sinks/stdout_color_sinks.h>
30#include <boost/program_options.hpp>
31#include "../lib/json.h"
32
33//-------------------------------------------------------------------//
34//------------------------ GRAMM Configuration ----------------------//
35#define MAX_DIST 10000000
36#define RIKEN 1 //Defining the architecture type (1 --> Riken, 0 --> Adres)
37#define DEBUG 0 //For enbaling the print-statements
38#define computeTopoEnable 0 //Compute topological order and sort the graph based on it while finding the minor.
39#define maxIterations 39
40//-------------------------------------------------------------------//
41
42//Struct for defining the node configuration in hConfig and gConfig data-structures:
43struct NodeConfig {
44 // For [G] --> Device Model Graph
45 std::string Cell; //Cell-type --> FuncCell, RouteCell, PinCell
46 std::string Type; //Node-Type --> io, alu, memport....
47 int Latency = 0; //Optional
48
49 // For [H] --> Application Graph
50 std::string Opcode; //OpcodeType --> FADD, FMUL, FSUB, INPUT, OUTPUT, etc.
51 std::string loadPin; //Load pin of the PinCell node --> inPinA, inPinB
52 std::pair<int, int> Location = {0,0}; //Optional
53};
54
55//Struct for defining the expected attributes defined in the h and g graph:
56struct DotVertex {
57 // For [H] --> Application Graph
58 std::string H_Name; //[Required] Contains name of the operation in Application graph (ex: Load_0)
59 std::string H_Opcode; //[Required] Contains the Opcode of the operation (ex: FMUL, FADD, INPUT, OUTPUT etc.)
60 std::string H_Latency; //[Optional] Contains the latency of the operation
61 std::string H_PlacementX; //[Optional] Contains the placement location of X
62 std::string H_PlacementY; //[Optional] Contains the placement location of Y
63
64 // For [G] --> Device Model Graph
65 std::string G_Name; //[Required] Contains the unique name of the cell in the device model graph.
66 std::string G_CellType; //[Required] Contains the Opcode of the CellType (FuncCell, RouteCell, PinCell)
67 std::string G_NodeType; //[Required] Contains the NodeType of Device Model Graph (For example "ALU" for CellType "FuncCell")
68 std::string G_VisualX; //[Optional] Visual X co-ordinate
69 std::string G_VisualY; //[Optional] Visual Y co-ordinate
70};
71
72//Struct for defining the edge types in the H graph to determine the pin layout
74 // For [H] --> Application Graph
75 std::string H_LoadPin; //[Required]
76 std::string H_DriverPin; //[Required]
77 // For [H] --> Application Graph and [G] --> Device Model Graph
78 int weight;
79};
80
81//Properties of the application and device model graph:
82typedef boost::adjacency_list<boost::listS, boost::vecS, boost::bidirectionalS, DotVertex, EdgeProperty> DirectedGraph;
83typedef boost::graph_traits<DirectedGraph>::edge_iterator edge_iterator;
84typedef boost::graph_traits<DirectedGraph>::in_edge_iterator in_edge_iterator;
85typedef boost::graph_traits<DirectedGraph>::out_edge_iterator out_edge_iterator;
86typedef boost::graph_traits<DirectedGraph>::vertex_descriptor vertex_descriptor;
87typedef boost::graph_traits<DirectedGraph>::vertex_iterator vertex_iterator;
88typedef boost::graph_traits<DirectedGraph>::out_edge_iterator OutEdgeIterator;
89typedef DirectedGraph::edge_descriptor Edge;
90
91// the routing tree for a signal
92// explanation for the three fields:
93// for each node in the tree, we have a map that returns a list of its child nodes (i.e. the nodes it drives)
94// for each node in the tree, we have a map that returns its parent node (i.e., the unique node that drives it)
95// we also keep track of the list of all nodes in the routing tree
97 std::map<int, std::list<int>> children;
98 std::map<int, int> parent;
99 std::list<int> nodes;
100};
101
102// Routing related variables:
103extern std::vector<RoutingTree> *Trees; // routing trees for every node in H
104extern std::vector<std::list<int>> *Users; // for every node in device model G track its users
105extern std::map<int, int> invUsers; // InvUsers, key = hID, value = current_mapped gID
106extern std::vector<int> *HistoryCosts; // for history of congestion in PathFinder
107extern std::vector<int> *TraceBack;
108extern std::vector<int> *TopoOrder; // NOT USED: for topological order
109extern std::map<int, std::string> hNames; //Map for storing the unique names of Application graph
110extern std::map<int, std::string> gNames; //Map for storing the unique names of device model graph
111extern std::bitset<100000> explored;
112
113//Pathefinder cost parameters:
114extern float PFac; //Congestion cost factor
115extern float HFac; //History cost factor
116
117//Logger variable:
118extern std::shared_ptr<spdlog::logger> UGRAMM;
119
120extern std::vector<std::string> inPin;
121extern std::vector<std::string> outPin;
122
123//New way for node and opcode types:
124extern std::map<std::string, std::vector<std::string>> ugrammConfig; //New general way
125
126//JSON parsing for the config file:
127using json = nlohmann::json;
128extern json jsonParsed;
129
130//Function declaration:
131
142int findMinorEmbedding(DirectedGraph *H, DirectedGraph *G, std::map<int, NodeConfig> *hConfig, std::map<int, NodeConfig> *gConfig);
143
155int findMinVertexModel(DirectedGraph *G, DirectedGraph *H, int y, std::map<int, NodeConfig> *hConfig, std::map<int, NodeConfig> *gConfig);
156
157#endif //UGRAMM header
Definition UGRAMM.h:56
Definition UGRAMM.h:73
Definition UGRAMM.h:43
Definition UGRAMM.h:96