-
Notifications
You must be signed in to change notification settings - Fork 11
/
sparse_apps.py
99 lines (74 loc) · 2.46 KB
/
sparse_apps.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
import subprocess
import glob
import random
import os
app = "matmul_ijk_crddrop"
# test = "n4c6-b1"
test = "qiulp"
num_samples = 10
#data = ["cage3"]
#data = ["Trec4"]
#data = []
#data_file = open("../sam/scripts/tensor_names/suitesparse_valid_small50.txt")
#data_file_lines = data_file.readlines()
#for line in data_file_lines:
# data.append(line[:-1])
name_list = glob.glob(f"./SPARSE_TESTS/{app}_tile*")
# print(name_list)
lst = [int(tile.replace(f"./SPARSE_TESTS/{app}_tile", "")) for tile in name_list]
# print(lst)
largest_num = max(lst)
#take random sample
tiles_to_run = random.sample(range(0, largest_num),num_samples)
print("NUM TILES: ", largest_num)
name_list = []
# for i in range(largest_num+1):
# name_list.append(f"tile{i}")
for i in tiles_to_run:
name_list.append(f"tile{i}")
data = name_list
# print(data)
f = open(f"sparse_sweep_{app}_{test}_FIX.txt", "w")
for datum in data:
# print(app, datum)
subprocess.call(["aha",
"glb",
f"../../../garnet/SPARSE_TESTS/{app}_{datum}/GLB_DIR/{app}_combined_seed_{datum}",
"--sparse",
"--sparse-test-name",
f"{app}",
"--sparse-comparison",
f"/aha/garnet/SPARSE_TESTS/{app}_{datum}/GLB_DIR/{app}_combined_seed_{datum}/"],
text=True,
stdout=f)
path = f"/aha/garnet/tensor_X_matmul_tiled/{test}/{datum}"
if not os.path.exists(path):
os.makedirs(path)
command_clear = f"rm /aha/garnet/tensor_X_matmul_tiled/{test}/{datum}/*"
os.system(command_clear)
command = f"cp /aha/garnet/tests/test_app/tensor_X* /aha/garnet/tensor_X_matmul_tiled/{test}/{datum}"
print(command)
os.system(command)
f.close()
name_list = glob.glob(f"./SPARSE_TESTS/{app}_tile*")
print(name_list)
lst = [int(tile.replace(f"./SPARSE_TESTS/{app}_tile", "")) for tile in name_list]
print(lst)
largest_num = max(lst)
name_list = []
for i in range(largest_num+1):
name_list.append(f"tile{i}")
data = name_list
print(name_list)
f2 = open(f"sparse_sweep_{app}_{test}_FIX.txt", "r")
lines = f2.readlines()
total_time = 0
idx = 0
for line in lines:
if "total time" in line:
time = line.split()[3]
print(f"tile {idx}: ", data[idx], time)
total_time += float(time)
idx = idx + 1
print(f"total time for sample {app} {datum} is ", total_time)
print("the largest number is ", largest_num)