-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_processing_ws.py
129 lines (106 loc) · 5.81 KB
/
post_processing_ws.py
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
117
118
119
120
121
122
123
124
125
126
127
128
129
import numpy as np
results_folder = 'results/'
f = 'biharmonic_3d'
nnodes = [1,2,4,8,16,32,64]
ntasks_per_node = [32,32,32,32,32,32,32]
nthreads = [1,1,1,1,1,1,1]
ncells0 = [[32,32,16],[32,32,32],[64,32,32],[64,64,32],[64,64,64],[128,64,64],[128,128,64]]
ncells1 = [[40,40,20],[40,40,40],[80,40,40],[80,80,40],[80,80,80],[160,80,80],[160,160,80]]
ncells = [ncells0,ncells1]
ncells_pp = [8,10]
degrees = [2,3,4]
timmings_bi_assembly = np.zeros((len(ncells),len(degrees), len(nnodes)))
timmings_dot_p = np.zeros((len(ncells),len(degrees), len(nnodes)))
for i1,nc in enumerate(ncells):
for i2,d in enumerate(degrees):
for i3, (nn,nt,nth) in enumerate(zip(nnodes, ntasks_per_node, nthreads)):
mpi_p = nn*nt
names = (f,'geof') + (nc[i3][0],nc[i3][1],nc[i3][2]) +(d,)*3 + (mpi_p, nth)
filename = '_'.join([str(i) for i in names])
try:
T = np.load(results_folder+filename+'.npy', allow_pickle=True)
T = T.item()
timmings_bi_assembly[i1,i2,i3] = min(T['bilinear_form_assembly_time'],T.get('blinear_form_assembly_time2', T['bilinear_form_assembly_time']))
timmings_dot_p[i1,i2,i3] = T['dot_product_time']
except:
timmings_bi_assembly[i1,i2,i3] = np.nan
timmings_solve_time[i1,i2,i3] = np.nan
timmings_dot_p[i1,i2,i3] = np.nan
ntasks_per_node = [2,2,2,2,2,2,2]
nthreads = [16,16,16,16,16,16,16]
timmings_bi_assembly_mth = np.zeros((len(ncells),len(degrees), len(nnodes)))
timmings_dot_p_mth = np.zeros((len(ncells),len(degrees), len(nnodes)))
for i1,nc in enumerate(ncells):
for i2,d in enumerate(degrees):
for i3, (nn,nt,nth) in enumerate(zip(nnodes, ntasks_per_node, nthreads)):
mpi_p = nn*nt
names = (f,'geof') + (nc[i3][0],nc[i3][1],nc[i3][2]) +(d,)*3 + (mpi_p, nth)
filename = '_'.join([str(i) for i in names])
try:
T = np.load(results_folder+filename+'.npy', allow_pickle=True)
T = T.item()
timmings_bi_assembly_mth[i1,i2,i3] = min(T['bilinear_form_assembly_time'],T.get('blinear_form_assembly_time2', T['bilinear_form_assembly_time']))
timmings_dot_p_mth[i1,i2,i3] = T['dot_product_time']
except:
timmings_bi_assembly_mth[i1,i2,i3] = np.nan
timmings_dot_p_mth[i1,i2,i3] = np.nan
##-----------------------------------------------------------------------------------------------------------------------
#from tabulate import tabulate
#headers = [""] + [str(nn*nt*nth) for nn,nt,nth in zip(nnodes, ntasks_per_node, nthreads)]
#if not all(np.isnan(v) for v in timmings_bi_assembly.flatten()):
# print("="*45,"Timings of the Matrix Assembly", "="*45)
# T = np.around(timmings_dot_p_mth, decimals=5)
# newT = []
# for i1,nc in enumerate(ncells):
# for i2,d in enumerate(degrees):
# newT.append(["nc = {} ** 3 , p = {}".format(nc[0][0],d)] + T[i1,i2].tolist())
# newT.append([" "]*len(T[0]))
# print(tabulate(newT, headers=headers, tablefmt="grid"))
# print("\n")
#raise
#====================================================================================================
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import cm
from matplotlib.legend_handler import HandlerLine2D
colors = np.linspace(0, 1, len(degrees))
colors = cm.rainbow(colors)
line_styles = ['>-','o-','s-','v-']
markers = ['>','o','s','v']
from itertools import product
titles = ['Matrix Assembly', 'Matrix Vector Product','Matrix Assembly', 'Matrix Vector Product']
fnames = ['matrix_assembly_biharmonic_weak_scaling', 'matrix_vector_product_biharmonic_weak_scaling','matrix_assembly_biharmonic_weak_scaling_multi_threading', 'matrix_vector_product_biharmonic_weak_scaling_multi_threading']
xaxist = [r'number of nodes', r'number of nodes',r'number of nodes',r'number of nodes']
timings = [[timmings_bi_assembly, timmings_bi_assembly_mth], [timmings_dot_p, timmings_dot_p_mth]]
nnodes = np.array(nnodes)
for title,fname,timings_i,xlabel in zip(titles, fnames, timings,xaxist):
fig = plt.figure(figsize=(10,15))
ax = fig.add_subplot(1, 1, 1)
for nc in range(len(ncells)):
for p in range(degrees[0],degrees[-1]+1):
mask = np.isfinite(timings_i[0][nc,p-degrees[0]])
line, = ax.plot(nnodes[mask], timings_i[0][nc,p-degrees[0]][mask], line_styles[nc],color=colors[p-degrees[0]])
mask = np.isfinite(timings_i[1][nc,p-degrees[0]])
line, = ax.plot(nnodes[mask], timings_i[1][nc,p-degrees[0]][mask], marker=markers[nc], linestyle='dashed', color=colors[p-degrees[0]])
row = '$n_{{el}}={}^3$'.format(ncells_pp[nc])
line, = ax.plot(np.nan*nnodes[mask], np.nan*timings_i[0][nc,0][mask], line_styles[nc],color='k', label=row)
for p in range(degrees[0],degrees[-1]+1):
row = '$p={}$ (Pure MPI)'.format(p)
line, = ax.plot(np.nan*nnodes[mask], np.nan*timings_i[0][0,p-degrees[0]][mask],color=colors[p-degrees[0]], label=row)
row = '$p={}$ (MPI+OpenMP)'.format(p)
line, = ax.plot(np.nan*nnodes[mask], np.nan*timings_i[0][0,p-degrees[0]][mask],linestyle='dashed', color=colors[p-degrees[0]], label=row)
box = ax.get_position()
# ax.set_position([box.x0, box.y0, box.width * 0.3, box.height])
# Put a legend to the right of the current axis
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
ax.set_xlabel( xlabel, rotation='horizontal' )
ax.set_ylabel( r'time [s]' )
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xticks([])
ax.set_xticks(nnodes)
ax.set_xticklabels([str(d) for d in nnodes])
ax.grid(True)
# ax.title.set_text(title)
fig.tight_layout()
fig.savefig("images/"+fname)