-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathplot.py
More file actions
116 lines (97 loc) · 3.97 KB
/
plot.py
File metadata and controls
116 lines (97 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import matplotlib.pyplot as plt
import json
import numpy as np
import math
import sys
# Function to plot the data
def plot(data, ticks, labels, title, topy, file=None):
# Define common styles for the plot
common_style = {
'linestyle': '-',
'marker': 'o',
'markersize': 10.0,
'markeredgewidth': 2.0,
'markeredgecolor': '#FFFFFF'
}
# Define unique styles for each dataset
styles = [
dict(color='#F6511D', **common_style),
dict(color='#7FB800', **common_style),
dict(color='#00A6ED', **common_style),
dict(color='#FFB400', **common_style),
dict(color='#983fd3', **common_style),
dict(color='#36cccc', **common_style),
dict(color='#db37af', **common_style),
dict(color='#5430e4', **common_style),
]
# Define grid style
grid_style = {'color': '#777777'}
# Set figure size
figsize = (14, 8)
fig, ax = plt.subplots(figsize=figsize)
# Enable grid with the defined style
ax.grid(True, **grid_style)
# Plot each dataset with its corresponding style and label
x = None
for d, s, l in zip(data, styles, labels):
ax.set_xlabel('size')
ax.set_ylabel('mflops')
x = np.linspace(0, len(d), len(d), False)
ax.plot(x, d, linewidth=1.6, label=l, **s)
# Set y-axis limits
ax.set_ylim(bottom=0.0)
ax.set_ylim(top=topy)
# Add legend at the bottom center
ax.legend(loc='lower center', shadow=True)
# Adjust x-axis ticks
if x is not None: # Ensure x is defined before using it
ticks = ticks[:len(x)]
plt.xticks(x, ticks, rotation='vertical')
plt.title(title)
plt.tight_layout()
# Save the plot to a file or display it
if not file:
plt.show()
else:
plt.savefig(file, dpi=125)
# Get input files from command-line arguments
files = sys.argv[1:]
if len(files) == 0:
sys.exit("No input files supplied. Example: \npython plot.py data1.json data2.json … dataN.json")
print("Processing files: ", files)
# Load JSON data from the input files
results = [json.load(open(f)) for f in files]
# Extract library names and all results
libraries = [r['library'] for r in results]
all_results = [re for r in results for re in r['performance']]
# Iterate over data types (float, double) and process each combination
for data in ['float', 'double']:
for type in ['complex', 'real']:
try:
print(f"Processing data type: {data}, type: {type}")
filtered_results = [x for x in all_results if x['data'] == data and x['type'] == type]
# Find the maximum MFLOPS value for scaling the y-axis
mflops_max = max(
x for x in [x.get('mflops') for x in filtered_results] if x is not None
)
topy = math.ceil(mflops_max / 10000.0) * 10000.0
# Iterate over FFT directions and buffer types
for direction in ['forward', 'inverse']:
for buffer in ['inplace', 'outofplace']:
# Generate the plot title
title = f'{data}-{type}-{direction}-{buffer}'
print("Generating plot: ", title)
# Extract sizes and values for the current configuration
sizes = [
x['size'] for x in results[0]['performance']
if x['data'] == data and x['type'] == type and x['direction'] == direction and x['buffer'] == buffer
]
values = [
[x.get('mflops') for x in r['performance']
if x['data'] == data and x['type'] == type and x['direction'] == direction and x['buffer'] == buffer]
for r in results
]
# Generate the plot
plot(values, sizes, libraries, title, topy, 'plots/' + title + '.svg')
except Exception as e:
print(f"Error processing {data}-{type}: {e}")