forked from The-OpenROAD-Project/RePlAce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute_lefdef.py
executable file
·156 lines (122 loc) · 4.74 KB
/
execute_lefdef.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/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
import time
#####################################
# configure
bmflag = "etc"
dpflag = "NTU3"
dploc = "../ntuplace/ntuplace3"
dirpos = "../bench_lefdef"
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 GetFileName( pos, extension ):
lis = os.listdir( pos )
for curFile in lis:
if curFile.endswith("." + extension):
return curFile
return None
def GetFileStr( pos, folder, ext, modeStr ):
retStr = GetFileName("%s/%s"%(pos, folder), ext)
if retStr != None :
return "%s %s/%s/%s " % (modeStr, pos, folder, retStr)
else:
return ""
dirList = os.listdir(dirpos)
try:
dirList.remove('download_ispd18.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] + " "
origFormat = "%s %s %s -bmflag %s FILESTR -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
lefStr = GetFileStr( dirpos, curBench, 'lef', '-lef')
defStr = GetFileStr( dirpos, curBench, 'def', '-def')
verilogStr = GetFileStr( dirpos, curBench, 'v', '-verilog')
exeFormat = origFormat.replace( "FILESTR", lefStr + defStr + verilogStr )
exeFormat = "screen -S %s -X stuff \"" + exeFormat + "\n\"" if useScreen else exeFormat
nameList = (nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
outpos, numThread, placeModeStr,\
directStr, logpos, fileName, curTime, nohupEndStr)
if useScreen:
ExecuteCommand( "screen -dmS %s bash" % (curBench) )
ExecuteCommand( exeFormat % (curBench, nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName, curTime, nohupEndStr ) )
else:
ExecuteCommand( exeFormat % (nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName, curTime, nohupEndStr ) )
else:
fileName = benchName + "_valgrind" if isValgrind else benchName
lefStr = GetFileStr( dirpos, benchName, 'lef', '-lef')
defStr = GetFileStr( dirpos, benchName, 'def', '-def')
verilogStr = GetFileStr( dirpos, benchName, 'v', '-verilog')
exeFormat = origFormat.replace( "FILESTR", lefStr + defStr + verilogStr )
exeFormat = "screen -S %s -X stuff \"" + exeFormat + "\n\"" if useScreen else exeFormat
if useScreen:
ExecuteCommand( "screen -dmS %s bash" % (benchName) )
ExecuteCommand( exeFormat % (benchName, nohupFrontStr, valgrindStr,\
binaryName, bmflag, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName , curTime, nohupEndStr ) )
else:
ExecuteCommand( exeFormat % (nohupFrontStr, valgrindStr, \
binaryName, bmflag, \
outpos, numThread, placeModeStr, plotStr, \
directStr, logpos, fileName , curTime, nohupEndStr ) )