24 import shlex, subprocess
30 sys.path.append(
"@PERFTEST_SCRIPTS_SRC_DIR@/misc_modules/")
33 summarize_results=
True 34 except ImportError, e:
35 print "WARNING: I wont summarize results because I could not import modules: ", e
36 summarize_results=
False 39 builddir=
"@PERFTEST_BASE_DIR@" 40 datadir=
"@PERFTEST_SMALL_DATA_DIR@" 43 sys.stderr.write(
'ERROR (test.py): '+message+
'\n')
47 assfn=(
"ass",
"-ass_rdt",
"ass.rdt",
"Assemble: dohrstruct->Assemble(...). Assemble element matrices and decompose matrices.")
48 crefn=(
"cre",
"-cre_rdt",
"cre.rdt",
"Create: dohrstruct->Create()")
49 solfn=(
"sol",
"-sol_rdt",
"sol.rdt",
"Solver: cg.Solve(...)")
50 totfn=(
"tot",
"-tot_rdt",
"tot.rdt",
"Total: all the steps")
51 tpzdohrassfn=(
"dohrass",
"-tpz_dohr_ass",
"tpzdohrass.rdt",
"Assemble element matrices")
52 tpzdohrdecfn=(
"dohrdec",
"-tpz_dohr_dec",
"tpzdohrdec.rdt",
"Decompose matrices")
55 rdtfiles_l=[assfn, crefn, solfn, totfn, tpzdohrassfn, tpzdohrdecfn]
60 if not os.path.isdir(builddir) :
61 error(builddir+
' is an invalid build directory.', 1)
63 rundir = os.path.join(builddir,
'scripts',
'substruct_tst16')
64 if not os.path.isdir(rundir) :
65 error(rundir+
' is an invalid run directory.', 1)
66 if not os.path.isdir(builddir) :
67 error(builddir+
' is an invalid build directory.', 1)
69 executable=os.path.join(builddir,
"progs",
"substruct",
"substruct-perf")
70 if not os.path.isfile(executable) :
71 error(executable+
' is an invalid executable file name.', 1)
73 inputfn = os.path.join(datadir,
"substruct",
"inputs",
"8andares02.txt")
74 if not os.path.isfile(inputfn) :
75 error(inputfn+
' is an invalid input file name.', 1)
77 micloadex =
"opt/intel/mic/bin/micnativeloadex" 78 if not os.path.isfile(micloadex) :
79 error(micloadex+
'is an invalid path to the mic load tool.', 1)
81 os.system (
"scp "+inputfn+
" mic0:/home/edson")
83 arguments =
' -mp '+
"/home/edson/8andares02.txt" 84 arguments = arguments +
' -nsub 240' 85 arguments = arguments +
' -nt_a 240' 86 arguments = arguments +
' -nt_d 240' 87 arguments = arguments +
' -nt_m 240' 88 arguments = arguments +
' -nt_sm 240' 89 arguments = arguments +
' -p 2' 90 for rdtarg
in rdtfiles_l :
91 arguments = arguments +
' ' + rdtarg[1] +
' ' + rdtarg[2]
93 return rundir, micloadex +
' ' + executable +
' -a ' +
'\"' + arguments +
'\"' 96 limits = {
"cpu" : (resource.RLIMIT_CPU, 3600,
"Max CPU time in seconds"),
107 print "Setting resource limit in child" 108 for k, v
in limits.iteritems() :
109 resource.setrlimit(v[0], (v[1],v[1]))
116 for f
in rdtfiles_l :
119 if summarize_results :
121 rdtfn=os.path.join(rundir,fn)
127 print "WARNING: Could not compute average for results at", fn,
"(", e,
")" 132 print "WARNING: Could not compute confidence interval for results at", fn,
"(", e,
")" 135 print "WARNING: error when summarizing results for", fn,
"(", e,
")" 147 for f
in rdtfiles_l :
149 rdt_fn = os.path.join(rundir,f[2])
151 results[rdt_id] = (rdt_fn, rdt_dsc)
154 def short_description() :
return "substructure -- 8andares02.txt -- 240 substructures and 240 threads" 157 def run_test(ntimes):
162 args = shlex.split(cmd)
165 for i
in range(ntimes) :
166 p = subprocess.Popen(args, preexec_fn=setlimits, stdout=sout, stderr=serr, cwd=rundir)
168 if (p.returncode != 0) :
169 return p.returncode, {}
176 print "\nUsage: test.py -r [-h]\n" 178 print "\t-r : Run the experiment." 179 print "\nDESCRIPTION" 180 print "\tExecute the substruct tool collecting statistics for the following steps:" 181 print "\t ", assfn[0],
": assembling the system (serial) -- results at", assfn[1]
182 print "\t ", tpzdohrassfn[0],
": assembling (ass part) the system (serial) -- results at", tpzdohrassfn[1]
183 print "\t ", tpzdohrdecfn[0],
": assembling (dec part) the system (serial) -- results at", tpzdohrdecfn[1]
184 print "\t ", crefn[0],
": creating the sytem (serial) -- results at", crefn[1]
185 print "\t ", solfn[0],
": solver (serial) -- results at", solfn[1]
186 print "\t ", totfn[0],
": total -- results at", totfn[1]
190 if __name__ ==
"__main__":
196 opts, extra_args = getopt.getopt(sys.argv[1:],
'rn:h')
197 except getopt.GetoptError, e:
201 elif f ==
'-n': ntimes=int(v)
202 elif f ==
'-h':
usage()
207 if status == 0:
print "Execution [OK]" 208 else :
print "Execution [FAILED] (status = ", status,
")" 209 print "Results summary ----------------------------" 210 for k,v
in results.iteritems() :
print '{0:10s} : {1:>16f} +- {2:<16f}'.format(k, v[0], v[1])
211 print "--------------------------------------------" 213 print "WARNING: No options provided. (use -h for help)"
def sumarize_rdt_files(rundir)
def sumarize_rdt_results(rundir)
def error(message, status)
def conf_int(vlist, conf_level)
def get_column_values(rdt_d, field)