-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot_parareal_memory.py
85 lines (74 loc) · 2.66 KB
/
plot_parareal_memory.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
#!/usr/bin/python
import numpy
from matplotlib import pyplot as plt
from pylab import rcParams
from matplotlib.patches import Ellipse, Polygon
from subprocess import call
fs = 8
compiler = 'cray'
# Two functions to be used below
def extract_memory(line):
str_to_find = "max_rss', "
ind1 = line.find(str_to_find)
ind1 = ind1 + len(str_to_find)
ind2 = line.find("rchar")
# To ignore the , ' in the RUR file before rchar, ignore the last three entries
memory = int(line[ind1:ind2-3])
return memory
Nprocs = numpy.array([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24])
memory = numpy.zeros([3,Nprocs.size])
# Load serial energy
filename = "serial_f_Np1.rur"
f = open(filename,'r')
# Extract memory entry in RUR file
line1 = f.readline()
memory_fine = extract_memory(line1)/1024
f.close
# Load coarse runtime
filename = "serial_g_Np1.rur"
f = open(filename, 'r')
line1 = f.readline()
memory_coarse = extract_memory(line1)/1024
f.close
types = [ 'mpi', 'openmp', 'openmp_pipe' ]
for tt in range(0,3):
type = types.pop(0)
for ii in range(0,Nprocs.size):
np = Nprocs[ii]
filename = type+"_Np"+str(np)+".rur"
f = open(filename,'r')
line1 = f.readline()
if type=='mpi':
memory[tt,ii] = np*extract_memory(line1)/1024
else:
memory[tt,ii] = extract_memory(line1)/1024
line2 = f.readline()
f.close()
types = [ 'mpi', 'openmp', 'openmp_pipe' ]
print ("Memory fine serial propagator (MB): %4i" % memory_fine)
print ("Memory fine coarse propagator (MB): %4i" % memory_coarse)
for tt in range(0,3):
type = types.pop(0)
for ii in range(0,Nprocs.size):
print ("Memory for Parareal "+type+" on "+str(ii)+" cores (MB): %4i" % memory[tt,ii])
rcParams['figure.figsize'] = 2.5, 2.5
fig, ax = plt.subplots()
ind = numpy.arange(Nprocs.size)
width = 0.4
rects1 = ax.bar( ind, memory[0,:], width, color='b', hatch='x')
rects2 = ax.bar( ind+width, memory[2,:], width, color='r', hatch='\\')
#rects3 = ax.bar( ind+2*width, memory[2,:], width, color='r', hatch='-')
ax.plot( ind+1.0*width, memory_fine*Nprocs, 'k-', linewidth=1.0)
ax.legend( (rects1[0], rects2[0]), ('MPI','OpenMP','OpenMP(pipe)'), loc=2, fontsize=fs)
ax.set_xticks(ind+1.0*width)
ax.set_xticklabels( ('2', '4', '6', '8', '10', '12', '14', '16', '18', '20', '22', '24'))
for label in ax.xaxis.get_ticklabels()[::2]:
label.set_visible(False)
ax.tick_params(axis='both', which='major', labelsize=fs)
ax.set_xlabel(r'Number of cores $P$', fontsize=fs)
ax.set_ylabel(r'Memory in MByte $m(P)$', fontsize=fs, labelpad=5)
ax.set_ylim([0, 350])
#plt.show()
filename = 'memory_dora_'+compiler+'.pdf'
fig.savefig(filename, bbox_inches='tight')
call(["pdfcrop", filename, filename])