continue prepareMake(opts) fine = exp_fun(resMgr, *(exp_fun_args + [opts])) end_time = time.time() print 'Experiment %s on %s finished at %s (duration: %s).' % (exp, dev, time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime(end_time)), str(timedelta(seconds=int(end_time-start_time)))) if opts['plot'] and opts.get('test', True) and (not 'onlygen' in opts or not opts['onlygen']) and something_happend and fine: if len(precomp_series) == 0: precomp_series = None precomp_markers = None precomp_linestyles = None precomp_colors = None precomp_lw = None filename = '%s.%s.%s.pdf' % (exp_id, dev, date.today().isoformat()) resMgr.makePlot(opts, 0, 8, exp_description, "n [" +opts['precision']+ "]", "Performance [f/c]", opts['logroot'], filename, addLegend=opts['addlegend'], addTitle=opts['addtitle'], xLabelStride=opts['xlabelstride'], series=precomp_series, seriesMarkers=precomp_markers, seriesColors=precomp_colors, seriesLw=precomp_lw, seriesLinestyles=precomp_linestyles, adjust_yaxis=False) # resMgr.makePlot(opts, 0, opts['peak'][opts['isa'].__name__][opts['precision']], exp_description, "n [" +opts['precision']+ "]", # "Performance [f/c]", opts['logroot'], filename, addLegend=opts['addlegend'], addTitle=opts['addtitle'], # xLabelStride=opts['xlabelstride'], series=precomp_series, seriesMarkers=precomp_markers, seriesColors=precomp_colors, seriesLw=precomp_lw, seriesLinestyles=precomp_linestyles) opts.clear() gc.collect() end_all_exps = time.time() final_msg = 'Total execution time for %d experiments on %d devices: %s' % (len(experiments), len(devices), str(timedelta(seconds=int(end_all_exps - start_all_exps)))) print final_msg send_email_with_log(common_config, subj="Experiments Completed", body=final_msg)
def testing1toNParam(resMgr, p0, fs, opts): sizesP0 = range(p0[0], p0[1] + 1) if len(p0) == 2 else range(p0[0], p0[1] + 1, p0[2]) params = [f[0] for f in fs] sizes = [] for i in sizesP0: sizes.append([f[1](i) for f in fs]) fine = True for pvalues, i in zip(sizes, sizesP0): try: opts['static_params'] = pvalues genCode = not 'libname' in opts onlygen = 'onlygen' in opts and opts['onlygen'] compiler = None if genCode: opts['pvalues'] = { p: pvalue for p, pvalue in zip(params, pvalues) } llprog = parseLL( {p: pvalue for p, pvalue in zip(params, pvalues)}, opts) compiler = Compiler(llprog, opts) else: compiler = LibraryCode(opts) s = datetime.now() if not onlygen: printToLog( " " + "Starting compiler at " + str(s) + " ----------------------------------------", opts) fine = fine and compiler.compile() e = datetime.now() if not (genCode and onlygen): procOutcome(resMgr, compiler, opts, " ", sizeParams=[i]) printToLog( " " + "Compiling took " + str(e - s) + " ----------------------------------------------------------", opts) recordTime((e - s).total_seconds(), opts) except Exception: # openLog(opts) ts = '%s.%s' % (date.today().isoformat(), time.strftime('%H-%M-%S', time.localtime(time.time()))) msg = "=@" * 10 + " Begin Exc Report from testing1toNParam (" + ts + ") " + "=@" * 10 + "\n" msg += "-" * 10 + " opts " + "-" * 10 + "\n" msg += str(opts) + "\n" msg += "-" * 10 + " traceback " + "-" * 10 + "\n" # printToLog(msg, opts, openf=False, closef=False) # traceback.print_exc(file=opts['logfile']) msg += traceback.format_exc() msg += "\n" + "=@" * 10 + " End Exc Report (" + ts + ") " + "=@" * 10 + "\n" printToLog(msg, opts) if opts.get('breakonexc', False): # openLog(opts, 'r') # body = opts['logfile'].read() # closeLog(opts) send_email_with_log(opts, subj="SLinGen Report on Exception", body=msg) raise fine = False return fine
def makePlot(self, opts, y_min, y_max, title, x_label, y_label, basefolder, plotfilename, addLegend=True, addTitle=True, xLabelStride=1, series=None, seriesMarkers=None, seriesColors=None, seriesLw=None, seriesLinestyles=None, plotStats=True, adjust_yaxis=True): fig = plt.figure() if addTitle: fig.suptitle(title,fontsize=14,fontweight='bold') ax = fig.add_subplot(111) # formatting of axis labels ax.set_title(y_label,fontsize=12,ha='left',position=(0,1)) ax.set_xlabel(x_label, fontsize=12) # uncomment to remove the x-axis # ax.axes.get_xaxis().set_visible(False) self.series = [ basefolder+'/results/'+curve for curve in self.series ] # Load the data if series is not None: linestyles = seriesLinestyles + self.linestyles markers = seriesMarkers + self.markers colors = seriesColors + self.colors lw = seriesLw + self.lw series += self.series else: linestyles = self.linestyles markers = self.markers colors = self.colors lw = self.lw series = self.series x_min, x_max, xDataLabels, xData = self._setup_x_axis(series[0], xLabelStride) if series else (0, 0, [], []) yDataAll = [] def _read_multiline(filename, linelist): with open(filename,'r') as file_in: for line in file_in.readlines(): split_line = line.rstrip('\n').split(' ') linelist.append(split_line) for i, curve in enumerate(series): print "Plotting curve " + curve #Plot Max line nCycles = [] _read_multiline(curve+'/cycles.txt', nCycles) # file_in = open(curve+'/cycles.txt','r') # lines = file_in.readlines() # for line in lines: # split_line = line.rstrip('\n').split(' ') # nCycles.append(split_line) # file_in.close() nFLOPS = [] _read_multiline(curve+'/flops.txt', nFLOPS) # file_in = open(curve+'/flops.txt','r') # lines = file_in.readlines() # for line in lines: # split_line = line.rstrip('\n').split(' ') # nFLOPS.append(split_line) # file_in.close() curve_label = '' with open(curve+'/legend.txt','r') as file_in: curve_label = file_in.readlines()[0].strip() # file_in = open(curve+'/legend.txt','r') # curve_label = file_in.readlines()[0].strip() # file_in.close() self._add_line(ax, nFLOPS, nCycles, plotStats, xData, colors[i], linestyles[i], lw[i], markers[i], colors[i], self.ms[i], curve_label, yDataAll) if os.path.exists(curve+'/perf_variants'): # Temp # rgb_color_lst = [[255,51,51],[175,51,51],[95,51,51]] # mrkr_lst = ['D','v','s','*'] # cm_lst = [ (rgb,mrkr) for mrkr in mrkr_lst for rgb in rgb_color_lst ] # Temp vartags = sorted(next(os.walk(curve+'/perf_variants'))[1]) num_lines = len(vartags) color_stride = 256//num_lines # rgb_color = [255,51,51] rgb_color = [255,33,33] # for cm,vartag in zip(cm_lst,vartags): # for m,vartag in zip(mrkr_lst,vartags): for vartag in vartags: vardir = curve+'/perf_variants/'+vartag nCycles = [] _read_multiline(vardir+'/cycles.txt', nCycles) nFLOPS = [] _read_multiline(vardir+'/flops.txt', nFLOPS) # hex_color = webcolors.rgb_to_hex(cm[0]) # self._add_line(ax, nFLOPS, nCycles, plotStats, xData, hex_color, '--', 1., cm[1], hex_color, self.ms[i], vartag.replace('_','-')) hex_color = webcolors.rgb_to_hex(rgb_color) # self._add_line(ax, nFLOPS, nCycles, plotStats, xData, hex_color, '--', 1., m, '#333333', self.ms[i], vartag.replace('_','-')) self._add_line(ax, nFLOPS, nCycles, plotStats, xData, hex_color, '--', 1., markers[i], hex_color, self.ms[i], vartag.replace('_','-')) rgb_color[0] -= color_stride # yData =[] # for f,c in zip(nFLOPS,nCycles): # yData.append([float(vf)/float(vc) for vf, vc in zip(f,c) if vf != '' and vc != '']) # yDataAll.append(yData) # # # txDataLabels = [] # # file_in = open(curve+'/sizes.txt','r') # # txDataLabels = file_in.readline().rstrip('\n').split(' ') # # # txDataLabels = [s[1:s.find(',')] for s in file_in.readline().rstrip('\n').split(' ')] # # file_in.close() # # # # xDataLabels = ['']*len(txDataLabels) # # xDataLabels[::xLabelStride] = txDataLabels[::xLabelStride] # # # # xData = range(len(xDataLabels)) # # x_min=xData[0] # # x_max=xData[-1] # # if plotStats: # """ # Percentile boxes # On each box, the central mark is the median, the edges of the box are the lower hinge (defined as the 25th percentile # ) and the upper hinge (the 75th percentile), the whiskers extend to the most extreme data points not considered outliers, # this ones are plotted individually. # """ # # rectanglesWidths = [0 for x in xData] # rectanglesWidths = [0]*len(xData) # bp = ax.boxplot(yData, positions=xData, widths = rectanglesWidths) # # setp(bp['medians'], color='black') # setp(bp['fliers'], color=colors[i],marker='None') # setp(bp['whiskers'], color=colors[i], linestyle= '-') # setp(bp['boxes'], color=colors[i]) # setp(bp['caps'], color=colors[i]) # # medians = range(len(xData)) # for j in range(len(xData)): # med = bp['medians'][j] # medianX = [] # medianY = [] # for k in range(2): # medianX.append(med.get_xdata()[k]) # medianY.append(med.get_ydata()[k]) # medians[j] = medianY[0] # # ax.plot(xData, medians, linestyles[i], lw=lw[i], color=colors[i], marker=markers[i], markeredgecolor=colors[i], markersize=self.ms[i], label=curve_label, mfc='white', mew=2.) # else: # ax.plot(xData, yData, linestyles[i], lw=lw[i], color=colors[i], marker=markers[i], markeredgecolor=colors[i], markersize=self.ms[i], label=curve_label) # # end of if-else # #end for loop # ax.set_xticklabels(xDataLabels, rotation=45) ax.xaxis.grid(False) ax.tick_params(direction='out', pad=5) ax.xaxis.set_ticks_position('bottom') ax.spines['bottom'].set_color('#000000') ax.spines['bottom'].set_linewidth(2) for line in ax.xaxis.get_ticklines(): line.set_markeredgewidth(1) line.set_marker(lns.TICKDOWN) ax.set_xticklabels(xDataLabels) #ax.legend(numpoints=1, loc='best',frameon = False ) # ax.legend(numpoints=1, loc='best').get_frame().set_visible(False) legframe = ax.legend(numpoints=1, loc='best', fancybox=True).get_frame() legframe.set_facecolor('#FFFFFF') # legframe.set_visible(False) if adjust_yaxis: y_min, y_max = self.adjust_yaxis_scale(yDataAll, y_min, y_max, addLegend) #x-y range ax.axis([x_min-0.15,x_max+0.15,y_min,y_max]) # ax.legend().set_visible(addLegend) if not addLegend: ax.legend().set_visible(False) # Uncomment to change the font size of the x-axis labels # ax.tick_params(axis='x', labelsize=2) #save file print '\n\nSaving plot in ' + basefolder+'/plots/'+plotfilename + '\n\n' fig.savefig(basefolder+'/plots/'+plotfilename, dpi=250, bbox_inches='tight') send_email_with_log(opts, "Perf Plot", attachments=[(basefolder+'/plots/', plotfilename)], extra_to=opts.get('onlypdfs', []))
def testingNParam(resMgr, ps, opts): ''' Test the kernel for the cartesian product of the values in the given intervals p0, p1, p2, ... ''' params = [pi[0] for pi in ps] sizesPi = [ range(pi[1], pi[2] + 1) if len(pi) == 3 else range(pi[1], pi[2] + 1, pi[3]) for pi in ps ] sizes = list(itertools.product(*sizesPi)) fine = True for pvalues in sizes: try: opts['static_params'] = list(pvalues) genCode = not 'libname' in opts onlygen = 'onlygen' in opts and opts['onlygen'] compiler = None if genCode: opts['pvalues'] = { p: pvalue for p, pvalue in zip(params, pvalues) } llprog = parseLL( {p: pvalue for p, pvalue in zip(params, pvalues)}, opts) compiler = Compiler(llprog, opts) else: compiler = LibraryCode(opts) s = datetime.now() if not onlygen: printToLog( " " + "Starting compiler at " + str(s) + " ----------------------------------------", opts) fine = fine and compiler.compile() e = datetime.now() if not (genCode and onlygen): procOutcome(resMgr, compiler, opts, " ") printToLog( " " + "Compiling took " + str(e - s) + " ----------------------------------------------------------", opts) recordTime((e - s).total_seconds(), opts) except Exception: openLog(opts) ts = '%s.%s' % (date.today().isoformat(), time.strftime('%H-%M-%S', time.localtime(time.time()))) msg = "=@" * 10 + " Begin Exc Report from testingNParam (" + ts + ") " + "=@" * 10 + "\n" msg += "-" * 10 + " opts " + "-" * 10 + "\n" msg += str(opts) + "\n" msg += "-" * 10 + " traceback " + "-" * 10 + "\n" # printToLog(msg, opts, openf=False, closef=False) # traceback.print_exc(file=opts['logfile']) msg += traceback.format_exc() msg += "\n" + "=@" * 10 + " End Exc Report (" + ts + ") " + "=@" * 10 + "\n" # printToLog(msg, opts, openf=False) printToLog(msg, opts) if opts.get('breakonexc', False): send_email_with_log(opts, subj="SLinGen Report on Exception", body=msg) raise fine = False return fine