Change-Id: I8022d937477668253c613e97c3a579ae65084b1e
This commit is contained in:
Horst Schirmeier
2014-02-09 18:54:21 +01:00
parent 5df364dea2
commit 277958b31b
45 changed files with 430 additions and 444 deletions

View File

@ -5,19 +5,18 @@
class ResultCollector;
class BasicAlgorithm {
public:
/**
*
* @returns boolean value for calculation success
*/
virtual bool calculateAllHops(fail::TraceReader& trace) = 0;
public:
/**
*
* @returns boolean value for calculation success
*/
virtual bool calculateAllHops(fail::TraceReader& trace) = 0;
BasicAlgorithm(ResultCollector *rc) {m_resultCollector = rc;}
virtual ~BasicAlgorithm() {}
BasicAlgorithm(ResultCollector *rc) { m_resultCollector = rc; }
virtual ~BasicAlgorithm() {}
protected:
ResultCollector *m_resultCollector;
protected:
ResultCollector *m_resultCollector;
};
#endif // __BASIC_ALGORITHM__HPP

View File

@ -5,7 +5,7 @@ set(SRCS
)
if(NOT CONFIG_INJECTIONPOINT_HOPS)
message (FATAL_ERROR "For building the compute-hops tool you need to enable CONFIG_INJECTIONPOINT_HOPS")
message (FATAL_ERROR "For building the compute-hops tool you need to enable CONFIG_INJECTIONPOINT_HOPS")
endif()
add_executable(compute-hops main.cc ${SRCS})

View File

@ -74,7 +74,7 @@ ResultCollector::addResult(std::vector<result_tuple >& res, unsigned int costs)
if (ps) {
InjectionPointMessage hc;
hc.set_costs(costs);
hc.set_target_trace_position(res.back().second);
hc.set_target_trace_position(res.back().second);
// If checkpoint at beginning of hop-chain, add its id to InjectionPointMessage
std::vector<result_tuple >::iterator it_hop = res.begin();
if (it_hop != res.end() && it_hop->first.second == ACCESS_CHECKPOINT) {
@ -82,7 +82,7 @@ ResultCollector::addResult(std::vector<result_tuple >& res, unsigned int costs)
it_hop++;
}
for(;it_hop != res.end();
for (; it_hop != res.end();
it_hop++) {
InjectionPointMessage_Hops *hop = hc.add_hops();
hop->set_address(it_hop->first.first);
@ -111,7 +111,7 @@ ResultCollector::addResult(std::vector<result_tuple >& res, unsigned int costs)
}
ps->writeMessage(&hc);
} else {
for(std::vector<result_tuple >::iterator it_hop = res.begin();
for (std::vector<result_tuple >::iterator it_hop = res.begin();
it_hop != res.end();
it_hop++) {
address_t add = it_hop->first.first;

View File

@ -45,7 +45,7 @@ public:
m_checkpoint_count(1),
m_it_mean_costs(0),
m_max_costs(0),
ps(0){}
ps(0) {}
void
addResult(std::vector<result_tuple >& res, unsigned int costs);
@ -87,5 +87,3 @@ private:
};
#endif /* STATISTICSCOLLECTOR_HPP_ */

View File

@ -1,7 +1,6 @@
#ifndef SIMPLE_ALGORITHM__HPP
#define SIMPLE_ALGORITHM__HPP
//#include <vector>
#include <map>
#include "BasicAlgorithm.hpp"
@ -16,15 +15,14 @@ public:
SimpleAlgorithm(ResultCollector *rc) : BasicAlgorithm(rc) {}
virtual ~SimpleAlgorithm() {}
bool calculateAllHops(TraceReader& trace);
bool calculateAllHops(TraceReader& trace);
private:
// Count occurences
//map<trace_event_tuple_t, vector<trace_pos_t> > m_occurences;
std::map<trace_event_tuple_t, unsigned long > m_occurences;
// Count occurences
//map<trace_event_tuple_t, vector<trace_pos_t> > m_occurences;
std::map<trace_event_tuple_t, unsigned long> m_occurences;
std::map<trace_event_tuple_t, unsigned long > m_occ_cp;
std::map<trace_event_tuple_t, unsigned long> m_occ_cp;
};
#endif // SIMPLE_ALGORITHM__HPP

View File

@ -71,7 +71,7 @@ bool SmartAlgorithm::calculateAllHops(TraceReader& trace)
continue;
}
// Deltion of unnecessary hops
// Deletion of unnecessary hops
/*
* |----------------|

View File

@ -21,19 +21,19 @@ public:
SmartAlgorithm(ResultCollector *rc) : BasicAlgorithm(rc), m_next_cp_id(0) {}
virtual ~SmartAlgorithm() {}
bool calculateAllHops(TraceReader& trace);
bool calculateAllHops(TraceReader& trace);
private:
bool
bool
occurenceInPosIntervall(unsigned int intervall_low,
unsigned int intervall_high,
address_t add,
mem_access_type_e acc);
std::map<trace_event_tuple_t, trace_pos_t> m_last_positions;
std::vector<checkpoint_tuple_t > m_checkpoints;
unsigned int m_next_cp_id;
std::map<trace_event_tuple_t, trace_pos_t> m_last_positions;
std::vector<checkpoint_tuple_t > m_checkpoints;
unsigned int m_next_cp_id;
};
#endif // SMART_ALGORITHM__HPP

View File

@ -37,7 +37,6 @@ Logger LOG("hop-calculator", false);
int main(int argc, char *argv[])
{
// Manually fill the command line option parser
CommandLine &cmd = CommandLine::Inst();
@ -239,7 +238,7 @@ int main(int argc, char *argv[])
if (cmd[CHECKPOINT_OUTPUT_FILE].count() > 0) {
std::string filename(cmd[CHECKPOINT_OUTPUT_FILE].first()->arg);
g_cp_ofstream.open(filename.c_str());
if(!g_cp_ofstream.is_open()) {
if (!g_cp_ofstream.is_open()) {
LOG << "Unable to open cp_out_file " << filename << std::endl;
exit(-1);
}
@ -282,32 +281,32 @@ int main(int argc, char *argv[])
BasicAlgorithm *algo;
switch (algorithm) {
case ALGO_SMART:
algo = new SmartAlgorithm(&rc);
break;
case ALGO_SIMPLE:
algo = new SimpleAlgorithm(&rc);
break;
default:
break;
switch (algorithm) {
case ALGO_SMART:
algo = new SmartAlgorithm(&rc);
break;
case ALGO_SIMPLE:
algo = new SimpleAlgorithm(&rc);
break;
default:
break;
}
rc.startTimer();
algo->calculateAllHops(trace);
rc.stopTimer();
rc.startTimer();
algo->calculateAllHops(trace);
rc.stopTimer();
rc.finish();
rc.finish();
// ToDo: close output file if not stdout
// ToDo: close output file if not stdout
if (outFile != &std::cout) {
((std::ofstream*)outFile)->close();
delete (std::ofstream*)outFile;
}
if (g_use_checkpoints) {
g_cp_ofstream.close();
}
if (g_use_checkpoints) {
g_cp_ofstream.close();
}
return 0;
return 0;
}