-
Notifications
You must be signed in to change notification settings - Fork 7
/
createPSTaskConfigs.py
138 lines (126 loc) · 3.84 KB
/
createPSTaskConfigs.py
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
import sys
from os import listdir
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import numpy as np
import pandas as pd
import csv
import os
import statistics
from operator import itemgetter
import json
workloads=["traffic", "game", "scen1", "scen2", "scen3", "scen4", "scen5"]
SLO=[]
model_ids=[]
def parse_args():
parser = ArgumentParser(description=__doc__,
formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('output_dir',
help='directory which will holds task configs ')
args = parser.parse_args()
return args
def setup(workload):
global SLO
global workloadl_ids
if workload == "traffic":
SLO=[(6,112),(8,90),(9,112)]
model_ids=[6,8,9]
elif workload == "game":
SLO=[(0,108),(1,108),(2,108),(3,108),(4,108),(5,108),(7,108)]
model_ids=[0,1,2,3,4,5,7]
else:
SLO=[(0,5),(6,66),(7,108),(8,202),(9, 142),(10,62),(11,64),(12,202),(13,22)]
model_ids=[0,6,7,8,9,10,11,12,13]
def generateCombinations(workload):
comb_list=[]
rates=range(10,3000,10)
if workload == "scen1":
for rate in rates:
item1=(0,rate*2)
item2=(6,rate*2)
item3=(7,rate*2)
item4=(8,rate)
item5=(9,rate)
comb_list.append([item1,item2,item3,item4,item5])
elif workload == "scen2":
for rate in rates:
item3=(7,rate)
item4=(8,rate)
item5=(9,rate)
comb_list.append([item3,item4,item5])
elif workload == "game":
for rate in rates:
item1=(0,rate)
item2=(1,rate)
item3=(2,rate)
item4=(3,rate)
item5=(4,rate)
item6=(5,rate)
item7=(7,rate)
comb_list.append([item1,item2,item3,item4,item5,item6,item7])
elif workload == "traffic":
for rate in rates:
item1=(6,rate)
item2=(8,rate)
item3=(9,rate)
comb_list.append([item1,item2,item3])
elif workload == "scen3":
for rate in rates:
item1=(7,rate)
item2=(9,rate)
item3=(11,rate)
comb_list.append([item1,item2,item3])
elif workload == "scen4":
for rate in rates:
item1=(8,rate)
item2=(10,rate)
item3=(12,rate)
comb_list.append([item1,item2,item3])
elif workload == "scen5":
for rate in rates:
item1=(0,rate)
item2=(8,rate)
item3=(9,rate)
item4=(10,rate)
comb_list.append([item1,item2,item3,item4])
else:
print("unrecognized workload: "+workload)
exit(1)
return comb_list
def getSLO(id):
slo=0
for item in SLO:
if id in item:
slo=item[1]
return slo
def writeContent(comb, fp, idx):
num_of_models =0
for item in comb:
if item[1] != 0:
num_of_models = num_of_models +1
if num_of_models == 0:
return
fp.write(str(num_of_models)+"\n")
for item in comb:
if(item[1] == 0):
continue
slo=getSLO(item[0])
fp.write(str(item[0])+","+str(item[1])+","+str(slo)+",")
fp.write("\n")
def generateLists(list_dir, possible_combinations, workload):
save_path=list_dir
idx=0
for idx in range(0,len(possible_combinations)):
filename=workload+"-"+str(idx+1)+"-config.csv"
complete_path=os.path.join(save_path,filename)
fp=open(complete_path,"w")
writeContent(possible_combinations[idx],fp, idx)
fp.close()
def main():
args=parse_args()
for workload in workloads:
setup(workload)
combs=generateCombinations(workload)
generateLists(args.output_dir, combs, workload)
print("Finished writing all combinations")
if __name__=='__main__':
main()