-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconf_gasgen.c
110 lines (101 loc) · 2.75 KB
/
conf_gasgen.c
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
#include "gastask.h"
extern unsigned wcet_min, wcet_max, mem_total;
extern double util_cpu, util_target;
extern unsigned n_tasks_target;
extern unsigned task_size_min, task_size_max;
extern unsigned input_size_min, input_size_max;
extern unsigned output_size_min, output_size_max;
extern unsigned n_networks_target;
extern unsigned uplink_min, uplink_max, downlink_min, downlink_max;
extern unsigned n_net_commander_target;
extern unsigned intercept_out_min, intercept_out_max, intercept_in_min, intercept_in_max;
static void
parse_gentask(FILE *fp)
{
char buf[1024];
while (fgets(buf, 1024, fp)) {
if (buf[0] == '#')
continue;
if (buf[0] == '\n' || buf[0] == '*') {
fseek(fp, -1 * strlen(buf), SEEK_CUR);
return;
}
if (sscanf(buf, "%u %u %u %lf %lf %u %u %u %u %u %u %u", &wcet_min, &wcet_max, &mem_total,
&util_cpu, &util_target, &n_tasks_target, &task_size_min, &task_size_max,
&input_size_min, &input_size_max, &output_size_min, &output_size_max) != 12) {
FATAL(2, "cannot load configuration: invalid gentask parameters: %s", trim(buf));
}
if (util_cpu > util_target) {
FATAL(2, "target utilization cannot be smaller than full utilzation");
}
}
}
static void
parse_gennetwork(FILE *fp)
{
char buf[1024];
while (fgets(buf, 1024, fp)) {
if (buf[0] == '#')
continue;
if (buf[0] == '\n' || buf[0] == '*') {
fseek(fp, -1 * strlen(buf), SEEK_CUR);
return;
}
if (sscanf(buf, "%u %u %u %u %u", &uplink_min, &uplink_max,
&downlink_min, &downlink_max, &n_networks_target) != 5) {
FATAL(2, "cannot load configuration: invalid gennetwork parameters: %s", trim(buf));
}
}
}
static void
parse_gennetcommander(FILE *fp)
{
char buf[1024];
while (fgets(buf, 1024, fp)) {
if (buf[0] == '#')
continue;
if (buf[0] == '\n' || buf[0] == '*') {
fseek(fp, -1 * strlen(buf), SEEK_CUR);
return;
}
if (sscanf(buf, "%u %u %u %u %u", &intercept_out_min, &intercept_out_max,
&intercept_in_min, &intercept_in_max, &n_net_commander_target) != 5) {
FATAL(2, "cannot load configuration: invalid gencommander parameters: %s", trim(buf));
}
}
}
void
parse_conf(FILE *fp)
{
char buf[1024];
while (fgets(buf, 1024, fp)) {
if (buf[0] == '\n' || buf[0] == '#')
continue;
switch (check_section(buf)) {
case SECT_GENETIC:
case SECT_CPUFREQ:
case SECT_TASK:
case SECT_OFFLOADINGRATIO:
case SECT_CLOUD:
case SECT_NETWORK:
case SECT_NET_COMMANDER:
skip_section(fp);
break;
case SECT_MEM:
parse_mem(fp);
break;
case SECT_GENTASK:
parse_gentask(fp);
break;
case SECT_GENNETWORK:
parse_gennetwork(fp);
break;
case SECT_GENNETCOMMANDER:
parse_gennetcommander(fp);
break;
default:
errmsg("unknown section: %s", trim(buf));
FATAL(2, "cannot load configuration");
}
}
}