All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ooo_instrumentation.h
Go to the documentation of this file.
1 #ifndef OOO_INSTRUMENTATION_H_INCLUDED_
2 #define OOO_INSTRUMENTATION_H_INCLUDED_
3 
4 #include <iostream>
5 #include <cstdlib>
6 #include <unordered_set>
7 #include <unordered_map>
8 
9 
10 #include "rose.h"
11 #include "../segment_graph/combined_data_conflict_table.h"
12 #include "../segment_graph/prediction_time_advance_table.h"
13 #include "../segment_graph/prediction_event_notification_table.h"
14 
15 // Instrumentation of user-defined channels with locks
16 // (described as item "4. User-defined channel protection"
17 // in the RISC TRs up to v050 and the book chapter)
18 // is redundant (i.e. NOT necessary any more!)
19 // with the new PCP analysis and "cloning" (DATE'18 paper)!
20 // 01/14/19, RD.
21 //
22 // So we skip instrumentation of 'chnl_scoped_lock' in channels:
23 //#define RISC_INSTRUMENT_CHNL_SCOPED_LOCK
24 #ifndef DUMP_TABLE_THRESHOLD
25 #define DUMP_TABLE_THRESHOLD 42
26 #endif
27 
28 namespace risc {
29 
30 class Design;
31 
32 namespace sg {
33 
34 class DataConflictTable;
35 class EventConflictTable;
36 class SegmentGraph;
37 class TimeAdvanceTable;
38 }
39 
40 namespace tools {
41 
42 class ParseStatus;
43 }
44 
45 namespace inst {
46 
51 class InstrumentationTraversal: public AstSimpleProcessing
52 {
53  public:
55 #ifdef RISC_INSTRUMENT_CHNL_SCOPED_LOCK // skip user-channel protection
56  SgType*, SgExpression*, SgExpression*,
57 #endif // RISC_INSTRUMENT_CHNL_SCOPED_LOCK // skip user-channel protection
58  SgClassDefinition*, std::map<SgNode*, int>&, std::string );
59  virtual void visit(SgNode* astNode);
61  SgFunctionDeclaration* first_func_decl_that_contains_wait;
62  SgClassDeclaration* first_module_decl;
63  std::string design_file_name;
64  void hack_instrument_fifo_read(SgFunctionCallExp*, SgExpression*);
65  private:
66 #ifdef RISC_INSTRUMENT_CHNL_SCOPED_LOCK // skip user-channel protection
67 
70  SgType* variableType;
71 
75  SgExpression* PrimChnlVarRefExp;
76 
80  SgExpression* SCChnlVarRefExp;
81 #endif // RISC_INSTRUMENT_CHNL_SCOPED_LOCK // skip user-channel protection
82 
86  SgClassDefinition* SCModuleClassDef;
87 
91  std::map<SgNode*, int>& FuncCallExptoID;
92 
93  public: std::unordered_set<SgNode*> visited;
94  public: std::unordered_map<SgFunctionCallExp*, SgExpression*> map_fifoRead_id;
95 
96 };
97 
104 int
105 risc_link(SgProject* project, risc::tools::ParseStatus* parseStatus, const std::string tool_name);
106 
117 void
119  std::vector<std::string>& argv,
120  std::vector<std::string>& compilerCmdLine,
121  risc::tools::ParseStatus* parseStatus,
122  const std::string tool_name);
123 
132 int
133 risc_compileOutputFile(SgFile* file, risc::tools::ParseStatus* parseStatus, const std::string tool_name);
134 
143 int
144 risc_compileOutput(SgProject* project, risc::tools::ParseStatus* parseStatus, const std::string tool_name);
145 
154 void
155 risc_unparse(risc::Design &design,
156  risc::tools::ParseStatus* parseStatus,
157  const std::string tool_name,
158  UnparseFormatHelp *unparseFormatHelp = NULL,
159  UnparseDelegate* unparseDelegate = NULL);
160 
161 /*** THIS PATCHING AROUND ROSE LIMITATIONS IS NOT NEEDED ANY MORE
162  WITH THE NEW ROSE LIBRARY VERSION 0.9.10.X (RD, 05/30/18)
163 / **
164  * \fn risc_patch
165  * \brief This function patches the static_cast issues in the unparsed
166  * source code file(s)
167  * /
168 void
169 risc_patch(risc::Design &design,
170  risc::tools::ParseStatus* parseStatus,
171  const char *methodPattern,
172  const char *threadPattern,
173  const char *cthreadPattern,
174  const std::string tool_name);
175 ***/
176 
184 int
186  const std::string tool_name);
187 
198 int
199 risc_backend(risc::Design &design,
200  risc::tools::ParseStatus* parseStatus,
201  const std::string tool_name,
202  UnparseFormatHelp *unparseFormatHelp = NULL,
203  UnparseDelegate* unparseDelegate = NULL);
204 
225 void
226 instrumentor(risc::Design &design,
228  risc::sg::DataConflictTable* data_conflict_table,
229  risc::sg::EventConflictTable* event_conflict_table,
230  risc::sg::TimeAdvanceTable* time_advance_table,
231  risc::sg::CombinedDataConflictTable* combined_data_conflict_table,
232  risc::sg::PredictionTimeAdvanceTable* prediction_time_advance_table,
233  risc::sg::PredictionEventNotificationTable* prediction_event_notification_table,
234  risc::sg::PredictionEventNotificationTable* prediction_event_notification_table_no_indirect,
235  risc::tools::ParseStatus* parseStatus,
236  std::string design_file_name,
237  std::vector< std::vector<int> > &psg_seg_id_array,
238  std::vector<std::string> &file_names,
239  std::vector< std::vector<int> > &channel_seg_id_array,
240  std::vector<std::string> &channel_seg_id_array_names
241  );
242 
258 void dump_table_to_file(
259  risc::Design &design,
261  risc::sg::DataConflictTable* data_conflict_table,
262  risc::sg::EventConflictTable* event_conflict_table,
263  risc::sg::TimeAdvanceTable* time_advance_table,
264  risc::sg::CombinedDataConflictTable* combined_data_conflict_table,
265  risc::sg::PredictionTimeAdvanceTable* prediction_time_advance_table,
266  risc::sg::PredictionEventNotificationTable* prediction_event_notification_table,
267  risc::sg::PredictionEventNotificationTable* prediction_event_notification_table_no_indirect,
268  risc::tools::ParseStatus* parseStatus
269  );
270 
276 
277 
283 
290 
291 
298 
299 
309 std::string generate_unique_name(std::string var_name);
310 
314 extern int counter;
315 
316 } // end of namespace inst
317 
318 } // end of namespace risc
319 
320 #endif /* OOO_INSTRUMENTATION_H_INCLUDED_ */
321 
322 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */
int risc_compileOutput(SgProject *project, risc::tools::ParseStatus *parseStatus, const std::string tool_name)
Tailored SgProject::compileOutput for customized compiler. The original ROSE codes are at ~src/fronte...
Definition: ooo_instrumentation.cpp:1198
int counter
counter to get a unique variable name with number
Definition: ooo_instrumentation.cpp:33
int risc_compile(risc::Design &design, risc::tools::ParseStatus *parseStatus, const std::string tool_name)
This function compiles and links the unparsed source code file(s) using the customized compiler...
Definition: ooo_instrumentation.cpp:1405
This class represents a segment graph for a process.
Definition: segment_graph.h:79
Definition: design.h:57
void hack_instrument_fifo_read(SgFunctionCallExp *, SgExpression *)
Definition: ooo_instrumentation.cpp:59
This class stores the command-line options.
Definition: command_line_parsing.h:61
void instrument_offset_before_and_after_b_transports(risc::sg::SegmentGraph &sg)
sets the segment offset value before and after b_transport
Definition: ooo_instrumentation.cpp:4153
Definition: prediction_time_advance_table.h:13
InstrumentationTraversal(SgClassDefinition *, std::map< SgNode *, int > &, std::string)
Definition: ooo_instrumentation.cpp:35
std::unordered_set< SgNode * > visited
Definition: ooo_instrumentation.h:93
void dump_table_to_file(risc::Design &design, risc::sg::SegmentGraph &sg, risc::sg::DataConflictTable *data_conflict_table, risc::sg::EventConflictTable *event_conflict_table, risc::sg::TimeAdvanceTable *time_advance_table, risc::sg::CombinedDataConflictTable *combined_data_conflict_table, risc::sg::PredictionTimeAdvanceTable *prediction_time_advance_table, risc::sg::PredictionEventNotificationTable *prediction_event_notification_table, risc::sg::PredictionEventNotificationTable *prediction_event_notification_table_no_indirect, risc::tools::ParseStatus *parseStatus)
This function dumps all the lookup tables to a file.
Definition: ooo_instrumentation.cpp:2953
SgClassDefinition * SCModuleClassDef
SgClassDefinition of &quot;::sc_core::sc_module&quot;.
Definition: ooo_instrumentation.h:86
void instrument_wait_in_b_transports(risc::sg::SegmentGraph &sg)
changes the segment id passing from constants to variables in b_transports which are passed by thread...
Definition: ooo_instrumentation.cpp:4385
The conflicts are stored in the base class variable conflict_table_. The columns represent wait state...
Definition: event_conflict_table.h:29
int risc_backend(risc::Design &design, risc::tools::ParseStatus *parseStatus, const std::string tool_name, UnparseFormatHelp *unparseFormatHelp, UnparseDelegate *unparseDelegate)
Tailored backend for SystemC source files. The original ROSE codes are at ~src/roseSupport/utility_fu...
Definition: ooo_instrumentation.cpp:1473
Definition: combined_data_conflict_table.h:24
std::unordered_map< SgFunctionCallExp *, SgExpression * > map_fifoRead_id
Definition: ooo_instrumentation.h:94
int risc_link(SgProject *project, risc::tools::ParseStatus *parseStatus, const std::string tool_name)
Tailored SgProject::link for customized linker. The original ROSE codes are at ~src/frontend/SageIII/...
Definition: ooo_instrumentation.cpp:402
std::map< SgNode *, int > & FuncCallExptoID
Mapping from SgNode to segment ID.
Definition: ooo_instrumentation.h:91
This class represents the data conflict table among the individual segments. Two segments have a conf...
Definition: data_conflict_table.h:25
std::string design_file_name
Definition: ooo_instrumentation.h:63
SgFunctionDeclaration * first_func_decl_that_contains_wait
Definition: ooo_instrumentation.h:61
void instrument_functions_without_definitions(risc::sg::SegmentGraph &sg)
for test purpose now
void instrument_wait_in_channels(risc::sg::SegmentGraph &sg)
changes the segment id passing from constants to variables in channels which are passed by thread loc...
Definition: ooo_instrumentation.cpp:4018
SgClassDeclaration * first_module_decl
Definition: ooo_instrumentation.h:62
The AST traversal class.
Definition: ooo_instrumentation.h:51
Definition: prediction_event_notification_table.h:18
virtual void visit(SgNode *astNode)
Definition: ooo_instrumentation.cpp:86
void risc_buildCompilerCommandLineOptions(SgFile *file, std::vector< std::string > &argv, std::vector< std::string > &compilerCmdLine, risc::tools::ParseStatus *parseStatus, const std::string tool_name)
Tailored SgFile::buildCompilerCommandLineOptions for customized compiler. The original ROSE codes are...
Definition: ooo_instrumentation.cpp:596
int risc_compileOutputFile(SgFile *file, risc::tools::ParseStatus *parseStatus, const std::string tool_name)
Tailored SgFile::compileOutput for customized compiler. The original ROSE codes are at ~src/ROSETTA/G...
Definition: ooo_instrumentation.cpp:912
std::string generate_unique_name(std::string var_name)
generates a unique variable based on var_name
Definition: ooo_instrumentation.cpp:4607
void instrumentor(risc::Design &design, risc::sg::SegmentGraph &sg, risc::sg::DataConflictTable *data_conflict_table, risc::sg::EventConflictTable *event_conflict_table, risc::sg::TimeAdvanceTable *time_advance_table, risc::sg::CombinedDataConflictTable *combined_data_conflict_table, risc::sg::PredictionTimeAdvanceTable *prediction_time_advance_table, risc::sg::PredictionEventNotificationTable *prediction_event_notification_table, risc::sg::PredictionEventNotificationTable *prediction_event_notification_table_no_indirect, risc::tools::ParseStatus *parseStatus, std::string design_file_name, std::vector< std::vector< int > > &psg_seg_id_array, std::vector< std::string > &file_names, std::vector< std::vector< int > > &channel_seg_id_array, std::vector< std::string > &channel_seg_id_array_names)
This function instruments the AST tree of SystemC designs, and compiles unparsed source file(s) using...
Definition: ooo_instrumentation.cpp:1542
void instrument_port_calls(risc::sg::SegmentGraph &sg)
instruments the upcoming segments ids to thread local data
Definition: ooo_instrumentation.cpp:3852
void risc_unparse(risc::Design &design, risc::tools::ParseStatus *parseStatus, const std::string tool_name, UnparseFormatHelp *unparseFormatHelp, UnparseDelegate *unparseDelegate)
This function unparses AST trees to source code file(s)
Definition: ooo_instrumentation.cpp:1298
Definition: time_advance_table.h:18
bool _psg_off_instrumented
Definition: ooo_instrumentation.h:60