Skip to content

Commit

Permalink
add plot bitwise figure script
Browse files Browse the repository at this point in the history
Addresses #653.
  • Loading branch information
PeiMu committed May 24, 2023
1 parent cf7e76b commit bd31828
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
46 changes: 46 additions & 0 deletions analysis/statistics/5693026eb3620065f35a8222bf3202096ca061c6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

changeset: 1495:5693026eb3620065f35a8222bf3202096ca061c6
char kNewtonVersion[] = "0.3-alpha-1495 (5693026eb3620065f35a8222bf3202096ca061c6) (build 05-22-2023-11:[email protected]_64)";
\n./src/noisy/noisy-linux-EN -O0 applications/noisy/helloWorld.n -s
\n./src/newton/newton-linux-EN -v 0 -eP applications/newton/invariants/ViolinWithTemperatureDependence-pigroups.nt

Informational Report:
---------------------
Invariant "ViolinWithTemperatureDependenceForPiGroups" has 2 unique kernels, each with 2 column(s)...

Kernel 0 is a valid kernel:

1 1
-0.5 -0
1 0
0.5 0
0 -1
-0 -1


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 0, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^( 0) P5^(-0)

Pi group 0, Pi 1 is: P0^(-0) P1^( 1) P2^( 0) P3^( 0) P4^(-1) P5^(-1)


Kernel 1 is a valid kernel:

1 0
-0.5 1
1 -2
0.5 -1
-0 -2
0 -2


The ordering of parameters is: P1 P0 P3 P2 P4 P5

Pi group 1, Pi 0 is: P0^(-0.5) P1^( 1) P2^(0.5) P3^( 1) P4^(-0) P5^( 0)

Pi group 1, Pi 1 is: P0^( 1) P1^( 0) P2^(-1) P3^(-2) P4^(-2) P5^(-2)




Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import PercentFormatter


def bar_plot_groups(labels,
y1,
y2,
y1_label,
y2_label,
ylabel,
title,
save_fig='',
percentage=False):
"""
A simple wrapper for matplotlib's barplot.
:param labels:
:param y1:
:param y2:
:param ylabel:
:param xlabel:
:param save_fig:
:return:
"""
xlabel = labels + labels
x = np.arange(len(xlabel)) # the label locations
width = 0.35 # the width of the bars

plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.rc('font', size=12)

fig, ax = plt.subplots()
# ax.bar(x - width / 2, y1[0:len(x)], width, label=y1_label, color='#c2a4cf')
# ax.bar(x + width / 2, y2[0:len(x)], width, label=y2_label, color='#7b3294')
ax.bar(x[0:len(labels)] - width / 2, y1[0:len(labels)], width, label="arm "+y1_label, color='#fdb863')
ax.bar(x[0:len(labels)] + width / 2, y2[0:len(labels)], width, label="arm "+y2_label, color='#e66101')
ax.bar(x[len(labels):] - width / 2, y1[len(labels):], width, label="x86 "+y1_label, color='#c2a4cf')
ax.bar(x[len(labels):] + width / 2, y2[len(labels):], width, label="x86 "+y2_label, color='#7b3294')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel(ylabel)
if percentage:
ax.yaxis.set_major_formatter(PercentFormatter(1))
ax.set_ylim([min(min(y1), min(y2))*0.8, max(max(y1), max(y2))*1.3])
else:
ax.set_ylim([min(min(y1), min(y2))*0.8, max(max(y1), max(y2))*1.1])
ax.set_title(title)
ax.set_xticks(x)
ax.set_xticklabels(xlabel)
ax.legend(prop={'size': 9}, loc='upper right')

plt.xticks(rotation=45)
ax.yaxis.grid() # horizontal lines

fig.tight_layout()

if len(save_fig):
plt.savefig(save_fig)
else:
plt.show()


if __name__ == '__main__':
labels = ["perf_rem_pio2", "perf_sincosf", "perf_float64_add", "perf_float64_div", "perf_float64_mul"]

# time speedup
arm_without_bitwise = [1.04, 1, 1.25, 1.16, 1.22]
arm_with_bitwise = [1.11, 1.39, 2.01, 1.41, 1.33]
x86_without_bitwise = [1.07, 1.05, 1.18, 1.06, 1.12]
x86_with_bitwise = [1.13, 1.48, 1.47, 1.14, 1.20]
y1 = arm_without_bitwise + x86_without_bitwise
y2 = arm_with_bitwise + x86_with_bitwise

bar_plot_groups(labels, y1, y2, 'w/o Bitwise Op Analysis',
'w/ Bitwise Op Analysis', 'Speedup',
'Speedup with/without bitwise operator analysis',
'bitwise_op_time_comparison.png')

# size reduction
arm_without_bitwise = [0.71, 1, 1, 0.86, 0.89]
arm_with_bitwise = [0.8, 0.92, 0.98, 0.79, 0.98]
x86_without_bitwise = [0.46, 1, 1, 0.86, 0.86]
x86_with_bitwise = [0.65, 0.91, 0.99, 0.79, 0.94]
y1 = arm_without_bitwise + x86_without_bitwise
y2 = arm_with_bitwise + x86_with_bitwise

bar_plot_groups(labels, y1, y2, 'w/o Bitwise Op Analysis',
'w/ Bitwise Op Analysis', 'Reduction',
'Size reduction with/without bitwise operator analysis',
'bitwise_op_size_comparison.png', percentage=True)

0 comments on commit bd31828

Please sign in to comment.