@@ -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