Skip to content

Commit 960dbe6

Browse files
committed
small fixups for OMP Region Explorer
1 parent 4a3604a commit 960dbe6

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

pypop/notebook_interface/omp_explorer.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class OMPRegionExplorer(BokehBase):
1818
_omp_tooltip_template = [
1919
("Function(s)", "@{Region Function Fingerprint}"),
2020
("Location(s)", "@{Region Location Fingerprint}"),
21-
("Load Bal.", "@{Load Balance}"),
22-
("Length", "@{Region Length} ns"),
23-
("Avg. Comp.", "@{Average Computation Time}"),
24-
("Max. Comp.", "@{Maximum Computation Time}"),
25-
("Sum Comp.", "@{Region Total Computation}"),
21+
("Load Bal.", "@{Load Balance}{0.00}"),
22+
("Length", "@{Region Length}{0.000 a}s"),
23+
("Avg. Comp.", "@{Average Computation Time}{0.000 a}s"),
24+
("Max. Comp.", "@{Maximum Computation Time}{0.000 a}s"),
25+
("Sum Comp.", "@{Region Total Computation}{0.000 a}s"),
2626
]
2727

2828
def __init__(self, prv: PRV, fontsize=14):
@@ -32,9 +32,19 @@ def __init__(self, prv: PRV, fontsize=14):
3232

3333
def _build_plot(self):
3434

35-
omp_region_stats = self._prv.profile_openmp_regions()
36-
omp_region_stats["Region Start"] /= 1e9
37-
omp_region_stats["Region End"] /= 1e9
35+
omp_region_stats = self._prv.profile_openmp_regions().copy()
36+
37+
for tm in [
38+
"Region Start",
39+
"Region End",
40+
"Region Length",
41+
"Average Computation Time",
42+
"Maximum Computation Time",
43+
"Computation Delay Time",
44+
"Region Total Computation",
45+
"Region Delay Time",
46+
]:
47+
omp_region_stats[tm] /= 1e9
3848

3949
# Geometry calculations - start at 48 em width and 2em plus 2em per bar height up
4050
# to a maximum of 15 bars, then start shrinking the bars
@@ -51,6 +61,7 @@ def _build_plot(self):
5161
tools="xwheel_zoom,zoom_in,zoom_out,pan,reset,save",
5262
tooltips=self._omp_tooltip_template,
5363
)
64+
5465
for rank, rankdata in omp_region_stats.groupby(level="rank"):
5566
self._figure.hbar(
5667
y=rank,
@@ -68,14 +79,19 @@ def _build_plot(self):
6879

6980
n_ranks = len(omp_region_stats.index.unique(level="rank"))
7081
n_rankticks = n_ranks if n_ranks < 10 else 10
71-
rankticks = [
72-
int(x) for x in numpy.linspace(1, n_ranks, n_rankticks)
73-
]
82+
rankticks = [int(x) for x in numpy.linspace(1, n_ranks, n_rankticks)]
7483

7584
self._figure.yaxis.ticker = rankticks
7685

7786
self._figure.ygrid.visible = False
7887
self._figure.yaxis.major_tick_line_color = None
7988
self._figure.yaxis.axis_line_color = None
8089

90+
self._figure.xaxis.axis_label = "Time (s)"
91+
self._figure.xaxis.axis_label_text_font_size = "16pt"
92+
self._figure.xaxis.major_label_text_font_size = "16pt"
93+
self._figure.yaxis.axis_label = "Processes"
94+
self._figure.yaxis.axis_label_text_font_size = "16pt"
95+
self._figure.yaxis.major_label_text_font_size = "16pt"
96+
8197
self.update()

pypop/prv.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def __getattr__(self, attr):
116116

117117
if attr in PRV.record_types.values():
118118
self._parse_prv()
119-
return self.__getattribute__(attr)
120119

121120
return super().__getattribute__(attr)
122121

@@ -173,6 +172,18 @@ def _parse_pcf(self):
173172
except FileNotFoundError:
174173
raise FileNotFoundError("No PCF file accompanying PRV - cannot continue")
175174

175+
def add_interpreted_names(self):
176+
177+
if "Event Name" not in self.event:
178+
self.event["Event Name"] = self.event["event"].map(self.event_names)
179+
if "Event Value" not in self.event:
180+
self.event["Event Value"] = self.event.apply(
181+
lambda x: self.event_vals.get(x["event"], {}).get(
182+
x["value"], str(x["value"])
183+
),
184+
axis="columns",
185+
)
186+
176187
def _parse_prv(self):
177188

178189
self.state = None
@@ -327,19 +338,19 @@ def _read_binarycache(self, filename):
327338
try:
328339
self.state = hdfstore[PRV._statekey]
329340
except KeyError:
330-
pass
341+
self.state = None
331342
try:
332343
self.event = hdfstore[PRV._eventkey]
333344
except KeyError:
334-
pass
345+
self.event = None
335346
try:
336347
self.comm = hdfstore[PRV._commkey]
337348
except KeyError:
338-
pass
349+
self.comm = None
339350
try:
340351
self._omp_region_data = hdfstore[self._ompregionkey]
341352
except KeyError:
342-
pass
353+
self._omp_region_data = None
343354

344355
def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
345356
"""Profile OpenMP Region Info
@@ -455,7 +466,7 @@ def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
455466
region_fingerprints_func = region_funcs.apply(
456467
lambda x: ":".join(
457468
[
458-
self.omp_function_by_value(str(int(y)))
469+
self.omp_function_by_value(int(y))
459470
for y in x["value"].unique()
460471
]
461472
)
@@ -472,7 +483,7 @@ def profile_openmp_regions(self, no_progress=False, ignore_cache=False):
472483
region_fingerprints_loc = region_func_locs.apply(
473484
lambda x: ":".join(
474485
[
475-
self.omp_location_by_value(str(int(y)))
486+
self.omp_location_by_value(int(y))
476487
for y in x["value"].unique()
477488
]
478489
)
@@ -600,7 +611,7 @@ def openmp_region_summary(self, by_location=False):
600611
else:
601612
fingerprint_key = "Region Function Fingerprint"
602613

603-
runtime = self.metadata.elapsed_seconds * 1e-9
614+
runtime = self.metadata.elapsed_seconds * 1e9
604615
nproc = len(set(self.omp_region_data["Rank"]))
605616

606617
self.profile_openmp_regions()

0 commit comments

Comments
 (0)