Bladeren bron

Merge remote-tracking branch 'origin/master'

khvilaboa 5 jaren geleden
bovenliggende
commit
f3337b55a1

+ 53 - 5
devstone/adevs/src/DEVStone.cpp

@@ -5,6 +5,36 @@
 #include "DEVStone.hpp"
 
 
+DEVStone::DEVStone(const string& typeIn, int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn):
+        adevs::Digraph<int*>()
+{
+    Seeder *seeder = new Seeder(1);
+    add(seeder);
+
+    adevs::Digraph<int*> devstone;
+    if (typeIn == "LI") {
+        LI *li = new LI(depthIn, widthIn, intDelayIn, extDelayIn, procTimeIn);
+        add(li);
+        couple(seeder, seeder->out, li, li->in);
+    } else if (typeIn == "HI") {
+        HI *hi = new HI(depthIn, widthIn, intDelayIn, extDelayIn, procTimeIn);
+        add(hi);
+        couple(seeder, seeder->out, hi, hi->in);
+    } else if (typeIn == "HO") {
+        HO *ho = new HO(depthIn, widthIn, intDelayIn, extDelayIn, procTimeIn);
+        add(ho);
+        couple(seeder, seeder->out, ho, ho->in);
+    } else if (typeIn == "HOmod") {
+        HOmod *homod = new HOmod(depthIn, widthIn, intDelayIn, extDelayIn, procTimeIn);
+        add(homod);
+        couple(seeder, seeder->out, homod, homod->in1);
+        couple(seeder, seeder->out, homod, homod->in2);
+    } else {
+        throw runtime_error("Unable to determine DEVStone model type");
+    }
+}
+
+
 int main(int argc, char* argv[]) {
     auto start = hclock::now();
 
@@ -12,7 +42,7 @@ int main(int argc, char* argv[]) {
     po::options_description desc("Allowed options");
     desc.add_options()
             ("help", "produce help message")
-            ("kind", po::value<string>()->required(), "set kind of devstone: LI, HI or HO")
+            ("kind", po::value<string>()->required(), "set kind of devstone: LI, HI, HO, or HOmod")
             ("width", po::value<int>()->required(), "set width of the DEVStone: integer value")
             ("depth", po::value<int>()->required(), "set depth of the DEVStone: integer value")
             ("int-cycles", po::value<int>()->required(), "set the Dhrystone cycles to expend in internal transtions: integer value")
@@ -36,8 +66,8 @@ int main(int argc, char* argv[]) {
         }
     }
     string kind = vm["kind"].as<string>();
-    if (kind != "LI"  && kind != "HI" && kind != "HO") {
-        cout << "The kind needs to be LI, HI or HO and received value was: " << kind;
+    if (kind != "LI"  && kind != "HI" && kind != "HO" && kind != "HOmod") {
+        cout << "The kind needs to be LI, HI, HO, or HOmod and received value was: " << kind;
         cout << endl;
         cout << "for mode information run: " << argv[0] << " --help" << endl;
         return 1;
@@ -49,7 +79,25 @@ int main(int argc, char* argv[]) {
     int ext_cycles = vm["ext-cycles"].as<int>();
     int time_advance = vm["time-advance"].as<int>();
 
+    auto processed_parameters = hclock::now();
 
-    LI c = LI(2, 1, 0, 0, 0.0);
- return 0;
+    DEVStone *devstone = new DEVStone(kind, depth, width, int_cycles, ext_cycles, time_advance);
+
+    auto model_built = hclock::now();
+
+    cout << endl;
+    cout << "Model creation time: " << chrono::duration_cast<chrono::duration<double, ratio<1>>>( model_built - processed_parameters).count() << endl;
+    adevs::Simulator<IO_Type> sim(devstone);
+
+    auto model_init = hclock::now();
+
+    cout << "Engine setup time: " << chrono::duration_cast<chrono::duration<double, ratio<1>>>( model_init - model_built).count() << endl;
+    while (sim.nextEventTime() < DBL_MAX)
+    {
+        sim.execNextEvent();
+    }
+    /// Done!
+    auto finished_simulation = hclock::now();
+    cout << "Simulation time: " << chrono::duration_cast<chrono::duration<double, ratio<1>>>( finished_simulation - model_init).count() << endl;
+    return 0;
 }

+ 9 - 0
devstone/adevs/src/DEVStone.hpp

@@ -8,15 +8,24 @@
 #include <boost/program_options.hpp>
 #include <iostream>
 #include <chrono>
+#include <string>
 
 #include "utils.hpp"
 #include "li.hpp"
 #include "hi.hpp"
 #include "ho.hpp"
 #include "hoMod.hpp"
+#include "seeder.hpp"
 
 using namespace std;
 namespace po=boost::program_options;
 using hclock=chrono::high_resolution_clock;
 
+
+class DEVStone: public adevs::Digraph<int*>
+{
+public:
+    DEVStone(const string& typeIn, int depthIn, int widthIn, int intDelayIn, int extDelayIn, double propTimeIn);
+};
+
 #endif //DEVSTONE_ADEVS_DEVSTONE_HPP

+ 3 - 13
devstone/adevs/src/DummyAtomic.cpp

@@ -20,36 +20,26 @@ void DummyAtomic::delta_ext(double e, const adevs::Bag<IO_Type>& x) {
     t += e;
     if (sigma != DBL_MAX) {
         sigma -= e;
+    } else {
+        sigma = procTime;
     }
-    // Add the new values to the back of the list.
-    adevs::Bag<IO_Type>::const_iterator i = x.begin();
-    values.push_back(new int(*((*i).value)));
-    sigma = procTime;
 }
 
 /// Internal transition function
 void DummyAtomic::delta_int() {
     t += sigma;
-    // Done with the job, so set time of next event to infinity
     sigma = DBL_MAX;
-    values.clear();
 }
 
 /// Confluent transition function.
 void DummyAtomic::delta_conf(const adevs::Bag<IO_Type>& x) {
-    // Discard the old job
     delta_int();
-    // Process the incoming job
     delta_ext(0.0, x);
 }
 
 /// Output function.
 void DummyAtomic::output_func(adevs::Bag<IO_Type >& y) {
-    // Get the departing customer
-    std::list<int*>::iterator i;
-    for (i = values.begin(); i != values.end(); i++) {
-        y.insert(IO_Type(out, *i));
-    }
+    y.insert(IO_Type(out, 0));
 }
 
 /// Time advance function.

+ 0 - 1
devstone/adevs/src/DummyAtomic.hpp

@@ -17,7 +17,6 @@ class DummyAtomic: public adevs::Atomic<IO_Type> {
         int extDelay;
         double sigma;
         double procTime;
-        std::list<int*> values;
         double t;
     public:
         /// Model input port

+ 1 - 0
devstone/adevs/src/ho.hpp

@@ -10,6 +10,7 @@
 #include "DEVSWrapper.hpp"
 
 class HO: public DEVSWrapper {
+public:
     HO(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn);
 };
 

+ 6 - 6
devstone/adevs/src/hoMod.cpp

@@ -6,11 +6,11 @@
 #include <map>
 #include <list>
 
-const int HOMod::in1 = 0;
-const int HOMod::in2 = 1;
-const int HOMod::out = 2;
+const int HOmod::in1 = 0;
+const int HOmod::in2 = 1;
+const int HOmod::out = 2;
 
-HOMod::HOMod(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn):
+HOmod::HOmod(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn):
 adevs::Digraph<int*>()
 {
     depth = depthIn;
@@ -25,7 +25,7 @@ adevs::Digraph<int*>()
         couple(this, this->in1, a, a->in);
         couple(a, a->out, this, this->out);
     } else {
-        HOMod *c = new HOMod(depth - 1, width, intDelay, extDelay, procTime);
+        HOmod *c = new HOmod(depth - 1, width, intDelay, extDelay, procTime);
         couple(this, this->in1, c, c->in1);
         couple(c, c->out, this, this->out);
         if (width > 1) {
@@ -52,7 +52,7 @@ adevs::Digraph<int*>()
             for (auto a: atomics.find(0)->second) {
                 couple(a, a->out, c, c->in2);
             }
-            for (int i = 0; i < atomics.find(1)->second.size(); i++) {
+            for (int i = 0; i < atomics.find(1)->second.size(); i++) {  // TODO cambiar esto para el HOmod nuevo
                 DummyAtomic *aDown = *std::next(atomics.find(1)->second.begin(), i);
                 DummyAtomic *aTop = *std::next(atomics.find(0)->second.begin(), i);
                 couple(aDown, aDown->out, aTop, aTop->in);

+ 2 - 2
devstone/adevs/src/hoMod.hpp

@@ -9,7 +9,7 @@
 #include "DummyAtomic.hpp"
 
 
-class HOMod: public adevs::Digraph<int*> {
+class HOmod: public adevs::Digraph<int*> {
 protected:
     int depth, width;
     int intDelay, extDelay;
@@ -20,7 +20,7 @@ public:
     /// Model output port
     static const int out;
     // Constructor
-    HOMod(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn);
+    HOmod(int depthIn, int widthIn, int intDelayIn, int extDelayIn, double procTimeIn);
 };
 
 

+ 1 - 1
devstone/adevs/src/seeder.cpp

@@ -8,7 +8,7 @@ const int Seeder::out = 0;
 
 Seeder::Seeder(int nMessagesIn): adevs::Atomic<IO_Type>() {
     nMessages = nMessagesIn;
-    sigma = DBL_MAX;
+    sigma = 0;
     t = 0.0;
 }
 

+ 1 - 1
devstone_comparative.py

@@ -23,7 +23,7 @@ PYPDEVS_MIN_CMD = ""
 CADMIUM_CMD = "devstone/cadmium/build/cadmium-dynamic-devstone --kind={model_type} --depth={depth} --width={width} --int-cycles={int_cycles} --ext-cycles={ext_cycles}"
 CADMIUM_CONC_CMD = "devstone/cadmium/build/cadmium-dynamic-conc-devstone --kind={model_type} --depth={depth} --width={width} --int-cycles={int_cycles} --ext-cycles={ext_cycles} --threads=" + str(threads)
 CDBOOST_CMD = "devstone/cdboost/build/cdboost-devstone --kind={model_type} --depth={depth} --width={width} --int-cycles={int_cycles} --ext-cycles={ext_cycles} --event-list=events_devstone.txt"
-ADEVS_CMD = "devstone/adevs/build/DEVStone"  # TODO
+ADEVS_CMD = "devstone/adevs/build/DEVStone --kind={model_type} --depth={depth} --width={width} --int-cycles={int_cycles} --ext-cycles={ext_cycles}"
 
 DEFAULT_PARAMS = ((300, 10, 0, 0), (10, 300, 0, 0), (300, 300, 0, 0))
 DEFAULT_MODEL_TYPES = ("LI", "HI", "HO", "HOmod")