-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathlaunch.py
66 lines (61 loc) · 2.38 KB
/
launch.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
import sys
args = sys.argv
sockets = int(args[1])
numas = int(args[2])
numa_per_socket = int(numas / sockets)
cores_per_socket = int(args[3])
enable_2nd_process = int(args[4])
aot_inductor = int(args[5])
import os
os.environ["KMP_BLOCKTIME"] = "1"
os.environ["KMP_AFFINITY"] = "granularity=fine,compact,1,0"
os.environ["MALLOC_CONF"] = "oversize_threshold:1,background_thread:true,metadata_thp:auto"
assert "LD_PRELOAD" in os.environ.keys()
assert "iomp" in os.environ["LD_PRELOAD"]
assert "jemalloc" in os.environ["LD_PRELOAD"]
avgcore_per_numa = int(cores_per_socket // numa_per_socket)
coreidx_per_numa = list(range(0, cores_per_socket * sockets + 1, avgcore_per_numa))
for s in range(sockets):
current_n = s * numa_per_socket
print(coreidx_per_numa)
print((s + 1) * numa_per_socket)
while coreidx_per_numa[(s + 1) * numa_per_socket] != cores_per_socket * (s + 1):
for n in range(current_n + 1, numas + 1):
coreidx_per_numa[n] += 1
current_n += 1
if aot_inductor:
model_dir = str(args[5])
BS = int(os.environ["BATCH_SIZE"])
EVAL_BATCH = int(os.environ["EVAL_BATCH"])
from dlrm_main import aoti_benchmark_compile
composed_cmd = ""
for i in range(numas):
target_dir = f"./aoti-dir-{i}"
if os.path.exists(target_dir):
os.system(f"rm -r {target_dir}")
os.system(f"mkdir {target_dir}")
start = coreidx_per_numa[i]
end = coreidx_per_numa[i + 1] - 1
bench_bin = aoti_benchmark_compile(end-start+1, EVAL_BATCH, BS, model_dir, target_dir)
composed_cmd += f"taskset -c {start}-{end} {bench_bin} "
if i != (numas - 1):
composed_cmd += " & "
print(composed_cmd)
os.system(composed_cmd)
else:
cmd = str(args[6])
composed_cmd = ""
for i in range(numas):
start = coreidx_per_numa[i]
end = coreidx_per_numa[i + 1] - 1
if enable_2nd_process:
mid = (start + end) // 2
composed_cmd += f"taskset -c {start}-{mid} {cmd} --share-weight-instance={mid-start+1} "
composed_cmd += " & "
composed_cmd += f"taskset -c {mid + 1}-{end} {cmd} --share-weight-instance={end-mid} "
else:
composed_cmd += f"taskset -c {start}-{end} {cmd} --share-weight-instance={end-start+1} "
if i != (numas - 1):
composed_cmd += " & "
print(composed_cmd)
os.system(composed_cmd)