UGRAMM
Loading...
Searching...
No Matches
utilities.h
Go to the documentation of this file.
1//===========================================================================//
2// Universal GRAaph Minor Mapping (UGRAMM) method for CGRA //
3// file : utilities.h //
4// description: contains variables and function declaration used for utility //
5//===========================================================================//
6
7#ifndef UTILITIES_H
8#define UTILITIES_H
9
10#include <boost/config.hpp>
11#include <iostream>
12#include <fstream>
13#include <boost/graph/graph_traits.hpp>
14#include <boost/algorithm/string.hpp>
15#include <boost/graph/adjacency_list.hpp>
16#include <boost/graph/dijkstra_shortest_paths.hpp>
17#include <boost/property_map/property_map.hpp>
18#include <boost/graph/graphviz.hpp>
19#include <boost/graph/copy.hpp>
20#include <queue>
21#include <map>
22#include <list>
23#include <bitset>
24#include <algorithm>
25#include <boost/algorithm/string.hpp>
26
27#define VISUAL_SCALE 6.5 //Steches the user defined co-ordinate space using this scale-factor
28#define FunCell_Visual_Enable 1
29#define PinCell_Visual_Enable 1
30#define RouteCell_Visual_Enable 0
31
32extern std::vector<std::string> colors; //Color code for different FunCell nodes
33extern std::string input_pin_color; //Pre-defined color-code for the input-pin cell
34extern std::string output_pin_color; //Pre-defined color-code for the output-pin cell
35extern std::string unused_cell_color; //Pre-defined color-code for the unused cell
36extern std::map<std::string, std::string> funCellMapping; //Key-> Device-model node-name :: Value-> Mapped application name.
37
38
39//------------------------------------------------------------------------------------//
40//------------------- [Utilities] String manipulation operations ---------------------//
41//------------------------------------------------------------------------------------//
42
51std::string removeCurlyBrackets(const std::string& input);
52
59std::string gNames_deliemter_changes(std::string gNames);
60
68std::string string_remover(std::string original_string, std::string toRemove);
69
75void jsonUppercase(json& j);
76
77//------------------------------------------------------------------------------------//
78//---------------------- [Utilities] PRAGMA related functions ------------------------//
79//------------------------------------------------------------------------------------//
80
87std::string readCommentSection(std::ifstream &inputFile);
88
97bool skipPlacement(std::string hOpcode, json& jsonParsed);
98
108bool needLocking(int HID, json &jsonParsed, std::string& jsonLockNode);
109
116void readDeviceModelPragma(std::ifstream &deviceModelFile, json &UgrammPragmaConfig);
117
124void readApplicationGraphPragma(std::ifstream &applicationGraphFile, json &UgrammPragmaConfig);
125
133bool widthCheck(int hWidth, int gWidth);
134
147bool compatibilityCheck(int gID, int hID, std::map<int, NodeConfig> *hConfig, std::map<int, NodeConfig> *gConfig);
148
149
150//------------------------------------------------------------------------------------//
151//---------------------- [Utilities] Printing and visualization ----------------------//
152//------------------------------------------------------------------------------------//
153
164void printRoutingResults(int y, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile, std::map<int, NodeConfig> *hConfig, std::map<int, NodeConfig> *gConfig);
165
175void mandatoryFunCellConnections(int gNumber, std::string FunCellName, DirectedGraph *G, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile);
176
188void printPlacementResults(int gNumber, std::string gName, DirectedGraph *G, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile, std::map<int, NodeConfig> *gConfig, json &ugrammConfig);
189
199void printMappedResults(DirectedGraph *H, DirectedGraph *G, std::map<int, NodeConfig> *hConfig , std::map<int, NodeConfig> *gConfig, json &UgrammPragmaConfig);
200
206void printName(int n);
207
216void printVertexModels(DirectedGraph *H, DirectedGraph *G, std::map<int, NodeConfig> *hConfig, std::map<int, int> &invUsers);
217
218
224void printRouting(int signal);
225
226//------------------------------------------------------------------------------------//
227//-------------------------------- [Utilities] File read -----------------------------//
228//------------------------------------------------------------------------------------//
229
236void readDeviceModel(DirectedGraph *G, std::map<int, NodeConfig> *gConfig);
237
245void readApplicationGraph(DirectedGraph *H, std::map<int, NodeConfig> *hConfig, std::map<int, NodeConfig> *gConfig);
246
247#endif
std::map< int, int > invUsers
Definition UGRAMM.cpp:29
json UgrammPragmaConfig
Definition UGRAMM.cpp:53
json jsonParsed
Definition UGRAMM.cpp:52
std::map< int, std::string > gNames
Definition UGRAMM.cpp:35
std::map< std::string, std::vector< std::string > > ugrammConfig
Definition UGRAMM.cpp:49
boost::adjacency_list< boost::listS, boost::vecS, boost::bidirectionalS, DotVertex, EdgeProperty > DirectedGraph
Definition UGRAMM.h:91
nlohmann::json json
Definition UGRAMM.h:143
std::string unused_cell_color
Definition utilities.cpp:27
void printName(int n)
Definition utilities.cpp:580
std::string gNames_deliemter_changes(std::string gNames)
Definition utilities.cpp:62
std::map< std::string, std::string > funCellMapping
Definition utilities.cpp:28
void jsonUppercase(json &j)
Definition utilities.cpp:109
void printVertexModels(DirectedGraph *H, DirectedGraph *G, std::map< int, NodeConfig > *hConfig, std::map< int, int > &invUsers)
Definition utilities.cpp:588
void mandatoryFunCellConnections(int gNumber, std::string FunCellName, DirectedGraph *G, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile)
Definition utilities.cpp:403
std::string string_remover(std::string original_string, std::string toRemove)
Definition utilities.cpp:87
void printRoutingResults(int y, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig)
Definition utilities.cpp:355
std::string readCommentSection(std::ifstream &inputFile)
Definition utilities.cpp:139
void printPlacementResults(int gNumber, std::string gName, DirectedGraph *G, std::ofstream &positionedOutputFile, std::ofstream &unpositionedOutputFile, std::map< int, NodeConfig > *gConfig, json &ugrammConfig)
Definition utilities.cpp:440
std::vector< std::string > colors
Definition utilities.cpp:12
void printRouting(int signal)
Definition utilities.cpp:632
void readDeviceModelPragma(std::ifstream &deviceModelFile, json &UgrammPragmaConfig)
Definition utilities.cpp:238
void readApplicationGraphPragma(std::ifstream &applicationGraphFile, json &UgrammPragmaConfig)
Definition utilities.cpp:266
std::string removeCurlyBrackets(const std::string &input)
Definition utilities.cpp:38
void readDeviceModel(DirectedGraph *G, std::map< int, NodeConfig > *gConfig)
Definition utilities.cpp:652
bool widthCheck(int hWidth, int gWidth)
Checks if the application graph's node width is less than or equal to the device model's node width.
Definition utilities.cpp:300
std::string input_pin_color
Definition utilities.cpp:25
bool skipPlacement(std::string hOpcode, json &jsonParsed)
Definition utilities.cpp:173
std::string output_pin_color
Definition utilities.cpp:26
void readApplicationGraph(DirectedGraph *H, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig)
Definition utilities.cpp:720
bool compatibilityCheck(int gID, int hID, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig)
Definition utilities.cpp:325
void printMappedResults(DirectedGraph *H, DirectedGraph *G, std::map< int, NodeConfig > *hConfig, std::map< int, NodeConfig > *gConfig, json &UgrammPragmaConfig)
Definition utilities.cpp:504
bool needLocking(int HID, json &jsonParsed, std::string &jsonLockNode)
Definition utilities.cpp:214