forked from juicyfennel/PolyBench_DPHPC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
86 lines (74 loc) · 2.95 KB
/
plot.py
File metadata and controls
86 lines (74 loc) · 2.95 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
import pandas as pd
import matplotlib.pyplot as plt
import os
import argparse
# Plot runtime, speedup, and efficiency
def plot_metrics(df, size, output_dir):
interfaces = df['Type'].unique()
x_label = 'Number of Processes'
# Runtime plot
plt.figure()
for iface in interfaces:
iface_data = df[df['Type'] == iface].sort_values(by='Processes')
plt.plot(iface_data['Processes'], iface_data['Mean Runtime'], label=iface, marker="o")
plt.fill_between(iface_data['Processes'],
iface_data['Mean Runtime'] - iface_data['STD'],
iface_data['Mean Runtime'] + iface_data['STD'], alpha=0.2)
plt.xlabel(x_label)
plt.ylabel('Runtime (s)')
plt.title(f'Runtime vs {x_label} (Size {size})')
plt.legend()
plt.grid()
plt.savefig(f"{output_dir}/runtime_vs_processes.png")
plt.close()
# Speedup plot
plt.figure()
for iface in interfaces:
iface_data = df[df['Type'] == iface].sort_values(by='Processes')
plt.plot(iface_data['Processes'], iface_data['Speedup'], label=iface, marker="o")
plt.xlabel(x_label)
plt.ylabel('Speedup')
plt.title(f'Speedup vs {x_label} (Size {size})')
plt.legend()
plt.grid()
plt.savefig(f"{output_dir}/speedup_vs_processes.png")
plt.close()
# Efficiency plot
plt.figure()
for iface in interfaces:
iface_data = df[df['Type'] == iface].sort_values(by='Processes')
plt.plot(iface_data['Processes'], iface_data['Efficiency'], label=iface, marker="o")
plt.xlabel(x_label)
plt.ylabel('Efficiency')
plt.title(f'Efficiency vs {x_label} (Size {size})')
plt.legend()
plt.grid()
plt.savefig(f"{output_dir}/efficiency_vs_processes.png")
plt.close()
# Main function
def main():
parser = argparse.ArgumentParser(description="Plot runtime, speedup, and efficiency from a CSV file.")
parser.add_argument('--file', type=str, required=True, help="Path to the input CSV file.")
args = parser.parse_args()
input_file = args.file
output_dir_base = "runtime_speedup_efficiency"
# Read the data
df = pd.read_csv(input_file)
# Ensure required columns exist
required_columns = ['Size', 'Processes', 'Nodes', 'Type', 'Mean Runtime', 'STD']
for col in required_columns:
if col not in df.columns:
print(f"Error: Required column '{col}' is missing from the CSV.")
exit(1)
# Calculate speedup and efficiency
reference_runtime = df[(df['Processes'] == 1) & (df['Nodes'] == 1) & (df['Type'] == 'std')]['Mean Runtime'].iloc[0]
df['Speedup'] = reference_runtime / df['Mean Runtime']
df['Efficiency'] = df['Speedup'] / df['Processes']
# Extract size and create output directory
size = df['Size'].iloc[0]
output_dir = os.path.join(output_dir_base, "size_"+str(size))
os.makedirs(output_dir, exist_ok=True)
# Plot metrics
plot_metrics(df, size, output_dir)
if __name__ == "__main__":
main()