summaryrefslogtreecommitdiffstats
path: root/run_case_study_dag.py
diff options
context:
space:
mode:
Diffstat (limited to 'run_case_study_dag.py')
-rwxr-xr-xrun_case_study_dag.py319
1 files changed, 114 insertions, 205 deletions
diff --git a/run_case_study_dag.py b/run_case_study_dag.py
index 0b2f61c..f098e9e 100755
--- a/run_case_study_dag.py
+++ b/run_case_study_dag.py
@@ -1,4 +1,4 @@
1#!/usr/bin/python3 1#/usr/bin/python3
2# Make sure to run this as root!!!!! 2# Make sure to run this as root!!!!!
3import os 3import os
4import sys 4import sys
@@ -7,22 +7,30 @@ import csv
7import time 7import time
8import subprocess 8import subprocess
9 9
10A_SUITE = 1
11A_BIN = 2
12A_CRIT = 3
13A_PERIOD = 5
14 10
15P_CORE = 0 11# Single tasks:
16P_CRIT = 1 12# 0, binary_name, task_name, iterations, my_core, runID, save?, period, criticality, phase
17P_T1_ID = 2 13# Paired tasks:
18P_T2_ID = 5 14# 1, binary_name, task_name, iterations, my_core, runID, save?, period, criticality, phase, other_binary_name, other_task_name
19 15
20T_ID = 0
21T_BIN = 1
22T_PERIOD = 2
23T_CCX = 3
24 16
25CRIT_LEVEL_C = 2 17binary_path = "./SD-VBS/dag_binaries/"
18stderr_file = open("./deadline_misses", 'w+')
19
20BINARY_NAME = 1
21TASK_NAME = 2
22NUM_ITERS = 3
23CORE_NUM = 4
24RUN_ID = 5
25SAVE_RESULT = 6
26PERIOD = 7
27CRT_LEVEL = 8
28PHASE= 9
29
30OTHER_BINARY_NAME = 10
31OTHER_TASK_NAME = 11
32# OTHER_CORE_NUM = 12
33# PAIR_ID = 12
26 34
27all_pids=[] 35all_pids=[]
28def run(command): 36def run(command):
@@ -56,215 +64,116 @@ def main(pathName):
56 # Each list represents the parameters for a task as: 64 # Each list represents the parameters for a task as:
57 # [id, suite, binary name, criticality level (0-base), pet us (unused), period ms, wss (unused)] 65 # [id, suite, binary name, criticality level (0-base), pet us (unused), period ms, wss (unused)]
58 all_tasks = [] 66 all_tasks = []
59 # List of lists 67
60 # Each list represents the parameters for a pairing as:
61 # [core, criticality level (0-base), task 1 ID, task 1 name (unused), task 1 period, task 2 ID, task 2 name, task 2 period]
62 # if task 1 ID = task 2 ID, it's not actually a pair at all
63 levelAB = []
64 levelC = []
65 levelC_s = []
66 input_cmd = {} 68 input_cmd = {}
67 # Load input command for each binary 69 # Load input command for each binary
68 with open("baseline/tacleNames.txt") as f: 70
69 for benchName in f:
70 # TACLeBench doesn't need inputs
71 input_cmd[benchName.strip()] = "echo ' '"
72 with open("SD-VBS/sd-vbsNames.txt") as f: 71 with open("SD-VBS/sd-vbsNames.txt") as f:
73 for line in f: 72 for line in f:
74 name, cmd = line.split(maxsplit=1) 73 name, cmd = line.split(maxsplit=1)
75 input_cmd[name.replace("./", "")] = cmd.replace("./", "./SD-VBS/").strip() 74 input_cmd[name.replace("./", "")] = cmd.replace("./", "./SD-VBS/").strip()
76 with open("dis/dis2MbInNames.txt") as f: 75 # for k in input_cmd:
77 for line in f: 76 # print(k, input_cmd[k])
78 name, cmd = line.split(maxsplit=1) 77 # return 1
79 input_cmd[name.replace("./", "")] = cmd.replace("./", "./dis/").strip()
80 78
79 task_launches = []
80 max_core = 0
81 # Load task specifications 81 # Load task specifications
82 with open(pathName+"/all_tasks.csv", "r") as csv_file: 82 with open(pathName, "r") as file:
83 csv_reader = csv.reader(csv_file, delimiter = ',') 83 for line in file:
84 line = 0 84 parameters = line.split(",")
85 for row in csv_reader: 85 task_launches.append(parameters)
86 if line > 0: 86 core_num = int(parameters[CORE_NUM]) % 16
87 all_tasks.append(row) 87 if max_core < core_num:
88 line += 1 88 max_core = core_num
89 with open(pathName+"/levelAB_pairs.csv", "r") as csv_file: 89 # if parameters[0] == '1':
90 csv_reader = csv.reader(csv_file, delimiter = ',') 90 # other_core_num = int(parameters[OTHER_CORE_NUM]) % 16
91 line = 0 91 # if other_core_num > max_core:
92 for row in csv_reader: 92 # max_core = other_core_num
93 if line > 0: 93
94 levelAB.append(row) 94 core_count = max_core+1
95 line += 1 95 # print(parameters)
96 with open(pathName+"/levelC_threads.csv", "r") as csv_file: 96
97 csv_reader = csv.reader(csv_file, delimiter = ',')
98 line = 0
99 ccx = "0"
100 threaded = True
101 for row in csv_reader:
102 if(len(row) < 3):
103 continue
104 # Start of a cluster - read definition
105 if(row[0] == "threaded" or row[0] == "solo"):
106 threaded = row[0] == "threaded"
107 if(row[1] == "4"):
108 ccx = "1"
109 else:
110 ccx = "0"
111 continue
112 # Start of a thread speficication
113 if(row[0] != "task id" and row[0] != ""):
114 row.append(ccx)
115 if(threaded):
116 row.append("t")
117 else:
118 row.append("s")
119 levelC.append(row)
120 line += 1
121 ### Allocate Cache Ways ### 97 ### Allocate Cache Ways ###
122 run('mount -t resctrl resctrl /sys/fs/resctrl') 98 run('mount -t resctrl resctrl /sys/fs/resctrl')
123# run('echo "L3:0=0000,1=0000,2=0000,3=0000" > /sys/fs/resctrl/schemata') 99# run('echo "L3:0=0000,1=0000,2=0000,3=0000" > /sys/fs/resctrl/schemata')
124 with open(pathName+"/l3alloc.csv", "r") as csv_file: 100 # for core in range(16):
125 csv_reader = csv.reader(csv_file, delimiter = ',') 101 # run("mkdir -p /sys/fs/resctrl/core-{}".format(core))
126 line = 0 102 # ccx = core // 4
127 ccx = 0 103 # in_ccx = core % 4
128 for row in csv_reader: 104 # mask = "0000"
129 if line > 0: 105 # mask = mask[:in_ccx] +'f'+ mask[in_ccx+1:]
130 core = int(row[0]) 106 # if ccx == 0:
131 way_AB = int(row[1]) 107 # run('echo "L3:0=' + mask + ';1=0000;2=0000;3=0000" > /sys/fs/resctrl/core-{}/schemata'.format(core))
132 way_C = int(row[3]) 108 # if ccx == 1:
133 # Level C allocation 109 # run('echo "L3:0=0000;1=' + mask + ';2=0000;3=0000" > /sys/fs/resctrl/core-{}/schemata'.format(core))
134 if(core == 1): 110 # if ccx == 2:
135 run("mkdir -p /sys/fs/resctrl/level-c-ccx-0") 111 # run('echo "L3:0=0000;1=0000;2='+ mask +';3=0000" > /sys/fs/resctrl/core-{}/schemata'.format(core))
136 run('echo "L3:0=' + ("%0.4x" % (int("1"*way_C, 2))) + ';1=0000;2=0000;3=0000" > /sys/fs/resctrl/level-c-ccx-0/schemata') 112 # if ccx == 3:
137 113 # run('echo "L3:0=0000;1=0000;2=0000;3=' + mask + '" > /sys/fs/resctrl/core-{}/schemata'.format(core))
138 if(core == 4): 114
139 run("mkdir -p /sys/fs/resctrl/level-c-ccx-1") 115 # return 1
140 run('echo "L3:0=0000;1=' + ("%0.4x" % (int("1"*way_C, 2))) + ';2=0000;3=0000" > /sys/fs/resctrl/level-c-ccx-1/schemata')
141 run('mkdir -p /sys/fs/resctrl/level-ab-core-' + str(core))
142 if(core < 4):
143 run('echo "L3:0=' + ("%0.4x" % (int("1"*way_AB + "0"*(16-way_AB), 2))) + ';1=0000;2=0000;3=0000" > /sys/fs/resctrl/level-ab-core-' + str(core) + '/schemata')
144 else:
145 run('echo "L3:0=0000;1=' + ("%0.4x" % (int("1"*way_AB + "0"*(16-way_AB), 2))) + ';2=0000;3=0000" > /sys/fs/resctrl/level-ab-core-' + str(core) + '/schemata')
146 line += 1
147 ### Cleanup Old State ###
148 run("rm -rf /dev/shm/*") 116 run("rm -rf /dev/shm/*")
149 pairID = 0
150 ### Dispatch all the Level-A and -B paired and unpaired tasks ###
151 for pairing in levelAB:
152 task1 = int(pairing[P_T1_ID])
153 task2 = int(pairing[P_T2_ID])
154 # Lookup periods and binary location
155 name1 = all_tasks[task1][A_BIN]
156 name2 = all_tasks[task2][A_BIN]
157 period1 = all_tasks[task1][A_PERIOD]
158 period2 = all_tasks[task2][A_PERIOD]
159 suite1 = all_tasks[task1][A_SUITE]
160 suite2 = all_tasks[task2][A_SUITE]
161 core = pairing[P_CORE]
162 criticality = pairing[P_CRIT]
163 binary = ""
164 binary1 = ""
165 binary2 = ""
166 arg = ""
167 # If the IDs match, this isn't a pair at all
168 if task1 == task2:
169 if suite1 == "TACLe":
170 binary = "./baseline/bin/" + name1
171 elif suite1 == "SD-VBS":
172 binary = "./SD-VBS/" + name1 + "_qcif"
173 elif suite1 == "DIS":
174 binary = "./dis/" + name1