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 # memory values = [] bandwidth = 10.6 peak = 86.4 ymem = [] ypeak = [] 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 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': pd.Series(ypeak, 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()