-
Notifications
You must be signed in to change notification settings - Fork 1
/
kmp_verbose.py
91 lines (67 loc) · 2.81 KB
/
kmp_verbose.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
import numpy as np
import matplotlib.pyplot as plt
class output_parser():
def __init__(self,fn):
fh = open(fn)
lines = fh.readlines()
self.thread = dict()
self.procset = dict()
self.core = dict()
self.proc = dict()
for l in lines:
if 'OMP: Info #242' in l:
pid = -1
thread = -1
proc = -1
for i,ele in enumerate(l.split()):
if 'pid' in ele:
pid = int(l.split()[i+1])
if 'thread' in ele:
thread = int(l.split()[i+1])
if 'proc' in ele:
procset = int(l.split()[i+2][1:-1])
if pid >= 0 and thread >= 0 and procset >= 0:
if not pid in self.thread.keys():
self.thread[ pid] = [thread]
else:
self.thread[ pid].append(thread)
if not pid in self.procset.keys():
self.procset[pid] = [procset]
else:
self.procset[pid].append(procset)
if 'OMP: Info #171' in l:
proc = -1
core = -1
thread = -1
for i,ele in enumerate(l.split()):
if 'proc' in ele:
proc = int(l.split()[i+1])
if 'core' in ele:
core = int(l.split()[i+1])
if 'thread' in ele:
thread = int(l.split()[i+1])
if proc >= 0 and core >= 0 and thread >= 0:
if not thread in self.core.keys():
self.core[thread] = [core]
else:
self.core[thread].append(core)
if not thread in self.proc.keys():
self.proc[thread] = [proc]
else:
self.proc[thread].append(proc)
def plot_thread_bind(self,fignum=1):
fig = plt.figure(fignum)
plt.clf()
for pid in self.thread.keys():
plt.plot(self.thread[pid],self.procset[pid],'o',label='pid '+str(pid))
plt.xlabel('thread #')
plt.ylabel('proc set #')
plt.legend(loc=9,ncol=4)
def plot_proc_map(self,fignum=2):
fig = plt.figure(fignum)
plt.clf()
for thread in self.proc.keys():
plt.plot(self.core[thread],self.proc[thread],'o',label='thread '+str(thread))
plt.xlabel('core #')
plt.ylabel('OS proc #')
plt.legend(loc=9,ncol=4)