nanojpeg: load existing results before starting campaign
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1823 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -69,13 +69,6 @@ bool NanoJPEGCampaign::run()
|
|||||||
}
|
}
|
||||||
ProtoIStream ps(&tracef);
|
ProtoIStream ps(&tracef);
|
||||||
|
|
||||||
// experiment count
|
|
||||||
int count_exp = 0;
|
|
||||||
int count_exp_jobs = 0;
|
|
||||||
// known output count
|
|
||||||
int count_known = 0;
|
|
||||||
int count_known_jobs = 0;
|
|
||||||
|
|
||||||
// instruction counter within trace
|
// instruction counter within trace
|
||||||
unsigned instr = 0;
|
unsigned instr = 0;
|
||||||
|
|
||||||
@ -151,7 +144,6 @@ bool NanoJPEGCampaign::run()
|
|||||||
// new EC with experiments: acc->first -- instr, common_mask
|
// new EC with experiments: acc->first -- instr, common_mask
|
||||||
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
|
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
|
||||||
count_exp += add_experiment_ec(acc->first, instr, ev.ip(), reg, common_mask);
|
count_exp += add_experiment_ec(acc->first, instr, ev.ip(), reg, common_mask);
|
||||||
count_exp_jobs++;
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// new memory access EC in access cascade
|
// new memory access EC in access cascade
|
||||||
@ -196,7 +188,6 @@ bool NanoJPEGCampaign::run()
|
|||||||
// new EC with known result: acc->first -- instr, common_mask
|
// new EC with known result: acc->first -- instr, common_mask
|
||||||
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
|
// if (reg != RID_EBP && reg != RID_ESI && reg != RID_EDI) {
|
||||||
count_known += add_known_ec(acc->first, instr, ev.ip(), reg, common_mask);
|
count_known += add_known_ec(acc->first, instr, ev.ip(), reg, common_mask);
|
||||||
count_known_jobs++;
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +207,7 @@ bool NanoJPEGCampaign::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
campaignmanager.noMoreParameters();
|
campaignmanager.noMoreParameters();
|
||||||
|
available_results.clear();
|
||||||
cout << "experiments planned: " << dec << count_exp
|
cout << "experiments planned: " << dec << count_exp
|
||||||
<< " (" << count_exp_jobs << " jobs)" << endl;
|
<< " (" << count_exp_jobs << " jobs)" << endl;
|
||||||
cout << "known outcome ECs: " << dec << count_known
|
cout << "known outcome ECs: " << dec << count_known
|
||||||
@ -278,7 +270,12 @@ int NanoJPEGCampaign::add_experiment_ec(unsigned instr_ecstart, unsigned instr_o
|
|||||||
c += v & 1;
|
c += v & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check result CSV if we already know the answer
|
bitmask = check_available(instr_offset, register_id, bitmask);
|
||||||
|
if (!bitmask) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
count_exp_jobs++;
|
||||||
|
|
||||||
// enqueue job
|
// enqueue job
|
||||||
NanoJPEGExperimentData *d = new NanoJPEGExperimentData;
|
NanoJPEGExperimentData *d = new NanoJPEGExperimentData;
|
||||||
@ -303,7 +300,12 @@ int NanoJPEGCampaign::add_known_ec(unsigned instr_ecstart, unsigned instr_offset
|
|||||||
c += v & 1;
|
c += v & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check result CSV if we already stored the answer
|
bitmask = check_available(instr_offset, register_id, bitmask);
|
||||||
|
if (!bitmask) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
count_known_jobs++;
|
||||||
|
|
||||||
add_result(instr_ecstart, instr_offset, instr_address, register_id, 0, 0,
|
add_result(instr_ecstart, instr_offset, instr_address, register_id, 0, 0,
|
||||||
bitmask, NanoJPEGProtoMsg_Result::FINISHED, 0, INFINITY, "");
|
bitmask, NanoJPEGProtoMsg_Result::FINISHED, 0, INFINITY, "");
|
||||||
@ -314,31 +316,32 @@ bool NanoJPEGCampaign::init_results()
|
|||||||
{
|
{
|
||||||
// read already existing results
|
// read already existing results
|
||||||
bool file_exists = false;
|
bool file_exists = false;
|
||||||
/*
|
ifstream oldresults(NANOJPEG_RESULTS, ios::in);
|
||||||
set<uint64_t> existing_results;
|
|
||||||
ifstream oldresults(results_filename, ios::in);
|
|
||||||
if (oldresults.is_open()) {
|
if (oldresults.is_open()) {
|
||||||
char buf[16*1024];
|
char buf[16*1024];
|
||||||
uint64_t addr;
|
unsigned ignore;
|
||||||
|
unsigned instr_offset;
|
||||||
|
int register_id;
|
||||||
|
uint64_t bitmask;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
m_log << "scanning existing results ..." << endl;
|
m_log << "scanning existing results ..." << endl;
|
||||||
file_exists = true;
|
file_exists = true;
|
||||||
while (oldresults.getline(buf, sizeof(buf)).good()) {
|
while (oldresults.getline(buf, sizeof(buf)).good()) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << buf;
|
ss << buf;
|
||||||
ss >> addr;
|
ss >> hex >> ignore >> instr_offset >> ignore >> register_id >> ignore
|
||||||
|
>> ignore >> bitmask;
|
||||||
if (ss.fail()) {
|
if (ss.fail()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++count;
|
++count;
|
||||||
if (!existing_results.insert(addr).second) {
|
available_results
|
||||||
m_log << "duplicate: " << addr << endl;
|
[std::pair<unsigned, int>(instr_offset, register_id)]
|
||||||
}
|
|= bitmask;
|
||||||
}
|
}
|
||||||
m_log << "found " << dec << count << " existing results" << endl;
|
m_log << "found " << dec << count << " existing result rows" << endl;
|
||||||
oldresults.close();
|
oldresults.close();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// non-destructive: due to the CSV header we can always manually recover
|
// non-destructive: due to the CSV header we can always manually recover
|
||||||
// from an accident (append mode)
|
// from an accident (append mode)
|
||||||
@ -354,6 +357,17 @@ bool NanoJPEGCampaign::init_results()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t NanoJPEGCampaign::check_available(unsigned instr_offset,
|
||||||
|
fail::GPRegisterId register_id, uint64_t bitmask)
|
||||||
|
{
|
||||||
|
std::map<std::pair<unsigned, int>, uint64_t>::iterator it;
|
||||||
|
it = available_results.find(std::pair<unsigned, int>(instr_offset, (int)register_id));
|
||||||
|
if (it == available_results.end()) {
|
||||||
|
return bitmask;
|
||||||
|
}
|
||||||
|
return bitmask & ~it->second;
|
||||||
|
}
|
||||||
|
|
||||||
void NanoJPEGCampaign::add_result(unsigned instr_ecstart,
|
void NanoJPEGCampaign::add_result(unsigned instr_ecstart,
|
||||||
unsigned instr_offset, uint32_t instr_address, fail::GPRegisterId register_id,
|
unsigned instr_offset, uint32_t instr_address, fail::GPRegisterId register_id,
|
||||||
unsigned timeout, uint32_t injection_ip, uint64_t bitmask, int resulttype,
|
unsigned timeout, uint32_t injection_ip, uint64_t bitmask, int resulttype,
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
#define __NANOJPEG_CAMPAIGN_HPP__
|
#define __NANOJPEG_CAMPAIGN_HPP__
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "cpn/Campaign.hpp"
|
#include "cpn/Campaign.hpp"
|
||||||
#include "comm/ExperimentData.hpp"
|
#include "comm/ExperimentData.hpp"
|
||||||
@ -17,6 +19,8 @@ public:
|
|||||||
|
|
||||||
class NanoJPEGCampaign : public fail::Campaign {
|
class NanoJPEGCampaign : public fail::Campaign {
|
||||||
fail::Logger m_log;
|
fail::Logger m_log;
|
||||||
|
int count_exp, count_exp_jobs;
|
||||||
|
int count_known, count_known_jobs;
|
||||||
int add_experiment_ec(unsigned instr_ecstart, unsigned instr_offset,
|
int add_experiment_ec(unsigned instr_ecstart, unsigned instr_offset,
|
||||||
unsigned instr_address, fail::GPRegisterId register_id, uint64_t bitmask);
|
unsigned instr_address, fail::GPRegisterId register_id, uint64_t bitmask);
|
||||||
int add_known_ec(unsigned instr_ecstart, unsigned instr_offset,
|
int add_known_ec(unsigned instr_ecstart, unsigned instr_offset,
|
||||||
@ -27,9 +31,13 @@ class NanoJPEGCampaign : public fail::Campaign {
|
|||||||
unsigned timeout, uint32_t injection_ip, uint64_t bitmask,
|
unsigned timeout, uint32_t injection_ip, uint64_t bitmask,
|
||||||
int resulttype, uint32_t latest_ip, float psnr, char const *details);
|
int resulttype, uint32_t latest_ip, float psnr, char const *details);
|
||||||
void finalize_results();
|
void finalize_results();
|
||||||
|
uint64_t check_available(unsigned instr_offset,
|
||||||
|
fail::GPRegisterId register_id, uint64_t bitmask);
|
||||||
std::ofstream resultstream;
|
std::ofstream resultstream;
|
||||||
|
std::map<std::pair<unsigned, int>, uint64_t> available_results;
|
||||||
public:
|
public:
|
||||||
NanoJPEGCampaign() : m_log("nJPEG Campaign") {}
|
NanoJPEGCampaign() : m_log("nJPEG Campaign"),
|
||||||
|
count_exp(0), count_exp_jobs(0), count_known(0), count_known_jobs(0) {}
|
||||||
virtual bool run();
|
virtual bool run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user