55 for(std::size_t i=0; i<
num_sccs; ++i)
86 for(std::set<event_grapht::critical_cyclet>::const_iterator
87 it=(set_of_cycles).begin();
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> &
set_of_cycles)
116 std::set<event_grapht::critical_cyclet::delayt> delayed;
118 for(std::set<event_grapht::critical_cyclet>::iterator
119 it=set_of_cycles.begin();
120 it!=set_of_cycles.end(); ++it)
124 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
125 p_it=it->unsafe_pairs.begin();
126 p_it!=it->unsafe_pairs.end(); ++p_it)
128 if(delayed.find(*p_it)!=delayed.end())
139 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
140 p_it=it->unsafe_pairs.begin();
141 p_it!=it->unsafe_pairs.end(); ++p_it)
143 delayed.insert(*p_it);
147 std::pair<irep_idt, source_locationt>(
154 std::pair<irep_idt, source_locationt>(
163 const std::set<event_grapht::critical_cyclet> &
set_of_cycles)
166 throw "read first strategy not implemented yet";
170 const std::set<event_grapht::critical_cyclet> &
set_of_cycles)
173 throw "write first strategy not implemented yet";
193 const std::set<event_grapht::critical_cyclet> &
set_of_cycles)
219 std::set<event_grapht::critical_cyclet::delayt> edges;
220 for(std::set<event_grapht::critical_cyclet>::iterator
221 C_j=set_of_cycles.begin();
222 C_j!=set_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);
240 message.
debug() <<
"edges: "<<edges.size()<<
" cycles:"<<set_of_cycles.size()
244 glp_add_cols(lp, edges.size());
246 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
252 std::string name=
"e_"+std::to_string(i);
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, set_of_cycles.size());
262 for(std::set<event_grapht::critical_cyclet>::iterator
263 C_j=set_of_cycles.begin();
264 C_j!=set_of_cycles.end();
268 std::string name=
"C_"+std::to_string(i);
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=set_of_cycles.size()*edges.size();
276 int *imat=
new int[mat_size+1];
277 int *jmat=
new int[mat_size+1];
278 double *vmat=
new double[mat_size+1];
285 for(std::set<event_grapht::critical_cyclet::delayt>::iterator
291 for(std::set<event_grapht::critical_cyclet>::iterator
292 C_j=set_of_cycles.begin();
293 C_j!=set_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>(
351 throw "sorry, minimum interference option requires glpk; " 352 "please recompile goto-instrument with glpk";
357 const std::set<event_grapht::critical_cyclet> &
set,
360 for(std::set<event_grapht::critical_cyclet>::const_iterator
364 for(std::set<event_grapht::critical_cyclet::delayt>::const_iterator
365 p_it=it->unsafe_pairs.begin();
366 p_it!=it->unsafe_pairs.end(); ++p_it)
368 if(my_events.find(p_it->first)!=my_events.end())
373 std::pair<irep_idt, source_locationt>(
375 if(!p_it->is_po && my_events.find(p_it->second)!=my_events.end())
380 std::pair<irep_idt, source_locationt>(second_ev.
variable,
399 for(std::size_t i=0; i<
num_sccs; ++i)
409 file.open(
"inst.evt");
410 std::set<event_idt> this_set;
417 for(std::size_t i=0; i<size; i++)
420 this_set.insert(tmp);
std::set< irep_idt > var_to_instr
instrumentation_strategyt
unsigned cost(const event_grapht::critical_cyclet::delayt &e)
cost function
void instrument_my_events_inserter(const set_of_cyclest &set, const std::set< event_idt > &events)
void instrument_one_write_per_cycle_inserter(const set_of_cyclest &set)
static mstreamt & eom(mstreamt &m)
void instrument_my_events(const std::set< event_idt > &events)
void instrument_minimum_interference_inserter(const set_of_cyclest &set)
std::multimap< irep_idt, source_locationt > id2loc
std::multimap< irep_idt, source_locationt > id2cycloc
void instrument_with_strategy(instrumentation_strategyt strategy)
void instrument_one_event_per_cycle_inserter(const set_of_cyclest &set)
void instrument_all_inserter(const set_of_cyclest &set)
static std::set< event_idt > extract_my_events()
void instrument_one_read_per_cycle_inserter(const set_of_cyclest &set)
source_locationt source_location
std::set< event_grapht::critical_cyclet > set_of_cycles
std::vector< std::set< event_grapht::critical_cyclet > > set_of_cycles_per_SCC