Fail* directories reorganized, Code-cleanup (-> coding-style), Typos+comments fixed.
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1321 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
31
src/experiments/mh-test-campaign/CMakeLists.txt
Normal file
31
src/experiments/mh-test-campaign/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
set(EXPERIMENT_NAME mh-test-campaign)
|
||||
set(EXPERIMENT_TYPE MHTestExperiment)
|
||||
configure_file(../instantiate-experiment.ah.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/instantiate-${EXPERIMENT_NAME}.ah @ONLY
|
||||
)
|
||||
|
||||
## Setup desired protobuf descriptions HERE ##
|
||||
set(MY_PROTOS
|
||||
MHTest.proto
|
||||
)
|
||||
|
||||
set(MY_CAMPAIGN_SRCS
|
||||
MHTestCampaign.hpp
|
||||
MHTestCampaign.cc
|
||||
experiment.hpp
|
||||
experiment.cc
|
||||
)
|
||||
|
||||
#### PROTOBUFS ####
|
||||
find_package(Protobuf REQUIRED)
|
||||
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MY_PROTOS})
|
||||
|
||||
## Build library
|
||||
add_library(${EXPERIMENT_NAME} ${PROTO_SRCS} ${PROTO_HDRS} ${MY_CAMPAIGN_SRCS})
|
||||
|
||||
## This is the example's campaign server distributing experiment parameters
|
||||
add_executable(${EXPERIMENT_NAME}-server mhcampaign.cc)
|
||||
target_link_libraries(${EXPERIMENT_NAME}-server fail ${PROTOBUF_LIBRARY} ${Boost_THREAD_LIBRARY})
|
||||
5
src/experiments/mh-test-campaign/MHTest.proto
Normal file
5
src/experiments/mh-test-campaign/MHTest.proto
Normal file
@ -0,0 +1,5 @@
|
||||
message MHTestData {
|
||||
optional string foo = 1;
|
||||
optional int32 input = 2;
|
||||
optional int32 output = 3;
|
||||
}
|
||||
42
src/experiments/mh-test-campaign/MHTestCampaign.cc
Normal file
42
src/experiments/mh-test-campaign/MHTestCampaign.cc
Normal file
@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "MHTestCampaign.hpp"
|
||||
#include <cpn/CampaignManager.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace fail;
|
||||
|
||||
bool MHTestCampaign::run()
|
||||
{
|
||||
MHExperimentData* datas[m_parameter_count];
|
||||
cout << "[MHTestCampaign] Adding " << m_parameter_count << " values." << endl;
|
||||
for (int i = 1; i <= m_parameter_count; i++) {
|
||||
datas[i] = new MHExperimentData;
|
||||
datas[i]->msg.set_input(i);
|
||||
|
||||
campaignmanager.addParam(datas[i]);
|
||||
usleep(100 * 1000); // 100 ms
|
||||
}
|
||||
campaignmanager.noMoreParameters();
|
||||
// test results.
|
||||
int f;
|
||||
int res = 0;
|
||||
int res2 = 0;
|
||||
MHExperimentData * exp;
|
||||
for (int i = 1; i <= m_parameter_count; i++) {
|
||||
exp = static_cast<MHExperimentData*>(campaignmanager.getDone());
|
||||
f = exp->msg.output();
|
||||
// cout << ">>>>>>>>>>>>>>> Output: " << i << "^2 = " << f << endl;
|
||||
res += f;
|
||||
res2 += (i*i);
|
||||
delete exp;
|
||||
}
|
||||
if (res == res2) {
|
||||
cout << "TEST SUCCESSFUL FINISHED! " << "[" << res << "==" << res2 << "]" << endl;
|
||||
} else {
|
||||
cout << "TEST FAILED!" << " [" << res << "!=" << res2 << "]" << endl;
|
||||
}
|
||||
cout << "thats all... " << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
22
src/experiments/mh-test-campaign/MHTestCampaign.hpp
Normal file
22
src/experiments/mh-test-campaign/MHTestCampaign.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef __MH_TEST_CAMPAIGN_HPP__
|
||||
#define __MH_TEST_CAMPAIGN_HPP__
|
||||
|
||||
#include <cpn/Campaign.hpp>
|
||||
#include "comm/ExperimentData.hpp"
|
||||
#include "MHTest.pb.h"
|
||||
|
||||
class MHExperimentData : public fail::ExperimentData {
|
||||
public:
|
||||
MHTestData msg;
|
||||
MHExperimentData() : fail::ExperimentData(&msg) { }
|
||||
};
|
||||
|
||||
class MHTestCampaign : public fail::Campaign {
|
||||
private:
|
||||
int m_parameter_count;
|
||||
public:
|
||||
MHTestCampaign(int parametercount) : m_parameter_count(parametercount) { }
|
||||
bool run();
|
||||
};
|
||||
|
||||
#endif // __MH_TEST_CAMPAIGN_HPP__
|
||||
46
src/experiments/mh-test-campaign/experiment.cc
Normal file
46
src/experiments/mh-test-campaign/experiment.cc
Normal file
@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "experiment.hpp"
|
||||
#include "MHTestCampaign.hpp"
|
||||
#include "sal/SALInst.hpp"
|
||||
#include "sal/Register.hpp"
|
||||
#include "sal/Event.hpp"
|
||||
|
||||
// FIXME: You should provide a dependency check here!
|
||||
|
||||
using namespace std;
|
||||
using namespace fail;
|
||||
|
||||
bool MHTestExperiment::run()
|
||||
{
|
||||
cout << "[MHTestExperiment] Let's go" << endl;
|
||||
#if 0
|
||||
BPSingleEvent mainbp(0x00003c34);
|
||||
simulator.addEventAndWait(&mainbp);
|
||||
cout << "[MHTestExperiment] breakpoint reached, saving" << endl;
|
||||
simulator.save("hello.main");
|
||||
#else
|
||||
MHExperimentData par;
|
||||
if (m_jc.getParam(par)) {
|
||||
int num = par.msg.input();
|
||||
cout << "[MHExperiment] stepping " << num << " instructions" << endl;
|
||||
if (num > 0) {
|
||||
BPSingleEvent nextbp(ANY_ADDR);
|
||||
nextbp.setCounter(num);
|
||||
simulator.addEventAndWait(&nextbp);
|
||||
}
|
||||
address_t instr = simulator.getRegisterManager().getInstructionPointer();
|
||||
cout << "[MHTestExperiment] Reached instruction: "
|
||||
<< hex << instr
|
||||
<< endl;
|
||||
par.msg.set_output(instr);
|
||||
m_jc.sendResult(par);
|
||||
} else {
|
||||
cout << "No data for me? :(" << endl;
|
||||
}
|
||||
#endif
|
||||
simulator.clearEvents(this);
|
||||
|
||||
simulator.terminate();
|
||||
return true;
|
||||
}
|
||||
17
src/experiments/mh-test-campaign/experiment.hpp
Normal file
17
src/experiments/mh-test-campaign/experiment.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __MH_TEST_EXPERIMENT_HPP__
|
||||
#define __MH_TEST_EXPERIMENT_HPP__
|
||||
|
||||
#include "efw/ExperimentFlow.hpp"
|
||||
#include "efw/JobClient.hpp"
|
||||
|
||||
class MHTestExperiment : public fail::ExperimentFlow {
|
||||
private:
|
||||
fail::JobClient m_jc;
|
||||
public:
|
||||
MHTestExperiment() { }
|
||||
~MHTestExperiment() { }
|
||||
|
||||
bool run();
|
||||
};
|
||||
|
||||
#endif // __MH_TEST_EXPERIMENT_HPP__
|
||||
24
src/experiments/mh-test-campaign/mhcampaign.cc
Normal file
24
src/experiments/mh-test-campaign/mhcampaign.cc
Normal file
@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "cpn/CampaignManager.hpp"
|
||||
#include "MHTestCampaign.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
int paramcount = 0;
|
||||
if (argc == 2)
|
||||
paramcount = atoi(argv[1]);
|
||||
else
|
||||
paramcount = 10;
|
||||
cout << "Running MHTestCampaign [" << paramcount << " parameter sets]" << endl;
|
||||
|
||||
MHTestCampaign mhc(paramcount);
|
||||
fail::campaignmanager.runCampaign(&mhc);
|
||||
|
||||
cout << "Campaign complete." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user