File: plot_mem_from_trace.py

package info (click to toggle)
cp2k 6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 204,532 kB
  • sloc: fortran: 835,196; f90: 59,605; python: 9,861; sh: 7,882; cpp: 4,868; ansic: 2,807; xml: 2,185; lisp: 733; pascal: 612; perl: 547; makefile: 497; csh: 16
file content (48 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import re
import matplotlib.pyplot as plt

#===============================================================================
def main():
    if(len(sys.argv) != 2):
        print("Usage: plot_mem_from_trace.py <trace.out>")
        sys.exit(1)

    re_mem = re.compile("Hostmem: (\d+) MB GPUmem: (\d+) MB")
    trace_fn = sys.argv[1]
    f = open(trace_fn)
    hostmem_stats = []
    gpumem_stats = []
    for line in f.readlines():
        m = re_mem.search(line)
        if(not m):
            continue
        hostmem_stats.append(m.group(1))
        gpumem_stats.append(m.group(2))


    fig = plt.figure()
    ax1 = fig.add_subplot(111)

    ax1.plot(hostmem_stats,color="red", label="Host")
    ax1.set_ylabel('Host Memory Usage [MB]')
    ax1.set_xlabel('time')

    ax2 = ax1.twinx()
    ax2.plot(gpumem_stats, color="green", label="GPU")
    ax2.set_ylabel('GPU Memory Usage [MB]')


    handles1, labels1 = ax1.get_legend_handles_labels()
    handles2, labels2 = ax2.get_legend_handles_labels()
    plt.legend(handles1+handles2, labels1+labels2)
    plt.show()



#===============================================================================
main()
#EOF