Skip to content

Commit ca19ea7

Browse files
author
George Bisbas
committed
misc: Avoid reinitialization of parent class and minor fixes
1 parent b4fbddd commit ca19ea7

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

benchmarks/user/advisor/run_advisor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from subprocess import check_output, PIPE, Popen
99
from tempfile import gettempdir, mkdtemp
1010

11-
from advisor_logging import (check, log, progress, log_process)
11+
from advisor_logging import check, log, progress, log_process
1212

1313

1414
@click.command()

conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def skipif(items, whole_module=False):
8080
skipit = "`icx+cpu64` won't work with this test"
8181
break
8282
# Skip if icx or advisor are not available
83-
if i not in ('noadvisor',) or \
84-
not isinstance(configuration['compiler'], IntelCompiler) or \
85-
not get_advisor_path():
83+
if i == 'noadvisor' and \
84+
(not isinstance(configuration['compiler'], IntelCompiler) or
85+
not get_advisor_path()):
8686
skipit = "Only `icx+advisor` should be tested here"
8787
break
8888
# Skip if it won't run on Arm

devito/operator/profiling.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ class Profiler:
3333
_default_libs = []
3434
_ext_calls = []
3535

36+
_include_dirs = []
37+
_lib_dirs = []
38+
3639
_supports_async_sections = False
3740

3841
_verbosity = 0
3942

43+
_attempted_init = False
44+
4045
def __init__(self, name):
4146
self.name = name
4247

@@ -50,17 +55,7 @@ def __init__(self, name):
5055
# Python-level timers
5156
self.py_timers = OrderedDict()
5257

53-
# Instance attributes
54-
self._include_dirs = []
55-
self._lib_dirs = []
56-
57-
self.initialized = True
58-
59-
def add_include_dir(self, dir_path):
60-
self._include_dirs.append(dir_path)
61-
62-
def add_lib_dir(self, dir_path):
63-
self._lib_dirs.append(dir_path)
58+
self._attempted_init = True
6459

6560
def analyze(self, iet):
6661
"""
@@ -362,9 +357,6 @@ class AdvisorProfiler(AdvancedProfiler):
362357

363358
"""
364359
Rely on Intel Advisor 2025.1 for performance profiling.
365-
Tested versions of Intel Advisor:
366-
- As contained in Intel Parallel Studio 2020 v 2020 Update 2
367-
- As contained in Intel oneAPI 2021 beta08
368360
"""
369361

370362
_api_resume = '__itt_resume'
@@ -375,14 +367,18 @@ class AdvisorProfiler(AdvancedProfiler):
375367
_ext_calls = [_api_resume, _api_pause]
376368

377369
def __init__(self, name):
370+
if self._attempted_init:
371+
return
372+
378373
super().__init__(name)
379374

380375
path = get_advisor_path()
381376
if path:
382-
self.add_include_dir(path.joinpath('include').as_posix())
383-
self.add_lib_dir(path.joinpath('lib64').as_posix())
377+
self._include_dirs.append(path.joinpath('include').as_posix())
378+
self._lib_dirs.append(path.joinpath('lib64').as_posix())
379+
self._attempted_init = True
384380
else:
385-
self.initialized = False
381+
self._attempted_init = False
386382

387383
def analyze(self, iet):
388384
"""
@@ -517,13 +513,13 @@ def create_profile(name):
517513
level = configuration['profiling']
518514
profiler = profiler_registry[level](name)
519515

520-
if profiler.initialized:
516+
if profiler._attempted_init:
521517
return profiler
522518
else:
523519
warning(f"Couldn't set up `{level}` profiler; reverting to 'advanced'")
524520
profiler = profiler_registry['advanced'](name)
525521
# We expect the `advanced` profiler to always initialize successfully
526-
assert profiler.initialized
522+
assert profiler._attempted_init
527523
return profiler
528524

529525

0 commit comments

Comments
 (0)