25 import shlex, subprocess
31 executable=
'./Perf-TBB' 37 limits = {
"cpu" : (resource.RLIMIT_CPU, 3600,
"Max CPU time in seconds") }
45 if not os.path.isfile(filename):
46 raise RdtError(filename+
' is not a valid rdt file.')
48 with open(filename)
as f:
50 hlist=f.readline().split(
',')
58 vlist = line.split(
',')
60 if first.strip() !=
"#":
63 d[hi][1].append(float(v.strip()))
68 for k, v
in rdt_d.iteritems():
78 s=reduce(
lambda x,y : float(x)+float(y), vlist, 0.0)
83 if size == 1
or size == 0:
84 raise StatsError(
"Cannot calculate variance for a sample of size "+str(size))
85 sum1=reduce(
lambda x,y : float(x)+float(y), vlist, 0.0)
86 sum2=reduce(
lambda x,y : float(x)+(float(y)*float(y)), vlist, 0.0)
87 v = (sum2-(
pow(sum1,2)/float(size)))/float(size-1)
92 raise StatsError(
"Something went wrong while calculating the variance (result < 0.0)")
101 print "Setting resource limit in child" 102 for k, v
in limits.iteritems() :
103 resource.setrlimit(v[0], (v[1],v[1]))
106 stat_res =
read(res_data)
110 print '{0:7s} \t {1:7s} \t {2:7s} \t {3:7s} \t {4:7s}'.format(
'threads',
'elapsed',
'user',
'elapsed_error',
'user_error')
112 print '{0:7s} \t {1:5.2f} \t {2:5.2f} \t '.format(t,
average(elapsed_list[lst:lst+ntimes]),
average(self_list[lst:lst+ntimes])),
114 print '{0:5.2f} \t {1:5.2f} '.format(
stdev(elapsed_list[lst:lst+ntimes]),
stdev(self_list[lst:lst+ntimes]))
116 print '{0:5.2f} \t {1:5.2f} '.format(0, 0)
120 arguments = executable +
' -p 3' 121 arguments = arguments +
' -perf ' + res_data
122 arguments = arguments +
' -mc ' + inputdata
123 arguments = arguments +
' -nt ' + nthreads
124 arguments = arguments +
' -type ' + t
127 args = shlex.split(arguments)
130 for i
in range(ntimes) :
131 p = subprocess.Popen(args, preexec_fn=setlimits, stdout=sout, stderr=serr, cwd=rundir)
133 if (p.returncode != 0) :
134 print "Execution [FAILED]" 137 if __name__ ==
"__main__":
140 threads = [
'2',
'4',
'6',
'8',
'12' ]
143 opts, extra_args = getopt.getopt(sys.argv[1:],
't:n:')
144 except getopt.GetoptError, e:
151 res =
'res_data_1.rdt' 156 res =
'res_data_' + str(t) +
'.rdt' 158 run_exp(i, ntimes, res, str(t))
159 print '# Execution Type : 1 #' 162 res =
'res_data_'+str(t)+
'.rdt' 163 print '# Execution Type : ' + str(t) +
' #' def run_exp(nthreads, ntimes, res_data, t)
def get_column_values(rdt_d, field)
def show_results(res_data, ths)
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
def error(message, status)