forked from The-OpenROAD-Project/RePlAce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute_bookshelf.py
executable file
·137 lines (109 loc) · 4.07 KB
/
execute_bookshelf.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/python
#################################################################
# This script is written by Mingyu Woo. (16/12/17)
# http://mgwoo.github.io
#################################################################
import os
import sys
import subprocess as sp
from datetime import datetime
#####################################
# configure
bmflag = "etc"
dpflag = "NTU3"
dploc = "../ntuplace/ntuplace3"
dirpos = "../bench/bookshelf"
binaryName = "./RePlAce"
outpos = "../output"
logpos = "../logdir"
numThread = 1
isOnlyGP = False
isValgrind = False
isNohup = False
isCentos = False
useScreen = False
isPlot = False
## configure done
#####################################
def ExecuteCommand( command ):
print( command )
sp.call( command, shell=True )
def GetAuxFileName( benchFolderPos ):
lis = os.listdir( benchFolderPos )
for curFile in lis:
if curFile.find(".aux") != -1:
return curFile
return None
dirList = os.listdir(dirpos)
try:
dirList.remove('download_dac2012.sh')
except ValueError:
pass
if len(sys.argv) <=1:
print("usage: ./execute.py <benchname or number>")
print("Example: ")
print(" ./execute.py 0" )
print(" ./execute.py superblue19")
print("")
print("Dir List: ")
for idx, cdir in enumerate(sorted(dirList)):
print("%d %s" % (idx, cdir))
sys.exit(1)
benchNum = -1
benchName = ""
if sys.argv[1].isdigit():
benchNum = int(sys.argv[1])
benchName = sorted(dirList)[benchNum]
elif sys.argv[1] == "all":
benchName = sorted(dirList)
else:
benchName = sys.argv[1]
curTime = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
placeModeStr = "-onlyGP" if isOnlyGP else "-dpflag %s -dploc %s" % (dpflag, dploc)
directStr = ">" if isNohup else "|& tee" if isCentos else "| tee"
plotStr = "-plot" if isPlot else ""
valgrindStr = "valgrind --log-fd=1" if isValgrind else ""
nohupFrontStr = "nohup" if isNohup else ""
nohupEndStr = "&" if isNohup else ""
addStr = ""
for i in range(2, len(sys.argv)):
addStr += sys.argv[i] + " "
exeFormat = "screen -S %s -X stuff \"%s %s %s -bmflag %s -aux %s/%s/%s -output %s -t %d %s " \
+ addStr + " %s %s %s/%s_%s.log %s\n\"" if useScreen \
else "%s %s %s -bmflag %s -aux %s/%s/%s -output %s -t %d %s " + addStr + " %s %s %s/%s_%s.log %s"
if type(benchName) is list:
for curBench in benchName:
if "__" in curBench:
continue
print( curBench )
fileName = curBench + "_valgrind" if isValgrind else curBench
AuxName = GetAuxFileName( "%s/%s" % (dirpos, curBench) )
if useScreen:
ExecuteCommand( "screen -dmS %s bash" % (curBench) )
ExecuteCommand( exeFormat % (curBench, nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
dirpos, curBench, AuxName, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName, curTime, nohupEndStr ) )
else:
ExecuteCommand( exeFormat % (nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
dirpos, curBench, AuxName, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName, curTime, nohupEndStr ) )
else:
fileName = benchName + "_valgrind" if isValgrind else benchName
AuxName = GetAuxFileName( "%s/%s" % (dirpos, benchName) )
if useScreen:
ExecuteCommand( "screen -dmS %s bash" % (benchName) )
ExecuteCommand( exeFormat % (benchName, nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
dirpos, benchName, AuxName, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName , curTime, nohupEndStr ) )
else:
ExecuteCommand( exeFormat % (nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
dirpos, benchName, AuxName, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName , curTime, nohupEndStr ) )