54 for(std::size_t i=0; i<
num_sccs; ++i)
83 const std::set<event_grapht::critical_cyclet> &subset_of_cycles)
85 for(std::set<event_grapht::critical_cyclet>::const_iterator it =
86 subset_of_cycles.begin();
87 it != subset_of_cycles.end();
90 for(std::set<event_grapht::critical_cyclet::delayt>::const_iterator
91 p_it=it->unsafe_pairs.begin();
92 p_it!=it->unsafe_pairs.end(); ++p_it)
97 std::pair<irep_idt, source_locationt>(
104 std::pair<irep_idt, source_locationt>(
112 const std::set<event_grapht::critical_cyclet> &subset_of_cycles)
116 std::set<event_grapht::critical_cyclet::delayt> delayed;
118 for(std::set<event_grapht::critical_cyclet>::iterator it =
119 subset_of_cycles.begin();
120 it != subset_of_cycles.end();
125 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
126 p_it=it->unsafe_pairs.begin();
127 p_it!=it->unsafe_pairs.end(); ++p_it)
129 if(delayed.find(*p_it)!=delayed.end())
140 if(!it->unsafe_pairs.empty())
142 std::set<event_grapht::critical_cyclet::delayt>::iterator
143 p_it=it->unsafe_pairs.begin();
144 delayed.insert(*p_it);
148 std::pair<irep_idt, source_locationt>(
155 std::pair<irep_idt, source_locationt>(
163 const std::set<event_grapht::critical_cyclet> &)
166 throw "read first strategy not implemented yet";
170 const std::set<event_grapht::critical_cyclet> &)
173 throw "write first strategy not implemented yet";
193 const std::set<event_grapht::critical_cyclet> &subset_of_cycles)
219 std::set<event_grapht::critical_cyclet::delayt> edges;
220 for(std::set<event_grapht::critical_cyclet>::iterator C_j =
221 subset_of_cycles.begin();
222 C_j != subset_of_cycles.end();
224 for(std::set<event_grapht::critical_cyclet::delayt>::const_iterator e_i=
225 C_j->unsafe_pairs.begin();
226 e_i!=C_j->unsafe_pairs.end();
232 glp_init_iocp(&parm);
233 parm.msg_lev=GLP_MSG_OFF;
234 parm.presolve=GLP_ON;
236 lp=glp_create_prob();
237 glp_set_prob_name(lp,
"instrumentation optimisation");
238 glp_set_obj_dir(lp, GLP_MIN);
244 glp_add_cols(lp, edges.size());
246 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
253 glp_set_col_name(lp, i, name.c_str());
254 glp_set_col_bnds(lp, i, GLP_LO, 0.0, 0.0);
255 glp_set_obj_coef(lp, i,
cost(*e_i));
256 glp_set_col_kind(lp, i, GLP_BV);
260 glp_add_rows(lp, subset_of_cycles.size());
262 for(std::set<event_grapht::critical_cyclet>::iterator C_j =
263 subset_of_cycles.begin();
264 C_j != subset_of_cycles.end();
269 glp_set_row_name(lp, i, name.c_str());
270 glp_set_row_bnds(lp, i, GLP_LO, 1.0, 0.0);
273 const std::size_t mat_size = subset_of_cycles.size() * edges.size();
276 std::vector<int> imat(mat_size+1);
277 std::vector<int> jmat(mat_size+1);
278 std::vector<double> vmat(mat_size+1);
285 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
291 for(std::set<event_grapht::critical_cyclet>::iterator C_j =
292 subset_of_cycles.begin();
293 C_j != subset_of_cycles.end();
298 if(C_j->unsafe_pairs.find(*e_i)!=C_j->unsafe_pairs.end())
309 for(i=1; i<=mat_size; ++i)
315 glp_load_matrix(lp, mat_size, imat, jmat, vmat);
316 glp_intopt(lp, &parm);
322 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
328 if(glp_mip_col_val(lp, i)>=1)
333 std::pair<irep_idt, source_locationt>(
340 std::pair<irep_idt, source_locationt>(
348 (void)subset_of_cycles;
349 throw "sorry, minimum interference option requires glpk; "
350 "please recompile goto-instrument with glpk";
355 const std::set<event_grapht::critical_cyclet> &set,
358 for(std::set<event_grapht::critical_cyclet>::const_iterator
362 for(std::set<event_grapht::critical_cyclet::delayt>::const_iterator
363 p_it=it->unsafe_pairs.begin();
364 p_it!=it->unsafe_pairs.end(); ++p_it)
371 std::pair<irep_idt, source_locationt>(
378 std::pair<irep_idt, source_locationt>(second_ev.
variable,
397 for(std::size_t i=0; i<
num_sccs; ++i)
407 file.open(
"inst.evt");
408 std::set<event_idt> this_set;
415 for(std::size_t i=0; i<size; i++)
418 this_set.insert(tmp);
source_locationt source_location
std::multimap< irep_idt, source_locationt > id2cycloc
void instrument_one_event_per_cycle_inserter(const set_of_cyclest &set)
void instrument_my_events(const std::set< event_idt > &events)
void instrument_all_inserter(const set_of_cyclest &set)
void instrument_one_read_per_cycle_inserter(const set_of_cyclest &set)
std::set< event_grapht::critical_cyclet > set_of_cycles
void instrument_with_strategy(instrumentation_strategyt strategy)
std::set< irep_idt > var_to_instr
void instrument_one_write_per_cycle_inserter(const set_of_cyclest &set)
std::multimap< irep_idt, source_locationt > id2loc
void instrument_my_events_inserter(const set_of_cyclest &set, const std::set< event_idt > &events)
void instrument_minimum_interference_inserter(const set_of_cyclest &set)
std::vector< std::set< event_grapht::critical_cyclet > > set_of_cycles_per_SCC
unsigned cost(const event_grapht::critical_cyclet::delayt &e)
cost function
static std::set< event_idt > extract_my_events()
mstreamt & statistics() const
#define UNREACHABLE
This should be used to mark dead code.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
instrumentation_strategyt