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")
54 rdtfiles_l=[assfn, crefn, solfn, totfn, tpzdohrassfn, tpzdohrdecfn]
59 if not os.path.isdir(builddir) :
60 error(builddir+
' is an invalid build directory.', 5)
62 rundir = os.path.join(builddir,
'scripts',
'substruct_tst14')
63 if not os.path.isdir(rundir) :
64 error(rundir+
' is an invalid run directory.', 1)
65 if not os.path.isdir(builddir) :
66 error(builddir+
' is an invalid build directory.', 1)
68 executable=os.path.join(builddir,
"progs",
"substruct",
"substruct-perf")
69 if not os.path.isfile(executable) :
70 error(executable+
' is an invalid executable file name.', 1)
72 inputfn = os.path.join(datadir,
"substruct",
"inputs",
"Cubo986.msh")
73 if not os.path.isfile(inputfn) :
74 error(inputfn+
' is an invalid input file name.', 1)
76 arguments =
' -mc '+inputfn
77 arguments = arguments +
' -p 2' 79 arguments = arguments +
' -naDALora' 83 arguments = arguments +
' -naDALtws' 84 for rdtarg
in rdtfiles_l :
85 arguments = arguments +
' ' + rdtarg[1] +
' ' + rdtarg[2]
87 return rundir, executable+arguments
90 limits = {
"cpu" : (resource.RLIMIT_CPU, 3600,
"Max CPU time in seconds"),
101 print "Setting resource limit in child" 102 for k, v
in limits.iteritems() :
103 resource.setrlimit(v[0], (v[1],v[1]))
110 for f
in rdtfiles_l :
113 if summarize_results :
115 rdtfn=os.path.join(rundir,fn)
121 print "WARNING: Could not compute average for results at", fn,
"(", e,
")" 126 print "WARNING: Could not compute confidence interval for results at", fn,
"(", e,
")" 129 print "WARNING: error when summarizing results for", fn,
"(", e,
")" 137 for arq
in rdtfiles_l:
144 for f
in rdtfiles_l :
146 rdt_fn = os.path.join(rundir,f[2])
148 results[rdt_id] = (rdt_fn, rdt_dsc)
151 def short_description() :
return "substructure -- cubo986.msh -- parallel -- different number of substructures and number of threads with Numa naDALora and naDALtws" 154 def run_test(ntimes, nsub, thread):
159 cmd = cmd +
" -nsub " + nsub
161 cmd = cmd +
' -nt_a ' + thread
162 cmd = cmd +
' -nt_d ' + thread
163 cmd = cmd +
' -nt_m ' + thread
164 cmd = cmd +
' -nt_sm ' + thread
166 args = shlex.split(cmd)
167 sout = subprocess.PIPE
170 for i
in range(ntimes) :
171 p = subprocess.Popen(args, preexec_fn=setlimits, stdout=sout, stderr=serr, cwd=rundir)
173 if (p.returncode != 0) :
174 return p.returncode, {}
181 print "\nUsage: test.py -r [-h]\n" 183 print "\t-r : Run the experiment." 184 print "\nDESCRIPTION" 185 print "\tExecute the substruct tool collecting statistics for the following steps:" 186 print "\t ", assfn[0],
": assembling the system (serial) -- results at", assfn[1]
187 print "\t ", tpzdohrassfn[0],
": assembling (ass part) the system (serial) -- results at", tpzdohrassfn[1]
188 print "\t ", tpzdohrdecfn[0],
": assembling (dec part) the system (serial) -- results at", tpzdohrdecfn[1]
189 print "\t ", crefn[0],
": creating the sytem (serial) -- results at", crefn[1]
190 print "\t ", solfn[0],
": solver (serial) -- results at", solfn[1]
191 print "\t ", totfn[0],
": total -- results at", totfn[1]
195 if __name__ ==
"__main__":
201 opts, extra_args = getopt.getopt(sys.argv[1:],
'rn:h')
202 except getopt.GetoptError, e:
206 elif f ==
'-n': ntimes=int(v)
207 elif f ==
'-h':
usage()
209 subs = [
"4",
"8",
"12",
"16",
"20",
"24",
"28",
"32",
"36",
"48",
"64",
"128"]
210 numthreads = [
"1" ,
"6",
"12",
"18",
"24",
"32",
"48" ,
"64"]
213 for thr
in numthreads:
214 print "# Results Summary" 215 print '{0:s}; {1:s}; '.format(
"nsub",
"threads"),
216 for arq
in rdtfiles_l:
217 print'{0:s}; {1:s};'.format(arq[0],
"err_"+arq[0]),
221 if status != 0 :
print "Execution [FAILED] (status = ", status,
")" 222 print '\n{0:s}; {1:s};'.format(item, thr ),
223 for k,v
in results.iteritems() :
print '{0:.2f}; {1:.2f};'.format(v[0], v[1]),
224 print "\n--------------------------------------------" 226 print "WARNING: No options provided. (use -h for help)"
def error(message, status)
def conf_int(vlist, conf_level)
def run_test(ntimes, nsub, thread)
def sumarize_rdt_results(rundir)
def get_column_values(rdt_d, field)
def sumarize_rdt_files(rundir)