|
@@ -10,8 +10,8 @@ import os
|
|
|
# Helper function to attach labels to the bars
|
|
|
def autolabel(subplot, bars):
|
|
|
for bar in bars:
|
|
|
- height = bar.get_height()
|
|
|
- subplot.text(bar.get_x() + bar.get_width()/2., 1.05*height, '%d' % int(height), ha='center', va='bottom')
|
|
|
+ height = round(bar.get_height(), 1)
|
|
|
+ subplot.text(bar.get_x() + bar.get_width()/2., 1.05*height, '%s' % height, ha='center', va='bottom')
|
|
|
|
|
|
# Helper function to strip away the "opencl/" prefix and other stuff from all the names
|
|
|
def stripNames (category, names):
|
|
@@ -24,7 +24,7 @@ def stripNames (category, names):
|
|
|
return stripped_names
|
|
|
|
|
|
# List containing all the platform names
|
|
|
-platforms = ['cpu', 'gpu-primary', 'gpu-secondary']
|
|
|
+platforms = ['cpu']
|
|
|
|
|
|
# List containing the categories of the benchamrks
|
|
|
categories = ['short', 'long']
|
|
@@ -34,11 +34,7 @@ stderrTotal = {}
|
|
|
|
|
|
# Import data from file
|
|
|
averageTotal['cpu'] = np.genfromtxt('results/cpu/average.csv', dtype=None, delimiter=',', names=['name', 'time', 'power'])
|
|
|
-averageTotal['gpu-primary'] = np.genfromtxt('results/gpu-primary/average.csv', dtype=None, delimiter=',', names=['name', 'time', 'power'])
|
|
|
-averageTotal['gpu-secondary'] = np.genfromtxt('results/gpu-secondary/average.csv', dtype=None, delimiter=',', names=['name', 'time', 'power'])
|
|
|
stderrTotal['cpu'] = np.genfromtxt('results/cpu/stderr.csv', dtype=None, delimiter=',', names=['name', 'time', 'power'])
|
|
|
-stderrTotal['gpu-primary'] = np.genfromtxt('results/gpu-primary/stderr.csv', dtype=None, delimiter=',', names=['name', 'time', 'power'])
|
|
|
-stderrTotal['gpu-secondary'] = np.genfromtxt('results/gpu-secondary/stderr.csv', dtype=None, delimiter=',', names=['name', 'time', 'power'])
|
|
|
|
|
|
|
|
|
# Create the folder where to store the charts, if it doesn't already exist
|
|
@@ -51,15 +47,15 @@ indexes = {'short': [], 'long': []}
|
|
|
# We cycle on the benchmarks results for the cpu (since usually they are the ones with the longest run time) and divide in two groups the benchmarks, putting the relative indexes in two lists
|
|
|
for i in range(0,17):
|
|
|
record = averageTotal['cpu'].take(i)
|
|
|
- if record['time'] < 30:
|
|
|
+ if record['time'] < 10:
|
|
|
indexes['short'].append(i)
|
|
|
else:
|
|
|
indexes['long'].append(i)
|
|
|
|
|
|
|
|
|
# We instantiate a new dict to contain the average and the std err of the measurements on the various platforms
|
|
|
-average = {'cpu': {}, 'gpu-primary': {}, 'gpu-secondary': {}}
|
|
|
-stderr = {'cpu': {}, 'gpu-primary': {}, 'gpu-secondary': {}}
|
|
|
+average = {'cpu': {}}
|
|
|
+stderr = {'cpu': {}}
|
|
|
|
|
|
for platform in platforms:
|
|
|
for category in categories:
|
|
@@ -84,9 +80,7 @@ def plotTimes (category):
|
|
|
fig, ax = plt.subplots(figsize=(20, 10))
|
|
|
|
|
|
# Create the bar plot for the time values
|
|
|
- time_cpu_bars = ax.bar(x[category]-0.3, average['cpu'][category]['time'], width=0.2, color='b', align='edge', yerr=stderr['cpu'][category]['time'])
|
|
|
- time_gpu_primary_bars = ax.bar(x[category], average['gpu-primary'][category]['time'], width=0.2, color='r', align='center', yerr=stderr['gpu-primary'][category]['time'])
|
|
|
- time_gpu_secondary_bars = ax.bar(x[category]+0.3, average['gpu-secondary'][category]['time'], width=-0.2, color='g', align='edge', yerr=stderr['gpu-secondary'][category]['time'])
|
|
|
+ time_cpu_bars = ax.bar(x[category], average['cpu'][category]['time'], width=0.2, color='b', align='center', yerr=stderr['cpu'][category]['time'])
|
|
|
|
|
|
# Change the labels of the x axis to contain the names of the benchmarks
|
|
|
ax.set_xticks(x[category])
|
|
@@ -97,53 +91,15 @@ def plotTimes (category):
|
|
|
|
|
|
# Add some patches as legend of the colors used for the various benchmarks
|
|
|
red_patch = mpatches.Patch(color='blue', label='Execution time for cpu')
|
|
|
- blue_patch = mpatches.Patch(color='red', label='Execution time for gpu(4 core)')
|
|
|
- green_patch = mpatches.Patch(color='green', label='Execution time for gpu(2 core)')
|
|
|
|
|
|
- ax.legend(handles=[red_patch, blue_patch, green_patch])
|
|
|
+ ax.legend(handles=[red_patch])
|
|
|
|
|
|
# Invoke the helper function to attach labels for each bar
|
|
|
autolabel(ax, time_cpu_bars)
|
|
|
- autolabel(ax, time_gpu_primary_bars)
|
|
|
- autolabel(ax, time_gpu_secondary_bars)
|
|
|
|
|
|
# Save the obtained plot on file
|
|
|
plt.savefig('charts/times-' + category + '.pdf')
|
|
|
|
|
|
-# Helper function that create the plots of the execution time, takes as parameter the category of the benchmark we want to plot
|
|
|
-def plotPower (category):
|
|
|
-
|
|
|
- # Create a new figure
|
|
|
- fig, bx = plt.subplots(figsize=(20, 10))
|
|
|
-
|
|
|
- # Create the bar plot for the power values
|
|
|
- power_cpu_bars = bx.bar(x[category]-0.3, average['cpu'][category]['power'], width=0.2, color='b', align='edge', yerr=stderr['cpu'][category]['power'])
|
|
|
- power_gpu_primary_bars = bx.bar(x[category], average['gpu-primary'][category]['power'], width=0.2, color='r', align='center', yerr=stderr['gpu-primary'][category]['power'])
|
|
|
- power_gpu_secondary_bars = bx.bar(x[category]+0.3, average['gpu-secondary'][category]['power'], width=-0.2, color='g', align='edge', yerr=stderr['gpu-secondary'][category]['power'])
|
|
|
-
|
|
|
- # Change the labels of the x axis to contain the names of the benchmarks
|
|
|
- bx.set_xticks(x[category])
|
|
|
- bx.set_xticklabels(x_names_stripped[category])
|
|
|
- bx.set_title('Power consumption of the various benchmarks expressed in mWatt/hour')
|
|
|
- bx.set_xlabel('Benchmark')
|
|
|
- bx.set_ylabel('mWatt/hour')
|
|
|
-
|
|
|
- # Add some patches as legend of the colors used for the various benchmarks
|
|
|
- red_patch = mpatches.Patch(color='blue', label='Power consumption for cpu')
|
|
|
- blue_patch = mpatches.Patch(color='red', label='Power consumption for gpu(4 core)')
|
|
|
- green_patch = mpatches.Patch(color='green', label='Execution time for gpu(2 core)')
|
|
|
-
|
|
|
- bx.legend(handles=[red_patch, blue_patch, green_patch])
|
|
|
-
|
|
|
- # Invoke the helper function to attach labels one for each bar
|
|
|
- autolabel(bx, power_cpu_bars)
|
|
|
- autolabel(bx, power_gpu_primary_bars)
|
|
|
- autolabel(bx, power_gpu_secondary_bars)
|
|
|
-
|
|
|
- # Save the obtained plot on file
|
|
|
- plt.savefig('charts/power-' + category + '.pdf')
|
|
|
-
|
|
|
# Invoke the helper functions to plot the data
|
|
|
for category in categories:
|
|
|
plotTimes(category)
|
|
|
- plotPower(category)
|