import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib from matplotlib.ticker import ScalarFormatter, FormatStrFormatter matplotlib.style.use('ggplot') # Roofline Plot #log x i = 32 xlbl = [] while i > 1: xlbl.append("1/"+repr(i)) i //= 2 xlbl.append(repr(i)) #1 i += 1 while i<=64: xlbl.append(repr(i)) i *= 2 print(xlbl) # memory values = [] bandwidth = 10.6 peak = 86.4 basepeak = 54.4 ymem = [] ypeak = [] ybasepeak = [] yeight = [] ysix = [] for i in np.arange(0,64,0.1): if bandwidth*i < peak: values.append(bandwidth*i) else: values.append(peak) i=1/32 while i<=64: if i < 16 and i > 4: yeight.append(21.78) ysix.append(peak) else: yeight.append(None) ysix.append(None) if bandwidth*i < peak and bandwidth*i*2 < peak: ymem.append(bandwidth*i) ypeak.append(None) elif bandwidth*i < peak and bandwidth*i*2 > peak: ypeak.append(peak) ymem.append(bandwidth*i) else: ypeak.append(peak) ymem.append(None) i*=2 #plot data #data = pd.Series(data=values, name='Peak Memory Bandwidth', index=np.arange(0,64,0.1)) data = {'Peak Memory Bandwidth': pd.Series(ymem, index=xlbl), 'Peak Floating-Point Performance (Turbo)': pd.Series(ypeak, index=xlbl), 'Best 8 OI Kernel': pd.Series(yeight, index=xlbl), 'Best 1/16 OI Kernel': pd.Series(yeight, index=xlbl)} df = pd.DataFrame(data) ax = df.plot() ax.set_xlabel("Operational Itensity (FLOP/Byte)") ax.set_ylabel("Attainable GFLOP/s") ax.set_yscale('log', basey=2) ax.yaxis.set_major_formatter(FormatStrFormatter('%.0f')) print(repr(data)) plt.show()