1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#include <assert.h>
#include <errno.h>
#include <iostream>
#include <stdlib.h>
#include <boost/type_traits/is_same.hpp>
#include "everything_else.hpp"
#include "pla_getbyname.hpp"
#include "sim_replay.hpp"
#include "system_helpers.hpp"
#include "template_helpers.hpp"
#include "time.hpp"
#include "model.hpp"
using namespace std;
template<typename Prop, typename QuantClass = typename Prop::quant::class_t>
struct Replay;
template<>
struct Replay<BaseCase, Void> {
virtual void operator() (TimeSpan span, IdList<uint64_t> &ids) {
assert(false);
}
};
template<typename Prop>
struct Replay<Prop, ContinuousPropertyClass> : Replay<BaseCase, Void> {
typedef typename Prop::quant Quant;
virtual void operator() (TimeSpan span, IdList<uint64_t> &raw_ids) {
IdList<typename Quant::instance_ptr_t::ptr_t> ids(raw_ids);
for (auto i : ids)
assert(i < Ptr<Quant>::numInstances());
SimReplay<Lists::all_ro, Quant> simReplay{ids, span.begin()()};
// header
cout << "# " << Quant::name << "\n# time";
for (auto i : ids)
cout << "\t" << (uint64_t) i;
cout << endl;
// body
for (TimeSpan::iterator t=span.begin(); t.hasNext(); ++t) {
cout << t()();
for (auto i : ids)
cout << "\t" << simReplay.template get<Prop>(Ptr<Quant>(i), t());
cout << endl;
}
}
};
template<typename Prop>
struct Replay<Prop, DiscretePropertyClass> : Replay<BaseCase, Void> {
virtual void operator() (TimeSpan span, IdList<uint64_t> &raw_ids) {
cerr << Prop::name << " is a discrete property" << endl;
exit(-1);
}
};
int realmain(int argc, char **argv) __attribute__((noinline));
int realmain(int argc, char **argv) {
if (argc != 6) {
cout << "Usage: " << argv[0] << " property instance start stop delta" << endl;
return -1;
}
garantueeStackSize(64 * 1024 * 1024);
// read cmd line params
Replay<BaseCase, Void> *replay(NULL);
{
PropertyComposition<Lists::all_ro> pc;
PLA_GetByName<Replay> pla(argv[1]);
replay = pc.call(pla);
assert(replay != NULL);
}
errno = 0;
char *tail;
IdList<uint64_t> ids(argv[2]);
Time start(strtod(argv[3], &tail)); assert(*tail == 0);
Time stop( strtod(argv[4], &tail)); assert(*tail == 0);
Time delta(strtod(argv[5], &tail)); assert(*tail == 0);
assert(errno == 0);
TimeSpan span(start, stop, delta);
// replay simulation
(*replay)(span, ids);
return 0;
}
int main(int argc, char **argv) {
garantueeStackSize(64 * 1024 * 1024);
assertSimDir();
return realmain(argc, argv);
}
|