-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschedtst_p1.cpp
220 lines (162 loc) · 8.39 KB
/
schedtst_p1.cpp
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include <iostream>
#include <string>
#include <fstream>
#include "custom_types/ts.h"
#include "p1_key/test_2d_task.h"
#include "p1_key/test_3d_task.h"
#include "p1_key/test_4th_task.h"
#include "p1_key/test_5th_task.h"
#include "p1_key/test_6th_task.h"
#include "p1_key/test_7th_task.h"
#include "p1_key/test_8th_task.h"
/*#include "p1_key/test_9th_task.h"
#include "p1_key/test_10th_task.h"
#include "p1_key/test_11th_task.h"
#include "p1_key/test_12th_task.h"
#include "p1_key/test_13th_task.h"
#include "p1_key/test_14th_task.h"*/
#include <cinttypes>
using namespace std;
ofstream fileResults;
int main(int argc, char* argv[]) {
TS tsOriginal, ts;
unsigned short m;
cerr << "Number of processors?" << endl;
cin >> m;
unsigned short n;
cerr << "Number of tasks?" << endl;
cin >> n;
bool implicitDeadlines = false;
cerr << "Tasks have implicit deadlines? (1 - yes, 0 - no)" << endl;
cin >> implicitDeadlines;
tsOriginal.n = n;
unsigned short C, D, P;
for (unsigned short i = 0; i < n; i++) {
cerr << "C[" << i << "]?" << endl;
cin >> C;
if (!implicitDeadlines) {
cerr << "D[" << i << "]?" << endl;
cin >> D;
}
cerr << "P[" << i << "]?" << endl;
cin >> P;
if (!implicitDeadlines) tsOriginal.setTask(i, C, D, P);
else tsOriginal.setTask(i, C, P, P);
}
bool removeDominatedStatesFromMap = 0; // default setting
cerr << "Dynamically optimize memory usage? (to remove states from memory at runtime):" << endl;
cerr << "0 - no (recommended)" << endl;
cerr << "1 - yes (might increase execution time)" << endl;
cin >> removeDominatedStatesFromMap;
bool verbose = 0;
cerr << "Verbose? (0 - no, 1 -yes)" << endl;
cin >> verbose;
for (int i = 0; i < m; i++) ts.setTask(i, tsOriginal.C[i], tsOriginal.D[i], tsOriginal.P[i]);
unsigned long int savedStatesNum = 0;
unsigned long int visitedStatesNum = 0;
unsigned long int savedStatesNumIncr = 0;
unsigned long int visitedStatesNumIncr = 0;
bool sched = true;
unsigned long int t0;
unsigned long int tExecution_p1;
unsigned long int tExecutionTotal_p1 = 0;
for (uint8_t N = m + 1; N <= tsOriginal.n; N++) {
ts.n = N;
ts.setTask(N-1, tsOriginal.C[N-1], tsOriginal.D[N-1], tsOriginal.P[N-1]);
if (verbose) {
cout << endl << "===================" << endl;
cout << "Checking task " << (int)ts.n << endl;
}
switch (N) {
case 2:
t0 = clock();
sched = test_2d_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 3:
t0 = clock();
sched = test_3d_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 4:
t0 = clock();
sched = test_4th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 5:
t0 = clock();
sched = test_5th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 6:
t0 = clock();
sched = test_6th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 7:
t0 = clock();
sched = test_7th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 8:
t0 = clock();
sched = test_8th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
/*case 9:
t0 = clock();
sched = test_9th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 10:
t0 = clock();
sched = test_10th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 11:
t0 = clock();
sched = test_11th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 12:
t0 = clock();
sched = test_12th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 13:
t0 = clock();
sched = test_13th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;
case 14:
t0 = clock();
sched = test_14th_task(verbose, m, ts, removeDominatedStatesFromMap, savedStatesNumIncr, visitedStatesNumIncr);
tExecution_p1 = clock() - t0; tExecutionTotal_p1 += tExecution_p1;
savedStatesNum += savedStatesNumIncr; visitedStatesNum += visitedStatesNumIncr;
break;*/
default: cout << "No function defined to test " << N << " tasks!" << endl;
}
if (!sched) break;
}
const char* fileName = (argv[2*(tsOriginal.n)+5]);
fileResults.open(fileName, ios::app);
fileResults << "\t" << sched << "\t" << tExecutionTotal_p1 << "\t" << savedStatesNum;
fileResults.close();
if (!removeDominatedStatesFromMap) cout << "Sporadic burm2018 p1 (no r.):\t" << (float)(tExecutionTotal_p1*100/CLOCKS_PER_SEC)/100 << " sec, \t / " << savedStatesNum << " saved states" << " \t / " << visitedStatesNum << " visited states";
else cout << "Sporadic burm2018 p1:\t\t" << (float)(tExecutionTotal_p1*100/CLOCKS_PER_SEC)/100 << " sec, \t / " << savedStatesNum << " saved states" << " \t / " << visitedStatesNum << " visited states";
if (sched) cout << " \t / SCHED" << endl;
else cout << " \t / UNSCHED" << endl;
return sched;
}