diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2021-10-20 22:47:03 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2021-10-20 22:47:03 -0400 |
| commit | b6341ec8d9c3ed21e4092fe229df656094edcd53 (patch) | |
| tree | 5b0ea3696e7e3627b191a2e110c1e74ff80863ee | |
| parent | 2b4bf574a66c034d30e3cc84cf8cf6d588f036db (diff) | |
10.20 tmp
| -rw-r--r-- | extra.h | 2 | ||||
| -rwxr-xr-x | run_case_study_dag.py | 281 |
2 files changed, 282 insertions, 1 deletions
| @@ -30,7 +30,7 @@ extern int sched_getcpu(); | |||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | // This is a proxy for "case study mode" now | 32 | // This is a proxy for "case study mode" now |
| 33 | #define LITMUS 1 | 33 | #define LITMUS 0 |
| 34 | #define MMDC_PROF 0 | 34 | #define MMDC_PROF 0 |
| 35 | 35 | ||
| 36 | #if LITMUS | 36 | #if LITMUS |
diff --git a/run_case_study_dag.py b/run_case_study_dag.py new file mode 100755 index 0000000..0b2f61c --- /dev/null +++ b/run_case_study_dag.py | |||
| @@ -0,0 +1,281 @@ | |||
| 1 | #!/usr/bin/python3 | ||
| 2 | # Make sure to run this as root!!!!! | ||
| 3 | import os | ||
| 4 | import sys | ||
| 5 | import re | ||
| 6 | import csv | ||
| 7 | import time | ||
| 8 | import subprocess | ||
| 9 | |||
| 10 | A_SUITE = 1 | ||
| 11 | A_BIN = 2 | ||
| 12 | A_CRIT = 3 | ||
| 13 | A_PERIOD = 5 | ||
| 14 | |||
| 15 | P_CORE = 0 | ||
| 16 | P_CRIT = 1 | ||
| 17 | P_T1_ID = 2 | ||
| 18 | P_T2_ID = 5 | ||
| 19 | |||
| 20 | T_ID = 0 | ||
| 21 | T_BIN = 1 | ||
| 22 | T_PERIOD = 2 | ||
| 23 | T_CCX = 3 | ||
| 24 | |||
| 25 | CRIT_LEVEL_C = 2 | ||
| 26 | |||
| 27 | all_pids=[] | ||
| 28 | def run(command): | ||
| 29 | print(command) | ||
| 30 | os.system(command) | ||
| 31 | |||
| 32 | def addpid(pid): | ||
| 33 | with open("./pids.txt", "a") as f: | ||
| 34 | f.write(str(pid) + "\n") | ||
| 35 | def ID2PID(lookupID): | ||
| 36 | res = None | ||
| 37 | # Find benchmark PID (avoid getting shell or numactl PID) | ||
| 38 | try: | ||
| 39 | res = subprocess.check_output("pgrep -af ' " + lookupID + " ' | grep -v numactl", shell=True) | ||
| 40 | except: | ||
| 41 | res = None | ||
| 42 | if res: | ||
| 43 | # Ignore the newline | ||
| 44 | return res.decode("utf-8").split(" ")[0].strip() | ||
| 45 | else: | ||
| 46 | return None | ||
| 47 | |||
| 48 | def main(pathName): | ||
| 49 | with open("./pids.txt", "w") as f: | ||
| 50 | f.write("") | ||
| 51 | |||
| 52 | tacle_pairs_path = "./all_pairs" | ||
| 53 | tacle_baseline_path = "./baseline" | ||
| 54 | dis_path = "./dis" | ||
| 55 | # List of lists | ||
| 56 | # 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)] | ||
| 58 | all_tasks = [] | ||
| 59 | # List of lists | ||
| 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 = {} | ||
| 67 | # Load input command for each binary | ||
| 68 | with open("baseline/tacleNames.txt") as f: | ||
| 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: | ||
| 73 | for line in f: | ||
| 74 | name, cmd = line.split(maxsplit=1) | ||
| 75 | input_cmd[name.replace("./", "")] = cmd.replace("./", "./SD-VBS/").strip() | ||
| 76 | with open("dis/dis2MbInNames.txt") as f: | ||
| 77 | for line in f: | ||
| 78 | name, cmd = line.split(maxsplit=1) | ||
| 79 | input_cmd[name.replace("./", "")] = cmd.replace("./", "./dis/").strip() | ||
| 80 | |||
| 81 | # Load task specifications | ||
| 82 | with open(pathName+"/all_tasks.csv", "r") as csv_file: | ||
| 83 | csv_reader = csv.reader(csv_file, delimiter = ',') | ||
| 84 | line = 0 | ||
| 85 | for row in csv_reader: | ||
| 86 | if line > 0: | ||
| 87 | all_tasks.append(row) | ||
| 88 | line += 1 | ||
| 89 | with open(pathName+"/levelAB_pairs.csv", "r") as csv_file: | ||
| 90 | csv_reader = csv.reader(csv_file, delimiter = ',') | ||
| 91 | line = 0 | ||
| 92 | for row in csv_reader: | ||
| 93 | if line > 0: | ||
| 94 | levelAB.append(row) | ||
| 95 | line += 1 | ||
| 96 | with open(pathName+"/levelC_threads.csv", "r") as csv_file: | ||
| 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 ### | ||
| 122 | run('mount -t resctrl resctrl /sys/fs/resctrl') | ||
| 123 | # 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: | ||
| 125 | csv_reader = csv.reader(csv_file, delimiter = ',') | ||
| 126 | line = 0 | ||
| 127 | ccx = 0 | ||
| 128 | for row in csv_reader: | ||
| 129 | if line > 0: | ||
| 130 | core = int(row[0]) | ||
| 131 | way_AB = int(row[1]) | ||
| 132 | way_C = int(row[3]) | ||
| 133 | # Level C allocation | ||
| 134 | if(core == 1): | ||
| 135 | run("mkdir -p /sys/fs/resctrl/level-c-ccx-0") | ||
| 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') | ||
| 137 | |||
| 138 | if(core == 4): | ||
| 139 | run("mkdir -p /sys/fs/resctrl/level-c-ccx-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/*") | ||
| 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 | ||
| 175 | else: | ||
| 176 | print("Invalid suite name " + suite1 + " in Level-A/-B tasks! Exiting...") | ||
| 177 | return 1 | ||
| 178 | |||
| 179 | lookupID = name1 + str(task1) | ||
| 180 | if ID2PID(lookupID): | ||
| 181 | print("ERROR: Task ID {} is already running! Did you end the previous case study?".format(lookupID)) | ||
| 182 | return 1 | ||
| 183 | # Arg format: <unique name> <infinite loops> <core> <NULL runID> <no output> <period> <crit lvl> | ||
| 184 | arg = " " + lookupID + " -1 " + core + " NULL 0 " + period1 + " " + criticality | ||
| 185 | bench_tsk = subprocess.Popen(input_cmd[name1] + " | numactl --interleave=all " + binary + arg, shell=True, executable='/bin/bash') | ||
| 186 | pid_str = ID2PID(lookupID) | ||
| 187 | if not pid_str: | ||
| 188 | print("Unable to launch {} as a solo task! Exiting...".format(name1)) | ||
| 189 | return 1 | ||
| 190 | # Add this task to the appropriate cache partition (Class of Service in Intel CAT terms) | ||
| 191 | run("echo " + pid_str + " > /sys/fs/resctrl/level-ab-core-" + core + "/tasks") | ||
| 192 | addpid(pid_str) | ||
| 193 | else: | ||
