forked from onnx/onnx-mlir
-
Notifications
You must be signed in to change notification settings - Fork 2
/
multi-threading-test.py
41 lines (30 loc) · 977 Bytes
/
multi-threading-test.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
#!/usr/bin/env python3
# encoding=utf-8
# testing for multi-threading with onnx-mlir compilation
import datetime
import os
import threading
def execCmd(cmd):
try:
print("command " + cmd + " starts at " + str(datetime.datetime.now()))
os.system(cmd)
print("command " + cmd + " is finished at " + str(datetime.datetime.now()))
except:
print("command " + cmd + " meets errors")
if __name__ == "__main__":
# define 2 different commands
cmds = [
"onnx-mlir -O3 mnist.onnx -o mnist03",
"onnx-mlir -O1 mnist.onnx -o mnist01",
]
threads = []
print("program starts at " + str(datetime.datetime.now()))
# run the commands
for cmd in cmds:
th = threading.Thread(target=execCmd, args=(cmd,))
th.start()
threads.append(th)
# wait for all the commands finish
for th in threads:
th.join()
print("program is finished at " + str(datetime.datetime.now()))