Files
cem17/figures/kernels.py
2017-05-16 11:47:15 -07:00

50 lines
2.0 KiB
Python

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import math
sns.set(style="white", context="talk")
plt.rcdefaults()
DPI=300
BBOX_INCHES='tight'
path = 'figures/kernels'
fig, ax = plt.subplots()
systems = ['32T\n(1 XE)', "160T\n(1 S822LC)", "4 GPU\n(4 XK)" ,"4 GPU\n(1 S822LC)"]
x_pos = np.arange(len(systems))
p2m = (127.10, 72.10749, 7.73, 1.604)
m2m = (156.2506, 102.61091, 9.613814, 1.746476)
m2l = (189.615, 82.67791, 18.177774, 2.671025)
l2l = (91.5957, 101.56461, 20.215436, 2.611185)
l2p = (196.2115, 68.38529, 6.994, 1.395)
p2p = (1117.368, 590.4818, 90.619, 18.265)
total = [sum(i) for i in zip(p2m,m2m,m2l,l2l,l2p,p2p)]
p2m_ratio = [i/j for i,j in zip(p2m, total)]
m2m_ratio = [i/j for i,j in zip(m2m, total)]
m2l_ratio = [i/j for i,j in zip(m2l, total)]
l2l_ratio = [i/j for i,j in zip(l2l, total)]
l2p_ratio = [i/j for i,j in zip(l2p, total)]
p2p_ratio = [i/j for i,j in zip(p2p, total)]
ax.bar(x_pos, p2m_ratio, color='0.75', label='P2M', bottom=[sum(i) for i in zip(m2m_ratio, m2l_ratio, l2l_ratio, l2p_ratio,p2p_ratio)])
ax.bar(x_pos, m2m_ratio, color='0.50', label='M2M', bottom=[sum(i) for i in zip(m2l_ratio, l2l_ratio, l2p_ratio,p2p_ratio)])
ax.bar(x_pos, m2l_ratio, color='0.40', label='M2L', bottom=[sum(i) for i in zip(l2l_ratio, l2p_ratio,p2p_ratio)])
ax.bar(x_pos, l2l_ratio, color='0.25', label='L2L', bottom=[sum(i) for i in zip(l2p_ratio,p2p_ratio)])
ax.bar(x_pos, l2p_ratio, color='0.15', label='L2P', bottom=p2p_ratio)
ax.bar(x_pos, p2p_ratio, color='0', label='P2P')
ax.set_xticks(x_pos)
ax.set_xticklabels(systems)
ax.set_ylabel("MLFMM Kernel Breakdown")
handles, labels = ax.get_legend_handles_labels()
ax.legend(handles, labels)
# plt.ylim([1, 1e4])
# ax.set_title('How fast do you want to go today?')
sns.despine(trim=True)
legend = plt.legend(frameon = 1)
frame = legend.get_frame()
# frame.set_facecolor('white')
# frame.set_edgecolor('white')
frame.set_alpha(0.9)
plt.savefig(path+'.pdf', bbox_inches=BBOX_INCHES)
plt.savefig(path+'.png', dpi=DPI, bbox_inches=BBOX_INCHES)