Repository navigation
Expand file tree
/
Copy pathpostprocess.py
More file actions
71 lines (62 loc) · 2.36 KB
/
Copy pathpostprocess.py
File metadata and controls
71 lines (62 loc) · 2.36 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
import matplotlib.pyplot as plt
import numpy as np
import os
# --- CREAZIONE CARTELLA OUTPUT ---
output_dir = "risultati_plot/RCM"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# --- DATI DI INPUT (Sostituisci con i tuoi valori reali) ---
np_list = np.array([1, 2, 3, 4])
# Tempi misurati (esempio)
t_asm = np.array([0.935, 0.566, 0.492, 0.414])
t_qr = np.array([43.22, 27.11, 19.64, 22.27])
t_giv = np.array([39.94, 26.63, 21.38, 21.62])
def get_metrics(times):
speedup = times[0] / times
efficiency = speedup / np_list
return speedup, efficiency
s_qr, e_qr = get_metrics(t_qr)
s_giv, e_giv = get_metrics(t_giv)
s_asm, e_asm = get_metrics(t_asm)
# --- GENERAZIONE CODICE LATEX ---
print("\n% --- COPIA DA QUI PER IL TUO FILE LATEX ---")
print("\\begin{table}[h!]")
print(" \\centering")
print(" \\begin{tabular}{|c|ccc|ccc|ccc|}")
print(" \\hline")
print(" N. Thread & \\multicolumn{3}{c|}{Assembly} & \\multicolumn{3}{c|}{GMRES QR} & \\multicolumn{3}{c|}{GMRES Givens} \\\\")
print(" & Time & $S_p$ & $E_p$ & Time & $S_p$ & $E_p$ & Time & $S_p$ & $E_p$ \\\\")
print(" \\hline")
for i in range(len(np_list)):
line = f" {np_list[i]} & {t_asm[i]:.2f} & {s_asm[i]:.2f} & {e_asm[i]:.2f} & {t_qr[i]:.2f} & {s_qr[i]:.2f} & {e_qr[i]:.2f} & {t_giv[i]:.2f} & {s_giv[i]:.2f} & {e_giv[i]:.2f} \\\\"
print(line)
print(" \\hline")
print(" \\end{tabular}")
print(" \\caption{Sensibility analysis: Time, Speedup & Efficiency}")
print("\\end{table}")
print("% --- FINE CODICE LATEX ---\n")
# --- PLOTTING ---
# Grafico Tempo
plt.figure(figsize=(8, 5))
plt.plot(np_list, t_qr, 'o-', label='GMRES QR')
plt.plot(np_list, t_giv, 's-', label='GMRES Givens')
plt.xlabel('Number of Thread (np)')
plt.ylabel('Time [s]')
plt.title('GMRES (restart = 20): Execution time')
plt.grid(True, linestyle='--')
plt.legend()
plt.savefig(f"{output_dir}/tempo_confronto.pdf")
plt.close()
# Grafico Speedup
plt.figure(figsize=(8, 5))
plt.plot(np_list, np_list, 'k--', label='Ideal', alpha=0.5)
plt.plot(np_list, s_qr, 'o-', label='Speedup QR')
plt.plot(np_list, s_giv, 's-', label='Speedup Givens')
plt.xlabel('Number of Thread (np)')
plt.ylabel('Speedup')
plt.title('Speedup GMRES (restart = 20)')
plt.grid(True, linestyle='--')
plt.legend()
plt.savefig(f"{output_dir}/speedup_confronto.pdf")
plt.close()
print(f"Grafici salvati in: {output_dir}")