From c58eb9d2ccd79dec492a4baaf5a4aa066d5c999c Mon Sep 17 00:00:00 2001 From: hsc Date: Fri, 19 Oct 2012 17:52:10 +0000 Subject: [PATCH] nanojpeg experiment: counting instructions git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1772 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/experiments/nanojpeg/CMakeLists.txt | 37 +++++++++++ src/experiments/nanojpeg/experiment.cc | 62 +++++++++++++++++++ src/experiments/nanojpeg/experiment.hpp | 13 ++++ .../nanojpeg/instantiateExperiment.cc | 8 +++ 4 files changed, 120 insertions(+) create mode 100644 src/experiments/nanojpeg/CMakeLists.txt create mode 100644 src/experiments/nanojpeg/experiment.cc create mode 100644 src/experiments/nanojpeg/experiment.hpp create mode 100644 src/experiments/nanojpeg/instantiateExperiment.cc diff --git a/src/experiments/nanojpeg/CMakeLists.txt b/src/experiments/nanojpeg/CMakeLists.txt new file mode 100644 index 00000000..103d16e3 --- /dev/null +++ b/src/experiments/nanojpeg/CMakeLists.txt @@ -0,0 +1,37 @@ +set(EXPERIMENT_NAME nanojpeg) +set(EXPERIMENT_TYPE NanoJPEGExperiment) +configure_file(../instantiate-experiment-indirect.ah.in + ${CMAKE_CURRENT_BINARY_DIR}/instantiate-${EXPERIMENT_NAME}.ah @ONLY +) +#add_aspect_headers(${CMAKE_CURRENT_BINARY_DIR}/instantiate-${EXPERIMENT_NAME}.ah) + +## Setup desired protobuf descriptions HERE ## +set(MY_PROTOS + nanojpeg.proto +) + +set(MY_CAMPAIGN_SRCS + instantiateExperiment.cc + experiment.hpp + experiment.cc +) +# experimentInfo.hpp +# campaign.hpp +# campaign.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(fail-${EXPERIMENT_NAME} ${PROTO_SRCS} ${PROTO_HDRS} ${MY_CAMPAIGN_SRCS}) +add_dependencies(fail-${EXPERIMENT_NAME} fail-tracing) +target_link_libraries(fail-${EXPERIMENT_NAME} ${PROTOBUF_LIBRARY}) + +## This is the example's campaign server distributing experiment parameters +#add_executable(${EXPERIMENT_NAME}-server main.cc) +#target_link_libraries(${EXPERIMENT_NAME}-server fail-${EXPERIMENT_NAME} fail ${PROTOBUF_LIBRARY} ${Boost_THREAD_LIBRARY}) +#install(TARGETS ${EXPERIMENT_NAME}-server RUNTIME DESTINATION bin) diff --git a/src/experiments/nanojpeg/experiment.cc b/src/experiments/nanojpeg/experiment.cc new file mode 100644 index 00000000..62edaddc --- /dev/null +++ b/src/experiments/nanojpeg/experiment.cc @@ -0,0 +1,62 @@ +#include + +// getpid +#include +#include + +#include "util/Logger.hpp" + +#include "experiment.hpp" +//#include "experimentInfo.hpp" +//#include "campaign.hpp" + +#include "sal/SALConfig.hpp" +#include "sal/SALInst.hpp" +#include "sal/Memory.hpp" +#include "sal/Listener.hpp" + +// you need to have the tracing plugin enabled for this +#include "../plugins/tracing/TracingPlugin.hpp" + +#define LOCAL 1 + +using namespace std; +using namespace fail; + +// Check if configuration dependencies are satisfied: +//#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_SR_RESTORE) || \ +// !defined(CONFIG_SR_SAVE) || !defined(CONFIG_EVENT_TRAP) +// #error This experiment needs: breakpoints, traps, save, and restore. Enable these in the configuration. +//#endif + +bool NanoJPEGExperiment::run() +{ + char const *statename = "bochs.state"; // WEATHER_SUFFIX; + Logger log("nJPEG", true); + + log << "startup" << endl; + +#if 1 + // STEP 1: run until main starts, save state + // TODO: record trace, store golden run output + IOPortListener io(0x3f8, true); + simulator.addListenerAndResume(&io); + + log << "main() reached, saving state" << endl; + simulator.save(statename); + + simulator.addListener(&io); + BPSingleListener step(ANY_ADDR); + long counter = 0; + while (true) { + BaseListener *l = simulator.addListenerAndResume(&step); + if (l == &io) { + break; + } + counter++; + } + log << "golden run took " << counter << " instructions" << endl; +#endif + // Explicitly terminate, or the simulator will continue to run. + simulator.terminate(); +} diff --git a/src/experiments/nanojpeg/experiment.hpp b/src/experiments/nanojpeg/experiment.hpp new file mode 100644 index 00000000..43a80b27 --- /dev/null +++ b/src/experiments/nanojpeg/experiment.hpp @@ -0,0 +1,13 @@ +#ifndef __NANOJPEG_EXPERIMENT_HPP__ + #define __NANOJPEG_EXPERIMENT_HPP__ + +#include "efw/ExperimentFlow.hpp" +#include "efw/JobClient.hpp" + +class NanoJPEGExperiment : public fail::ExperimentFlow { + fail::JobClient m_jc; +public: + bool run(); +}; + +#endif // __NANOJPEG_EXPERIMENT_HPP__ diff --git a/src/experiments/nanojpeg/instantiateExperiment.cc b/src/experiments/nanojpeg/instantiateExperiment.cc new file mode 100644 index 00000000..98493577 --- /dev/null +++ b/src/experiments/nanojpeg/instantiateExperiment.cc @@ -0,0 +1,8 @@ +#include "experiment.hpp" +#include "sal/SALInst.hpp" + +static NanoJPEGExperiment experiment; +void instantiateNanoJPEGExperiment() +{ + fail::simulator.addFlow(&experiment); +}