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
|
#include <assert.h>
#include <errno.h>
#include <iostream>
#include <stdlib.h>
#include <boost/type_traits/is_same.hpp>
#include "everything_else.hpp"
#include "id_list.hpp"
#include "time.hpp"
#include "template_helpers.hpp"
#include "pla_getbyname.hpp"
#include "property_composition.hpp"
#include "model.hpp"
#include "mempool.hpp"
using namespace std;
template<typename Prop, typename QuantClass = typename Prop::quant::class_t>
struct CoarseReplay;
// define base case with virtual op() to runtime dispatch call by property name
template<>
struct CoarseReplay<BaseCase, Void> {
virtual void operator() (Time start, Time stop, IdList<uint64_t> rawIds) {
assert(false);
}
};
template<typename Prop>
struct CoarseReplay<Prop, ContinuousPropertyClass> : CoarseReplay<BaseCase, Void> {
virtual void operator() (Time start, Time stop,
IdList<uint64_t> rawIds) {
IdList<typename Ptr<typename Prop::quant>::ptr_t> ids(rawIds);
PropertyInstance<Prop, true> pi;
assert(stop <= pi.data.timeLimit);
assert(start >= 0);
// print header
cout << "#";
for (auto i : ids) cout << "\tval(" << (uint64_t) i << ")";
for (auto i : ids) cout << "\ttime(" << (uint64_t) i << ")";
cout << endl;
// print data
for (Time t = start; t <= stop; t = t + pi.data.interval()) {
cout << t();
for (auto i : ids) cout << "\t" << pi.data.getValue(t, i);
for (auto i : ids) cout << "\t" << pi.data.getTime (t, i);
cout << endl;
}
}
};
template<typename Prop>
struct CoarseReplay<Prop, DiscretePropertyClass> : CoarseReplay<BaseCase, Void> {
virtual void operator() (Time start, Time stop, uint64_t raw_addr) {
cerr << Prop::name << " is a discrete property" << endl;
exit(-1);
}
};
int main(int argc, char **argv) {
// read cmd line params
assert(argc == 5);
assertSimDir();
{
PropertyComposition<Lists::all> pc;
PLA_GetByName<CoarseReplay> pla(argv[1]);
CoarseReplay<BaseCase, Void> *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);
assert(errno == 0);
// output
(*replay)(start, stop, ids);
}
return 0;
}
|