====== Run PT Scripts ======
#! /tools/cfr/bin/python
import os
import re
import sys
import time
def is_starrc_done(starrc_dir):
if not os.path.isdir(starrc_dir):
return False
starrc_done = True
starrc_corners = 'cb cbht cw cwlt rcb rcw'.split(' ')
for corner in starrc_corners:
corner_path = os.path.join(starrc_dir, corner)
cpu_number = 0
# find cpu number for star-rc run
file_names = os.listdir(corner_path)
for file_name in file_names:
patt = """run-\d-(\d)\.log"""
cpu_number = re.findall(patt, file_name)
if cpu_number:
cpu_number = int(cpu_number[0])
break
# check starrc finished
for i in range(1, cpu_number+1):
done_file_name = os.path.join( corner_path, "starrc-%d-%d.done" % (i, cpu_number))
if not os.path.exists(done_file_name):
starrc_done = False
break
else:
print "Done: %s" % done_file_name
if not starrc_done:
break
return starrc_done
def wait_starrc(starrc_dir):
starrc_dir = "/home/ztzx2110002v0/users/dongu/FDH0_2/starrc"
sys.stdout.write("Waiting StarRC: %s ...\n" % starrc_dir )
count = 0
while 1:
if is_starrc_done( starrc_dir ):
break
else:
sys.stdout.write(".")
sys.stdout.flush()
count += 1
if count >= 30:
count = 0
sys.stdout.write("\r" + " "*30 + "\r")
time.sleep(1)
return True
if __name__ == "__main__1":
starrc_dir = "/home/ztzx2110002v0/users/dongu/FDH0_2/starrc"
wait_starrc ( starrc_dir )
modes = 'func mbist bisr scan merged'.split(' ')
corners = 'max maxlt min minht'.split(' ')
pt_file = 'pt_flow.tcl'
#pt_file = 'pt_flow_restore.tcl'
dir_pt_log = 'logs'
dir_scripts_src = 'scripts'
dir_scripts_gen = 'scripts_pt_mcmm'
for d in [dir_pt_log, dir_scripts_gen]:
if not os.path.isdir(d):
os.makedirs(d)
for mode in modes:
# func mode check rc corners
if mode == 'func': allcorners = corners + ['maxrc', 'minrc']
else: allcorners = corners
for corner in allcorners:
#print mode, corner
# generate pt sript file for all corners
script_content = ""
script_content += 'set mode %s\n' % mode
script_content += 'set corner %s\n\n' % corner
script_content += open(os.path.join(dir_scripts_src, pt_file)).read()
script_filename = os.path.join(dir_scripts_gen, "%s_%s.tcl" % (mode, corner))
open(script_filename, 'w').write(script_content)
cmd = """icsub -P gdh_pt -J gdhpt_%s_%s -q priority -R "rusage[mem=16000]" """ % (mode, corner)
cmd += """ -do "pt_shell -64 -f %s | tee %s/%s_%s.log" """ % (script_filename, dir_pt_log, mode, corner)
print cmd
os.system(cmd)
run simple pt
#! /bin/csh -f
mkdir logs
set log_date=`date '+%y_%m_%d_%H_%M_%S'`
icsub -P gdh -Ip -J gdh_pt -q priority -R "rusage[mem=8000]" -do "pt_shell -64 | tee logs/zrunpt-$log_date.log"